1-- @inline Snapshot.Cps02.mkState always
2-- @inline Snapshot.Cps02.unState always
3-- @inline Snapshot.Cps02.put arity=1
4-- @inline Snapshot.Cps02.get always
5module Snapshot.Cps02 where
9import Data.Function.Uncurried (Fn2, mkFn2, runFn2)
10import Data.Tuple (Tuple(..))
12newtype State s a = State (forall r. Fn2 (Fn2 s a r) s r)
14mkState :: forall s a. (forall r. (s -> a -> r) -> s -> r) -> State s a
15mkState k = State (mkFn2 \k' s -> k (runFn2 k') s)
17unState :: forall s a. State s a -> (forall r. (s -> a -> r) -> s -> r)
18unState (State k) k' s = runFn2 k (mkFn2 k') s
20instance Functor (State s) where
21 map f k = mkState \next1 s1 ->
22 unState k (\s2 -> next1 s2 <<< f) s1
24instance Apply (State s) where
27instance Applicative (State s) where
28 pure a = mkState \next s1 -> next s1 a
30instance Bind (State s) where
31 bind k1 k2 = mkState \next1 s1 ->
32 unState k1 (\s2 a -> unState (k2 a) next1 s2) s1
34instance Monad (State s)
36get :: forall s. State s s
37get = mkState \next s -> next s s
39put :: forall s. s -> State s Unit
40put s = mkState \next _ -> next s unit
42runState :: forall s a. s -> State s a -> Tuple s a
43runState s k = unState k Tuple s
45test4 :: State Int Unit
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list