Skip to content

Instantly share code, notes, and snippets.

@tarquin-the-brave
Created May 12, 2020 13:35
Show Gist options
  • Save tarquin-the-brave/aeae835c18a6dbb5066fddc120f8531e to your computer and use it in GitHub Desktop.
Save tarquin-the-brave/aeae835c18a6dbb5066fddc120f8531e to your computer and use it in GitHub Desktop.
instance Functor Prog where
fmap _ (Crashed e) = Crashed e
fmap f (End a) = End (f a)
fmap f (Running a) = Running (f a)
fmap f (AwaitInput a) = AwaitInput (f a)
instance Applicative Prog where
pure = Running
_ <*> (Crashed e) = Crashed e
(End f) <*> prog = fmap f prog
(Running f) <*> prog = fmap f prog
(AwaitInput f) <*> prog = fmap f prog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment