Files
loop/src/MaybeHelp.hs
T
2022-06-07 21:34:34 +01:00

27 lines
567 B
Haskell

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module MaybeHelp where
import Control.Lens
data Maybe' a = Just' {__Just' :: a} | Nothing'
deriving (Eq,Ord,Show)
fromJust' :: Maybe' a -> a
fromJust' mx = case mx of
Just' x -> x
Nothing' -> error "no fromJust'"
isJust' :: Maybe' a -> Bool
isJust' Just' {} = True
isJust' Nothing' = False
isNothing' :: Maybe' a -> Bool
isNothing' Just' {} = False
isNothing' Nothing' = True
strictify :: Maybe a -> Maybe' a
strictify Nothing = Nothing'
strictify (Just x) = Just' x
makeLenses ''Maybe'