module ProjectM36.TypeConstructor where
import ProjectM36.Base
import qualified Data.Set as S
name :: TypeConstructor -> TypeConstructorName
name (ADTypeConstructor name' _) = name'
name (PrimitiveTypeConstructor name' _) = name'
name (TypeVariable _) = error "spam"
arguments :: TypeConstructor -> [TypeConstructor]
arguments (ADTypeConstructor _ args) = args
arguments (PrimitiveTypeConstructor _ _) = []
arguments (TypeVariable _) = []
typeVars :: TypeConstructor -> S.Set TypeVarName
typeVars (PrimitiveTypeConstructor _ _) = S.empty
typeVars (ADTypeConstructor _ args) = S.unions (map typeVars args)
typeVars (TypeVariable v) = S.singleton v