Skip to content

Instantly share code, notes, and snippets.

@Rydgel
Created July 31, 2018 06:58
Show Gist options
  • Save Rydgel/894e44ccce8933374a015349c4d8cabf to your computer and use it in GitHub Desktop.
Save Rydgel/894e44ccce8933374a015349c4d8cabf to your computer and use it in GitHub Desktop.
instance Monad f => Applicative (OptionalT f) where
pure ::
a
-> OptionalT f a
pure =
OptionalT . pure . pure
(<*>) ::
OptionalT f (a -> b)
-> OptionalT f a
-> OptionalT f b
(OptionalT f) <*> (OptionalT a) =
OptionalT (lift2 (<*>) f a)
-- (<$>) for OptionalT: OK
-- (<*>) for OptionalT
-- one: OK
-- two: OK
-- three: OK
-- four: OK
-- five: FAIL
-- test/Course/StateTTest.hs:133:
-- expected: [Empty]
-- but got: [Empty,Empty]
-- six: FAIL
-- test/Course/StateTTest.hs:136:
-- expected: [Full 2,Full 3,Empty]
-- but got: [Full 2,Full 3,Empty,Empty]
-- seven: OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment