@@ -1,4 +1,10 @@
1−module TypeFun.Data.Maybe where
1+module TypeFun.Data.Maybe
2+ ( MaybeCase
3+ , NothingToConstr
4+ , JustToConstr
5+ , CatMaybes
6+ , FromJust
7+ ) where
28
39import GHC.Exts
410
@@ -8,7 +14,6 @@ type family MaybeCase (a :: Maybe k)
814 MaybeCase 'Nothing nothing just = nothing
915 MaybeCase ('Just k) nothing just = just k
1016
11−
1217type family NothingToConstr (a :: Maybe k) (c :: Constraint) :: Constraint where
1318 NothingToConstr 'Nothing c = c
1419 NothingToConstr ('Just a) c = ()
@@ -17,6 +22,7 @@ type family JustToConstr (a :: Maybe k) (c :: Constraint) :: Constraint where
1722 JustToConstr 'Nothing c = ()
1823 JustToConstr ('Just a) c = c
1924
25+-- | Like 'catMaybes' for type lists
2026type family CatMaybes (l :: [Maybe k]) :: [k] where
2127 CatMaybes '[] = '[]
2228 CatMaybes (('Just a) ': as) = a ': (CatMaybes as)