Skip to content

Commit 077e787

Browse files
authored
Merge pull request #25 from purescript/maybe
Add instances for Maybe
2 parents be3262a + 1c12247 commit 077e787

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Data/Unfoldable.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class Unfoldable1 t <= Unfoldable t where
4141
instance unfoldableArray :: Unfoldable Array where
4242
unfoldr = unfoldrArrayImpl isNothing (unsafePartial fromJust) fst snd
4343

44+
instance unfoldableMaybe :: Unfoldable Maybe where
45+
unfoldr f b = fst <$> f b
46+
4447
foreign import unfoldrArrayImpl
4548
:: forall a b
4649
. (forall x. Maybe x -> Boolean)

src/Data/Unfoldable1.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class Unfoldable1 t where
4141
instance unfoldable1Array :: Unfoldable1 Array where
4242
unfoldr1 = unfoldr1ArrayImpl isNothing (unsafePartial fromJust) fst snd
4343

44+
instance unfoldable1Maybe :: Unfoldable1 Maybe where
45+
unfoldr1 f b = Just (fst (f b))
46+
4447
foreign import unfoldr1ArrayImpl
4548
:: forall a b
4649
. (forall x. Maybe x -> Boolean)

0 commit comments

Comments
 (0)