module Data.MaybeLike.Instances
(
module Data.MaybeLike
) where
import Data.Eq ((==))
import Prelude (Bounded(maxBound), (/), isNaN)
import Prelude (Float, Double)
import Data.Char
import Data.Int
import Data.Word
import qualified Data.Maybe as M
import Data.MaybeLike
instance MaybeLike (M.Maybe a) a where
nothing = M.Nothing
isNothing = M.isNothing
just = M.Just
fromJust = M.fromJust
instance MaybeLike Char Char where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Int Int where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Int8 Int8 where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Int16 Int16 where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Int32 Int32 where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Int64 Int64 where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Word Word where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Word8 Word8 where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Word16 Word16 where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Word32 Word32 where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Word64 Word64 where
nothing = maxBound
isNothing v = v == maxBound
just v = v
fromJust v = v
instance MaybeLike Float Float where
nothing = 0/0
isNothing = isNaN
just v = v
fromJust v = v
instance MaybeLike Double Double where
nothing = 0/0
isNothing = isNaN
just v = v
fromJust v = v