kempe-0.1.0.1: src/Kempe/Check/Restrict.hs
-- | Check that sum types have <256 constructors
module Kempe.Check.Restrict ( restrictConstructors
) where
import Data.Foldable.Ext
import Kempe.AST
import Kempe.Error (Error (FatSumType))
restrictConstructors :: Module a c b -> Maybe (Error a)
restrictConstructors = foldMapAlternative restrictDecl
restrictDecl :: KempeDecl a c b -> Maybe (Error a)
restrictDecl (TyDecl l n _ ls) | length ls > 256 = Just (FatSumType l n)
| otherwise = Nothing
restrictDecl _ = Nothing