on 18f736a help sign in
project-m36/src/lib/ProjectM36/TypeConstructor.hs
19 lines 714 B history raw
1module ProjectM36.TypeConstructor where
2import ProjectM36.Base
3import qualified Data.Set as S
5name :: TypeConstructor -> TypeConstructorName
6name (ADTypeConstructor name' _) = name'
7name (PrimitiveTypeConstructor name' _) = name'
8name (TypeVariable _) = error "spam" --v --not really the name, but this is used for display only
10arguments :: TypeConstructor -> [TypeConstructor]
11arguments (ADTypeConstructor _ args) = args
12arguments (PrimitiveTypeConstructor _ _) = []
13arguments (TypeVariable _) = []
15typeVars :: TypeConstructor -> S.Set TypeVarName
16typeVars (PrimitiveTypeConstructor _ _) = S.empty
17typeVars (ADTypeConstructor _ args) = S.unions (map typeVars args)
18typeVars (TypeVariable v) = S.singleton v