diff options
Diffstat (limited to 'std/Monad')
-rw-r--r-- | std/Monad/Parser.bruijn | 6 | ||||
-rw-r--r-- | std/Monad/State.bruijn | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/std/Monad/Parser.bruijn b/std/Monad/Parser.bruijn index 0364ea0..12c058f 100644 --- a/std/Monad/Parser.bruijn +++ b/std/Monad/Parser.bruijn @@ -38,7 +38,7 @@ fail [[R.err 1]] ⧗ a → (Parser a) pure [[R.ok (1 : 0)]] ⧗ a → (Parser a) -ap [[[R.apply (2 0) ok]]] ⧗ (Parser (a → b)) → (Parser a) → (Parser b) +ap [[[R.bind (2 0) ok]]] ⧗ (Parser (a → b)) → (Parser a) → (Parser b) ok &[[R.map ok (3 0)]] ok &[[(3 1) : 0]] @@ -52,14 +52,14 @@ string y [[0 [[[go]]] (pure [[0]])]] ⧗ String → (Parser a) return pure ⧗ a → (Parser a) -bind [[[R.apply (2 0) ok]]] ⧗ (Parser a) → (a → (Parser b)) → (Parser a) +bind [[[R.bind (2 0) ok]]] ⧗ (Parser a) → (a → (Parser b)) → (Parser a) ok &[[3 1 0]] …>>=… bind alt [[[2 0 R.ok err]]] ⧗ (Parser a) → (Parser a) → (Parser a) err [2 1 R.ok err] - err [R.err (error-compose 1 0)] + err R.err ∘ (error-compose 0) …<|>… alt diff --git a/std/Monad/State.bruijn b/std/Monad/State.bruijn index 8a7ef25..6cf6019 100644 --- a/std/Monad/State.bruijn +++ b/std/Monad/State.bruijn @@ -11,3 +11,8 @@ map [[[1 0 [[[0 2 (5 1)]]]]]] ⧗ (a → b) → (State s a) → (State s b) bind [[[2 0 [[3 0 1]]]]] ⧗ (State s a) → (a → (State s b)) → (State s b) …>>=… bind + +pure [[[0 2 1]]] ⧗ a → (State s a) + +:test ((w' ∘ c) >>= [(w' ∘ c) >>= [pure 0]] [[0]]) (w' [[0]]) +:test ((w' ∘ c) >>= [(w' ∘ c) >>= [pure 0]] [[1]]) (w' [[1]]) |