Skip to content

Add instances for Maybe #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Data/Unfoldable.purs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Unfoldable1 t <= Unfoldable t where
instance unfoldableArray :: Unfoldable Array where
unfoldr = unfoldrArrayImpl isNothing (unsafePartial fromJust) fst snd

instance unfoldableMaybe :: Unfoldable Maybe where
unfoldr f b = fst <$> f b

foreign import unfoldrArrayImpl
:: forall a b
. (forall x. Maybe x -> Boolean)
Expand Down
3 changes: 3 additions & 0 deletions src/Data/Unfoldable1.purs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Unfoldable1 t where
instance unfoldable1Array :: Unfoldable1 Array where
unfoldr1 = unfoldr1ArrayImpl isNothing (unsafePartial fromJust) fst snd

instance unfoldable1Maybe :: Unfoldable1 Maybe where
unfoldr1 f b = Just (fst (f b))

foreign import unfoldr1ArrayImpl
:: forall a b
. (forall x. Maybe x -> Boolean)
Expand Down