module Data.Yoko.MaybeKind
(
IsJust, MaybePlus1, MaybeMap, If
) where
type family If (c :: Bool) (a :: k) (b :: k) :: k
type instance If True a b = a
type instance If False a b = b
type family IsJust (x :: Maybe k) :: Bool
type instance IsJust Nothing = False
type instance IsJust (Just x) = True
type family MaybePlus1 (x :: Maybe k) (y :: Maybe k) :: Maybe k
type instance MaybePlus1 Nothing y = y
type instance MaybePlus1 (Just x) Nothing = Just x
type family MaybeMap (f :: k -> l) (x :: Maybe k) :: Maybe l
type instance MaybeMap f (Just x) = Just (f x)
type instance MaybeMap f Nothing = Nothing