From 32553509f2c35e5333bfe2ce77223e763d4021e7 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Thu, 24 Dec 2020 09:56:40 -0800 Subject: [PATCH] Port generics-rep Maybe instance to this repo and derive it --- src/Data/Maybe.purs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Data/Maybe.purs b/src/Data/Maybe.purs index e0dd0e2..4faf09d 100644 --- a/src/Data/Maybe.purs +++ b/src/Data/Maybe.purs @@ -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 @@ -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.