git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix #368
32532d8Phil Freeman
examples/passing/TypedWhere.pursnew file+13
@@ -0,0 +1,13 @@
1+module Main where
2+
3+data E a b = L a | R b
4+
5+lefts :: forall a b. [E a b] -> [a]
6+lefts = go []
7+ where
8+ go :: forall a b. [a] -> [E a b] -> [a]
9+ go ls [] = ls
10+ go ls (L a : rest) = go (a : ls) rest
11+ go ls (_ : rest) = go ls rest
12+
13+main = Debug.Trace.trace "Done"
src/Language/PureScript/TypeChecker/Types.hs+6
@@ -675,6 +675,11 @@ infer' _ = error "Invalid argument to infer"
675
675
676inferLetBinding :: [Declaration] -> [Declaration] -> Value -> (Value -> UnifyT Type Check Value) -> UnifyT Type Check ([Declaration], Value)
676inferLetBinding :: [Declaration] -> [Declaration] -> Value -> (Value -> UnifyT Type Check Value) -> UnifyT Type Check ([Declaration], Value)
677inferLetBinding seen [] ret j = (,) seen <$> j ret
677inferLetBinding seen [] ret j = (,) seen <$> j ret
678+inferLetBinding seen (ValueDeclaration ident nameKind [] Nothing tv@(TypedValue checkType val ty) : rest) ret j = do
679+ Just moduleName <- checkCurrentModule <$> get
680+ let dict = if isFunction val then M.singleton (moduleName, ident) (ty, nameKind) else M.empty
681+ TypedValue _ val' ty' <- if checkType then bindNames dict (check val ty) else return tv
682+ bindNames (M.singleton (moduleName, ident) (ty', nameKind)) $ inferLetBinding (seen ++ [ValueDeclaration ident nameKind [] Nothing (TypedValue checkType val' ty')]) rest ret j
678inferLetBinding seen (ValueDeclaration ident nameKind [] Nothing val : rest) ret j = do
683inferLetBinding seen (ValueDeclaration ident nameKind [] Nothing val : rest) ret j = do
679 valTy <- fresh
684 valTy <- fresh
680 Just moduleName <- checkCurrentModule <$> get
685 Just moduleName <- checkCurrentModule <$> get
@@ -1103,3 +1108,4 @@ subsumes' val ty1 ty2 = do
1103
1108
1104
1109
1105
1110
1111+