git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix #368
commit32532d8cd0f708d5a308a2cf52859cb566c3e7e5 authorPhil Freeman <paf31@cantab.net> dateFri 11 Apr 2014, 15:41 (13 years ago) parent408d74a
2 files changed+19
examples/passing/TypedWhere.purs+13 src/Language/PureScript/TypeChecker/Types.hs+6
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"
675675
676676inferLetBinding :: [Declaration] -> [Declaration] -> Value -> (Value -> UnifyT Type Check Value) -> UnifyT Type Check ([Declaration], Value)
677677inferLetBinding 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
678683inferLetBinding seen (ValueDeclaration ident nameKind [] Nothing val : rest) ret j = do
679684 valTy <- fresh
680685 Just moduleName <- checkCurrentModule <$> get
@@ -1103,3 +1108,4 @@ subsumes' val ty1 ty2 = do
11031108
11041109
11051110
1111+