@@ -2,6 +2,7 @@ module Prelude.Maybe
3import Builtins
3import Builtins
4import Prelude.Algebra
4import Prelude.Algebra
6%access public
7%access public
7%default total
8%default total
@@ -58,3 +59,11 @@ instance (Semigroup a) => Semigroup (Maybe a) where
59instance (Monoid a) => Monoid (Maybe a) where
60instance (Monoid a) => Monoid (Maybe a) where
60 neutral = Nothing
61 neutral = Nothing
64+instance (Monoid a, Eq a) => Cast a (Maybe a) where
65+ cast x = if x == neutral then Nothing else Just x
67+instance (Monoid a) => Cast (Maybe a) a where
68+ cast Nothing = neutral