aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2024-03-11 05:49:47 +0100
committerHayleigh Thompson <me@hayleigh.dev>2024-03-12 08:04:11 +0100
commit2902de25833338c0298afb0b959ab193d2a5e46e (patch)
tree2100bcb5c2468e35c0c379b553908669c5742247 /src
parentc0042287511c6aaa3447f9ffc38a095add939a25 (diff)
downloadlustre-2902de25833338c0298afb0b959ab193d2a5e46e.tar.gz
lustre-2902de25833338c0298afb0b959ab193d2a5e46e.zip
:recycle: Remove usages of deprecated gleam/function functions.
Diffstat (limited to 'src')
-rw-r--r--src/lustre/attribute.gleam9
-rw-r--r--src/lustre/cli/utils.gleam8
-rw-r--r--src/lustre/effect.gleam10
-rw-r--r--src/lustre/internals/runtime.gleam4
4 files changed, 10 insertions, 21 deletions
diff --git a/src/lustre/attribute.gleam b/src/lustre/attribute.gleam
index b99e241..e99e0f6 100644
--- a/src/lustre/attribute.gleam
+++ b/src/lustre/attribute.gleam
@@ -6,7 +6,7 @@
// IMPORTS ---------------------------------------------------------------------
-import gleam/dynamic.{type Dynamic}
+import gleam/dynamic.{type Decoder, type Dynamic}
import gleam/function
import gleam/int
import gleam/list
@@ -34,11 +34,8 @@ pub fn property(name: String, value: any) -> Attribute(msg) {
}
///
-pub fn on(
- name: String,
- handler: fn(Dynamic) -> Result(msg, error),
-) -> Attribute(msg) {
- Event("on" <> name, function.compose(handler, result.replace_error(_, Nil)))
+pub fn on(name: String, handler: Decoder(msg)) -> Attribute(msg) {
+ Event("on" <> name, handler)
}
///
diff --git a/src/lustre/cli/utils.gleam b/src/lustre/cli/utils.gleam
index ddf62e3..f001a35 100644
--- a/src/lustre/cli/utils.gleam
+++ b/src/lustre/cli/utils.gleam
@@ -1,7 +1,3 @@
-// IMPORTS ---------------------------------------------------------------------
-
-import gleam/function
-
// CHAINING RESULTS ------------------------------------------------------------
pub fn try(
@@ -26,7 +22,9 @@ pub fn map(with f: fn(x) -> e) -> ErrorStrategy(x, e) {
f
}
-pub const keep: ErrorStrategy(e, e) = function.identity
+pub fn keep(err: e) -> e {
+ err
+}
// BOOLEAN GUARDS --------------------------------------------------------------
diff --git a/src/lustre/effect.gleam b/src/lustre/effect.gleam
index 47c1da3..53cd40b 100644
--- a/src/lustre/effect.gleam
+++ b/src/lustre/effect.gleam
@@ -48,7 +48,6 @@
import gleam/json.{type Json}
import gleam/list
-import gleam/function
// TYPES -----------------------------------------------------------------------
@@ -128,13 +127,8 @@ pub fn batch(effects: List(Effect(msg))) -> Effect(msg) {
///
pub fn map(effect: Effect(a), f: fn(a) -> b) -> Effect(b) {
Effect({
- list.map(effect.all, fn(effect) {
- fn(dispatch, emit) {
- let dispatch = function.compose(f, dispatch)
-
- effect(dispatch, emit)
- }
- })
+ use eff <- list.map(effect.all)
+ fn(dispatch, emit) { eff(fn(msg) { dispatch(f(msg)) }, emit) }
})
}
diff --git a/src/lustre/internals/runtime.gleam b/src/lustre/internals/runtime.gleam
index 49d1982..f9c4e87 100644
--- a/src/lustre/internals/runtime.gleam
+++ b/src/lustre/internals/runtime.gleam
@@ -3,7 +3,6 @@
import gleam/dict.{type Dict}
import gleam/dynamic.{type Decoder, type Dynamic}
import gleam/erlang/process.{type Selector, type Subject}
-import gleam/function.{identity}
import gleam/list
import gleam/json.{type Json}
import gleam/option.{Some}
@@ -78,7 +77,8 @@ pub fn start(
handlers,
on_attribute_change,
)
- let selector = process.selecting(process.new_selector(), self, identity)
+ let selector =
+ process.selecting(process.new_selector(), self, fn(msg) { msg })
run_effects(init.1, self)
actor.Ready(state, selector)