Skip to content

Commit 4e6a10f

Browse files
Port generics-rep Maybe instance to this repo and derive it (#55)
1 parent cf33800 commit 4e6a10f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Data/Maybe.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Control.Plus (class Plus)
1010

1111
import Data.Eq (class Eq1)
1212
import Data.Functor.Invariant (class Invariant, imapF)
13+
import Data.Generic.Rep (class Generic)
1314
import Data.Ord (class Ord1)
1415

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

220+
derive instance genericMaybe :: Generic (Maybe a) _
221+
219222
-- | Takes a default value, a function, and a `Maybe` value. If the `Maybe`
220223
-- | value is `Nothing` the default value is returned, otherwise the function
221224
-- | is applied to the value inside the `Just` and the result is returned.

0 commit comments

Comments
 (0)