git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
More examples
667eeefPhil Freeman
examples/TypeDecl.psnew file+17
@@ -0,0 +1,17 @@
1+id :: (a) -> a
2+
3+id = \x -> x
4+
5+k :: (String) -> (Number) -> String
6+
7+k = \x -> \y -> x
8+
9+iterate :: (Number) -> ((a) -> a) -> (a) -> a
10+
11+iterate = \n -> \f -> \a -> {
12+ var result = a;
13+ for (var i = 0; i < n; i = i + 1) {
14+ result = f(result);
15+ }
16+ return result;
17+}
src/PureScript/CodeGen.hs+1−1
@@ -349,7 +349,7 @@ typeToPs = fromMaybe (error "Incomplete pattern") . pattern matchType
349 operators :: OperatorTable Type String
349 operators :: OperatorTable Type String
350 operators =
350 operators =
351 OperatorTable $ [ AssocL typeApp $ \f x -> f ++ " " ++ x
351 OperatorTable $ [ AssocL typeApp $ \f x -> f ++ " " ++ x
352− , Split function $ \args ret -> "(" ++ intercalate "," (map typeToPs args) ++ ") -> " ++ typeToPs ret ]
352+ , Split function $ \args ret -> "(" ++ intercalate ", " (map typeToPs args) ++ ") -> " ++ typeToPs ret ]
353
353
354externToJs :: (String, Type) -> String
354externToJs :: (String, Type) -> String
355externToJs (name, ty) = "extern " ++ name ++ " :: " ++ typeToPs ty
355externToJs (name, ty) = "extern " ++ name ++ " :: " ++ typeToPs ty
src/PureScript/TypeChecker/Types.hs+1−1
@@ -196,7 +196,7 @@ typeConstraints m (Case val binders) = do
196 return (cs1 ++ cs2, ret)
196 return (cs1 ++ cs2, ret)
197typeConstraints m (TypedValue val ty) = do
197typeConstraints m (TypedValue val ty) = do
198 (cs, n1) <- typeConstraints m val
198 (cs, n1) <- typeConstraints m val
199− return ([TypeConstraint n1 ty], n1)
199+ return (TypeConstraint n1 ty : cs, n1)
200 -- TODO: Kind-check the type
200 -- TODO: Kind-check the type
201
201
202unaryOperatorConstraints :: UnaryOperator -> Int -> Int -> [TypeConstraint]
202unaryOperatorConstraints :: UnaryOperator -> Int -> Int -> [TypeConstraint]