Skip to content

Instantly share code, notes, and snippets.

@itsfarseen
itsfarseen / MyState.hs
Last active January 6, 2020 09:34 — forked from merijn/MyState.hs
MyState homework solution
data MyState s a = MyState (s -> (a,s))
get :: MyState s s
get = MyState (\s -> (s, s))
put :: s -> MyState s ()
put s = MyState (\_ -> ((), s))
modify :: (s -> s) -> MyState s ()
modify f = MyState (\s -> ((), f s))