Skip to content
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

Port Maybe's Generic instance to this repo #55

Merged
merged 1 commit into from
Dec 25, 2020
Merged
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/Maybe.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Control.Plus (class Plus)

import Data.Eq (class Eq1)
import Data.Functor.Invariant (class Invariant, imapF)
import Data.Generic.Rep (class Generic)
import Data.Ord (class Ord1)

-- | The `Maybe` type is used to represent optional values and can be seen as
Expand Down Expand Up @@ -216,6 +217,8 @@ instance showMaybe :: Show a => Show (Maybe a) where
show (Just x) = "(Just " <> show x <> ")"
show Nothing = "Nothing"

derive instance genericMaybe :: Generic (Maybe a) _

-- | Takes a default value, a function, and a `Maybe` value. If the `Maybe`
-- | value is `Nothing` the default value is returned, otherwise the function
-- | is applied to the value inside the `Just` and the result is returned.
Expand Down