27 lines
567 B
Haskell
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'
|