@@ -128,20 +128,20 @@ runtimeTypeChecks arg ty =
128128 maybe [] (argumentCheck (JSVar arg)) argTy
129129 where
130130 getFunctionArgumentType :: Type -> Maybe Type
131- getFunctionArgumentType (TypeApp (TypeApp Function funArg) _) = Just funArg
131+ getFunctionArgumentType (TypeApp (TypeApp t funArg) _) | t == tyFunction = Just funArg
132132 getFunctionArgumentType (ForAll _ ty') = getFunctionArgumentType ty'
133133 getFunctionArgumentType _ = Nothing
134134 argumentCheck :: JS -> Type -> [JS ]
135- argumentCheck val Number = [typeCheck val " number" ]
136- argumentCheck val String = [typeCheck val " string" ]
137- argumentCheck val Boolean = [typeCheck val " boolean" ]
138- argumentCheck val (TypeApp Array _) = [arrayCheck val]
135+ argumentCheck val t | t == tyNumber = [typeCheck val " number" ]
136+ argumentCheck val t | t == tyString = [typeCheck val " string" ]
137+ argumentCheck val t | t == tyBoolean = [typeCheck val " boolean" ]
138+ argumentCheck val (TypeApp t _) | t == tyArray = [arrayCheck val]
139139 argumentCheck val (Object row) =
140140 let
141141 (pairs, _) = rowToList row
142142 in
143143 typeCheck val " object" : concatMap (\ (prop, ty') -> argumentCheck (JSAccessor prop val) ty') pairs
144- argumentCheck val (TypeApp (TypeApp Function _) _) = [typeCheck val " function" ]
144+ argumentCheck val (TypeApp (TypeApp t _) _) | t == tyFunction = [typeCheck val " function" ]
145145 argumentCheck val (ForAll _ ty') = argumentCheck val ty'
146146 argumentCheck _ _ = []
147147 typeCheck :: JS -> String -> JS
@@ -253,7 +253,7 @@ isOnlyConstructor m e ctor =
253253 numConstructors ty = length $ filter (\ (ty1, _) -> ((==) `on` typeConstructor) ty ty1) $ M. elems $ dataConstructors e
254254 typeConstructor (TypeConstructor qual) = qualify m qual
255255 typeConstructor (ForAll _ ty) = typeConstructor ty
256- typeConstructor (TypeApp (TypeApp Function _) ty) = typeConstructor ty
256+ typeConstructor (TypeApp (TypeApp t _) ty) | t == tyFunction = typeConstructor ty
257257 typeConstructor (TypeApp ty _) = typeConstructor ty
258258 typeConstructor fn = error $ " Invalid arguments to typeConstructor: " ++ show fn
259259
0 commit comments