module Kempe.Check.Restrict ( restrictConstructors
) where
import Data.Foldable.Ext
import Kempe.AST
import Kempe.Error (Error (FatSumType))
restrictConstructors :: Declarations a c b -> Maybe (Error a)
restrictConstructors :: Declarations a c b -> Maybe (Error a)
restrictConstructors = (KempeDecl a c b -> Maybe (Error a))
-> Declarations a c b -> Maybe (Error a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Alternative f) =>
(a -> f b) -> t a -> f b
foldMapAlternative KempeDecl a c b -> Maybe (Error a)
forall a c b. KempeDecl a c b -> Maybe (Error a)
restrictDecl
restrictDecl :: KempeDecl a c b -> Maybe (Error a)
restrictDecl :: KempeDecl a c b -> Maybe (Error a)
restrictDecl (TyDecl a
l TyName a
n [TyName a]
_ [(TyName b, [KempeTy a])]
ls) | [(TyName b, [KempeTy a])] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(TyName b, [KempeTy a])]
ls Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
256 = Error a -> Maybe (Error a)
forall a. a -> Maybe a
Just (a -> TyName a -> Error a
forall a. a -> TyName a -> Error a
FatSumType a
l TyName a
n)
| Bool
otherwise = Maybe (Error a)
forall a. Maybe a
Nothing
restrictDecl KempeDecl a c b
_ = Maybe (Error a)
forall a. Maybe a
Nothing