git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
#188 Support for multiple data constructor arguments
commit997c4eebee7bafe6ce1015b8f13aa39aed1bab17 authorPhil Freeman <paf31@cantab.net> dateMon 10 Feb 2014, 20:16 (13 years ago) parent57dde89
15 files changed+116−118
docgen/Main.hs+2−2 docs/source/prelude.rst+1−3 examples/failing/KindError.purs+1−1 examples/passing/MultipleConstructorArgs.purs+14 prelude/README.md+1−3 prelude/prelude.purs+44−47 src/Language/PureScript/CodeGen/JS.hs+20−22 src/Language/PureScript/Declarations.hs+1−1 src/Language/PureScript/Parser/Declarations.hs+1−1 src/Language/PureScript/Parser/Types.hs+5−1 src/Language/PureScript/Parser/Values.hs+6−7 src/Language/PureScript/Pretty/Values.hs+1−2 src/Language/PureScript/TypeChecker.hs+8−8 src/Language/PureScript/TypeChecker/Types.hs+9−14 src/Language/PureScript/Values.hs+2−6
docgen/Main.hs+2−2
@@ -92,8 +92,8 @@ renderDeclaration n (P.ExternDeclaration _ ident _ ty) =
9292renderDeclaration n (P.DataDeclaration name args ctors) = do
9393 let typeName = P.runProperName name ++ " " ++ intercalate " " args
9494 atIndent n $ "data " ++ typeName ++ " where"
95− forM_ ctors $ \(ctor, ty) -> do
96− atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ maybe "" ((++ " -> ") . P.prettyPrintType) ty ++ typeName
95+ forM_ ctors $ \(ctor, tys) -> do
96+ atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ concat (map (\ty -> P.prettyPrintType ty ++ " -> ") tys) ++ typeName
9797renderDeclaration n (P.ExternDataDeclaration name kind) =
9898 atIndent n $ "data " ++ P.runProperName name ++ " :: " ++ P.prettyPrintKind kind
9999renderDeclaration n (P.TypeSynonymDeclaration name args ty) = do
docs/source/prelude.rst+1−3
@@ -413,7 +413,7 @@ Types
413413::
414414
415415 data Tuple a b where
416− Tuple :: { snd :: b, fst :: a } -> Tuple a b
416+ Tuple :: a -> b -> Tuple a b
417417
418418Type Classes
419419~~~~~~~~~~~~
@@ -432,8 +432,6 @@ Values
432432
433433 curry :: forall c. forall b. forall a. (Tuple a b -> c) -> a -> b -> c
434434
435− tuple :: forall b. forall a. a -> b -> Tuple a b
436−
437435 uncurry :: forall c. forall b. forall a. (a -> b -> c) -> Tuple a b -> c
438436
439437 unzip :: forall b. forall a. [Tuple a b] -> Tuple [a] [b]
examples/failing/KindError.purs+1−1
@@ -1,3 +1,3 @@
11module KindError where
22
3− data KindError f a = One f | Two f a
3+ data KindError f a = One f | Two (f a)
examples/passing/MultipleConstructorArgs.pursnew file+14
@@ -0,0 +1,14 @@
1+module MultipleConstructorArgs where
2+
3+data P a b = P a b
4+
5+runP :: forall a b r. (a -> b -> r) -> P a b -> r
6+runP f (P a b) = f a b
7+
8+module Main where
9+
10+import Prelude
11+import MultipleConstructorArgs
12+import Global
13+
14+main = Trace.trace (runP (\s n -> s ++ show n) (P "Test" 1))
prelude/README.md+1−3
@@ -369,7 +369,7 @@
369369### Types
370370
371371 data Tuple a b where
372− Tuple :: { snd :: b, fst :: a } -> Tuple a b
372+ Tuple :: a -> b -> Tuple a b
373373
374374
375375### Type Classes
@@ -384,8 +384,6 @@
384384
385385 curry :: forall c. forall b. forall a. (Tuple a b -> c) -> a -> b -> c
386386
387− tuple :: forall b. forall a. a -> b -> Tuple a b
388−
389387 uncurry :: forall c. forall b. forall a. (a -> b -> c) -> Tuple a b -> c
390388
391389 unzip :: forall b. forall a. [Tuple a b] -> Tuple [a] [b]
prelude/prelude.purs+44−47
@@ -516,8 +516,8 @@ module Arrays where
516516 foldl _ b [] = b
517517 foldl f b (a:as) = foldl f (f a b) as
518518
519− foreign import length "function length(xs) { \
520− \ return xs.length; \
519+ foreign import length "function length(xs) {\
520+ \ return xs.length;\
521521 \}" :: forall a. [a] -> Number
522522
523523 foreign import indexOf "function indexOf(l) {\
@@ -584,7 +584,7 @@ module Arrays where
584584
585585 foreign import splice "function splice(s) {\
586586 \ return function(e) {\
587− \ return function(l1) { \
587+ \ return function(l1) {\
588588 \ return function(l2) {\
589589 \ return l2.splice(s, e, l1);\
590590 \ }; \
@@ -654,27 +654,24 @@ module Tuples where
654654 import Prelude
655655 import Arrays
656656
657− data Tuple a b = Tuple { fst :: a, snd :: b }
657+ data Tuple a b = Tuple a b
658658
659659 instance (Prelude.Show a, Prelude.Show b) => Prelude.Show (Tuple a b) where
660− show (Tuple { fst = a, snd = b }) = "Tuple(" ++ show a ++ ", " ++ show b ++ ")"
660+ show (Tuple a b) = "Tuple(" ++ show a ++ ", " ++ show b ++ ")"
661661
662662 curry :: forall a b c. (Tuple a b -> c) -> a -> b -> c
663− curry f a b = f (tuple a b)
663+ curry f a b = f (Tuple a b)
664664
665665 uncurry :: forall a b c. (a -> b -> c) -> Tuple a b -> c
666− uncurry f (Tuple t) = f t.fst t.snd
667−
668− tuple :: forall a b. a -> b -> Tuple a b
669− tuple a b = Tuple { fst: a, snd: b }
666+ uncurry f (Tuple a b) = f a b
670667
671668 zip :: forall a b. [a] -> [b] -> [Tuple a b]
672− zip = zipWith tuple
669+ zip = zipWith Tuple
673670
674671 unzip :: forall a b. [Tuple a b] -> Tuple [a] [b]
675− unzip ((Tuple t):ts) = case unzip ts of
676− Tuple { fst = as, snd = bs } -> tuple (t.fst : as) (t.snd : bs)
677− unzip [] = tuple [] []
672+ unzip ((Tuple a b):ts) = case unzip ts of
673+ Tuple as bs -> Tuple (a : as) (b : bs)
674+ unzip [] = Tuple [] []
678675
679676module String where
680677
@@ -701,7 +698,7 @@ module String where
701698 \}" :: String -> String -> Number
702699
703700 foreign import localeCompare "function localeCompare(s1) {\
704− \ return function(s2) { \
701+ \ return function(s2) {\
705702 \ return s1.localeCompare(s2);\
706703 \ };\
707704 \}" :: String -> String -> Number
@@ -767,7 +764,7 @@ module Regex where
767764 \}" :: String -> String -> Regex
768765
769766 foreign import test "function test(r) {\
770− \ return function (s) { \
767+ \ return function (s) {\
771768 \ return r.test(s);\
772769 \ };\
773770 \}" :: Regex -> String -> Boolean
@@ -780,7 +777,7 @@ module Regex where
780777
781778 foreign import replaceR "function replaceR(r) {\
782779 \ return function(s1) {\
783− \ return function(s2) { \
780+ \ return function(s2) {\
784781 \ return s2.replace(r, s1);\
785782 \ };\
786783 \ };\
@@ -906,24 +903,24 @@ module Eff where
906903
907904 foreign import data Eff :: # ! -> * -> *
908905
909− foreign import retEff "function retEff(a) { \
910− \ return function() { \
911− \ return a; \
912− \ }; \
906+ foreign import retEff "function retEff(a) {\
907+ \ return function() {\
908+ \ return a;\
909+ \ };\
913910 \}" :: forall e a. a -> Eff e a
914911
915− foreign import bindEff "function bindEff(a) { \
916− \ return function(f) { \
917− \ return function() { \
918− \ return f(a())(); \
919− \ }; \
920− \ }; \
912+ foreign import bindEff "function bindEff(a) {\
913+ \ return function(f) {\
914+ \ return function() {\
915+ \ return f(a())();\
916+ \ };\
917+ \ };\
921918 \}" :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
922919
923920 type Pure a = forall e. Eff e a
924921
925− foreign import runPure "function runPure(f) { \
926− \ return f(); \
922+ foreign import runPure "function runPure(f) {\
923+ \ return f();\
927924 \}" :: forall a. Pure a -> a
928925
929926 instance Prelude.Monad (Eff e) where
@@ -986,22 +983,22 @@ module Errors where
986983
987984 foreign import data Error :: * -> !
988985
989− foreign import throwError "function throwError(e) { \
990− \ return function() { \
991− \ throw e; \
992− \ }; \
986+ foreign import throwError "function throwError(e) {\
987+ \ return function() {\
988+ \ throw e;\
989+ \ };\
993990 \}" :: forall a e r. e -> Eff (err :: Error e | r) a
994991
995− foreign import catchError "function catchError(c) { \
996− \ return function(t) { \
997− \ return function() { \
998− \ try { \
999− \ return t(); \
1000− \ } catch(e) { \
1001− \ return c(e)(); \
992+ foreign import catchError "function catchError(c) {\
993+ \ return function(t) {\
994+ \ return function() {\
995+ \ try {\
996+ \ return t();\
997+ \ } catch(e) {\
998+ \ return c(e)();\
1002999 \ }\
1003− \ }; \
1004− \ }; \
1000+ \ };\
1001+ \ };\
10051002 \}" :: forall e r a. (e -> Eff r a) -> Eff (err :: Error e | r) a -> Eff r a
10061003
10071004module IORef where
@@ -1054,11 +1051,11 @@ module Trace where
10541051
10551052 foreign import data Trace :: !
10561053
1057− foreign import trace "function trace(s) { \
1058− \ return function() { \
1059− \ console.log(s); \
1060− \ return {}; \
1061− \ }; \
1054+ foreign import trace "function trace(s) {\
1055+ \ return function() {\
1056+ \ console.log(s);\
1057+ \ return {};\
1058+ \ };\
10621059 \}" :: forall r. String -> Eff (trace :: Trace | r) {}
10631060
10641061 print :: forall a r. (Prelude.Show a) => a -> Eff (trace :: Trace | r) {}
src/Language/PureScript/CodeGen/JS.hs+20−22
@@ -74,16 +74,14 @@ declToJs opts mp (BindingGroupDeclaration vals) e =
7474 : setProperty ident (var ident) mp
7575 ) vals
7676declToJs _ mp (DataDeclaration _ _ ctors) _ =
77− Just $ flip concatMap ctors $ \(pn@(ProperName ctor), maybeTy) ->
78− let
79− ctorJs =
80− case maybeTy of
81− Nothing -> JSVariableIntroduction ctor (Just (JSObjectLiteral [ ("ctor", JSStringLiteral (show (Qualified (Just mp) pn))) ]))
82− Just _ -> JSFunction (Just ctor) ["value"]
83− (JSBlock [JSReturn
84− (JSObjectLiteral [ ("ctor", JSStringLiteral (show (Qualified (Just mp) pn)))
85− , ("value", JSVar "value") ])])
86− in ctorJs : setProperty (Escaped ctor) (JSVar ctor) mp
77+ Just $ flip concatMap ctors $ \(pn@(ProperName ctor), tys) ->
78+ JSVariableIntroduction ctor (Just (go pn 0 tys [])) : setProperty (Escaped ctor) (JSVar ctor) mp
79+ where
80+ go pn _ [] values =
81+ JSObjectLiteral [ ("ctor", JSStringLiteral (show (Qualified (Just mp) pn))), ("values", JSArrayLiteral $ reverse values) ]
82+ go pn index (_ : tys') values =
83+ JSFunction Nothing ["value" ++ show index]
84+ (JSBlock [JSReturn (go pn (index + 1) tys' (JSVar ("value" ++ show index) : values))])
8785declToJs opts mp (DataBindingGroupDeclaration ds) e =
8886 Just $ concat $ mapMaybe (flip (declToJs opts mp) e) ds
8987declToJs _ mp (ExternDeclaration importTy ident (Just js) _) _ =
@@ -263,23 +261,23 @@ binderToJs _ _ varName done (BooleanBinder False) =
263261 return [JSIfElse (JSUnary Not (JSVar varName)) (JSBlock done) Nothing]
264262binderToJs m e varName done (VarBinder ident) =
265263 return (JSVariableIntroduction (identToJs ident) (Just (JSVar varName)) : done)
266−binderToJs m e varName done (NullaryBinder ctor) =
264+binderToJs m e varName done (ConstructorBinder ctor bs) = do
265+ js <- go 0 done bs
267266 if isOnlyConstructor m e ctor
268267 then
269− return done
270− else
271− return [JSIfElse (JSBinary EqualTo (JSAccessor "ctor" (JSVar varName)) (JSStringLiteral (show ((\(mp, nm) -> Qualified (Just mp) nm) $ canonicalizeDataConstructor m e ctor)))) (JSBlock done) Nothing]
272−binderToJs m e varName done (UnaryBinder ctor b) = do
273− value <- fresh
274− js <- binderToJs m e value done b
275− let success = JSBlock (JSVariableIntroduction value (Just (JSAccessor "value" (JSVar varName))) : js)
276− if isOnlyConstructor m e ctor
277− then
278− return [success]
268+ return js
279269 else
280270 return [JSIfElse (JSBinary EqualTo (JSAccessor "ctor" (JSVar varName)) (JSStringLiteral (show ((\(mp, nm) -> Qualified (Just mp) nm) $ canonicalizeDataConstructor m e ctor))))
281− success
271+ (JSBlock js)
282272 Nothing]
273+ where
274+ go :: Integer -> [JS] -> [Binder] -> Gen [JS]
275+ go _ done' [] = return done'
276+ go index done' (binder:bs') = do
277+ argVar <- fresh
278+ done'' <- go (index + 1) done' bs'
279+ js <- binderToJs m e argVar done'' binder
280+ return (JSVariableIntroduction argVar (Just (JSIndexer (JSNumericLiteral (Left index)) (JSAccessor "values" (JSVar varName)))) : js)
283281binderToJs m e varName done (ObjectBinder bs) = go done bs
284282 where
285283 go :: [JS] -> [(String, Binder)] -> Gen [JS]
src/Language/PureScript/Declarations.hs+1−1
@@ -72,7 +72,7 @@ data Declaration
7272 -- |
7373 -- A data type declaration (name, arguments, data constructors)
7474 --
75− = DataDeclaration ProperName [String] [(ProperName, Maybe Type)]
75+ = DataDeclaration ProperName [String] [(ProperName, [Type])]
7676 -- |
7777 -- A minimal mutually recursive set of data type declarations
7878 --
src/Language/PureScript/Parser/Declarations.hs+1−1
@@ -40,7 +40,7 @@ parseDataDeclaration = do
4040 name <- indented *> properName
4141 tyArgs <- many (indented *> identifier)
4242 _ <- lexeme $ indented *> P.char '='
43− ctors <- sepBy1 ((,) <$> properName <*> P.optionMaybe (indented *> parsePolyType)) pipe
43+ ctors <- sepBy1 ((,) <$> properName <*> P.many (indented *> parseTypeAtom)) pipe
4444 return $ DataDeclaration name tyArgs ctors
4545
4646parseTypeDeclaration :: P.Parsec String ParseState Declaration
src/Language/PureScript/Parser/Types.hs+5−1
@@ -15,7 +15,8 @@
1515
1616module Language.PureScript.Parser.Types (
1717 parseType,
18− parsePolyType
18+ parsePolyType,
19+ parseTypeAtom
1920) where
2021
2122import Language.PureScript.Types
@@ -60,6 +61,9 @@ parseForAll :: P.Parsec String ParseState Type
6061parseForAll = (mkForAll <$> (P.try (reserved "forall") *> P.many1 (indented *> identifier) <* indented <* dot)
6162 <*> parseConstrainedType)
6263
64+-- |
65+-- Parse a type as it appears in e.g. a data constructor
66+--
6367parseTypeAtom :: P.Parsec String ParseState Type
6468parseTypeAtom = indented *> P.choice (map P.try
6569 [ parseNumber
src/Language/PureScript/Parser/Values.hs+6−7
@@ -228,11 +228,11 @@ parseNumberBinder = NumberBinder <$> C.integerOrFloat
228228parseVarBinder :: P.Parsec String ParseState Binder
229229parseVarBinder = VarBinder <$> C.parseIdent
230230
231−parseNullaryBinder :: P.Parsec String ParseState Binder
232−parseNullaryBinder = NullaryBinder <$> C.lexeme (C.parseQualified C.properName)
231+parseNullaryConstructorBinder :: P.Parsec String ParseState Binder
232+parseNullaryConstructorBinder = ConstructorBinder <$> C.lexeme (C.parseQualified C.properName) <*> pure []
233233
234−parseUnaryBinder :: P.Parsec String ParseState Binder
235−parseUnaryBinder = UnaryBinder <$> C.lexeme (C.parseQualified C.properName) <*> (C.indented *> parseBinder)
234+parseConstructorBinder :: P.Parsec String ParseState Binder
235+parseConstructorBinder = ConstructorBinder <$> C.lexeme (C.parseQualified C.properName) <*> (many (C.indented *> parseBinderNoParens))
236236
237237parseObjectBinder :: P.Parsec String ParseState Binder
238238parseObjectBinder = ObjectBinder <$> C.braces (C.commaSep (C.indented *> parseIdentifierAndBinder))
@@ -262,8 +262,7 @@ parseBinderAtom = P.choice (map P.try
262262 , parseNumberBinder
263263 , parseNamedBinder
264264 , parseVarBinder
265− , parseUnaryBinder
266− , parseNullaryBinder
265+ , parseConstructorBinder
267266 , parseObjectBinder
268267 , parseArrayBinder
269268 , C.parens parseBinder ]) P.<?> "binder"
@@ -287,7 +286,7 @@ parseBinderNoParens = P.choice (map P.try
287286 , parseNumberBinder
288287 , parseNamedBinder
289288 , parseVarBinder
290− , parseNullaryBinder
289+ , parseNullaryConstructorBinder
291290 , parseObjectBinder
292291 , parseArrayBinder
293292 , C.parens parseBinder ]) P.<?> "binder"
src/Language/PureScript/Pretty/Values.hs+1−2
@@ -119,8 +119,7 @@ prettyPrintBinderAtom = mkPattern match
119119 match (BooleanBinder True) = Just "true"
120120 match (BooleanBinder False) = Just "false"
121121 match (VarBinder ident) = Just $ show ident
122− match (NullaryBinder ctor) = Just $ show ctor
123− match (UnaryBinder ctor b) = Just $ show ctor ++ " " ++ prettyPrintBinder b
122+ match (ConstructorBinder ctor args) = Just $ show ctor ++ " " ++ intercalate " " (map (parens . prettyPrintBinder) args)
124123 match (ObjectBinder bs) = Just $ "{ " ++ intercalate ", " (map (uncurry prettyPrintObjectPropertyBinder) bs) ++ " }"
125124 match (ArrayBinder bs) = Just $ "[ " ++ intercalate ", " (map prettyPrintBinder bs) ++ " ]"
126125 match (NamedBinder ident binder) = Just $ show ident ++ "@" ++ prettyPrintBinder binder
src/Language/PureScript/TypeChecker.hs+8−8
@@ -38,21 +38,21 @@ import Language.PureScript.Kinds
3838import Language.PureScript.Declarations
3939import Language.PureScript.Sugar.TypeClasses
4040
41−addDataType :: ModuleName -> ProperName -> [String] -> [(ProperName, Maybe Type)] -> Kind -> Check ()
41+addDataType :: ModuleName -> ProperName -> [String] -> [(ProperName, [Type])] -> Kind -> Check ()
4242addDataType moduleName name args dctors ctorKind = do
4343 env <- getEnv
4444 putEnv $ env { types = M.insert (moduleName, name) (ctorKind, Data) (types env) }
45− forM_ dctors $ \(dctor, maybeTy) ->
45+ forM_ dctors $ \(dctor, tys) ->
4646 rethrow (("Error in data constructor " ++ show dctor ++ ":\n") ++) $
47− addDataConstructor moduleName name args dctor maybeTy
47+ addDataConstructor moduleName name args dctor tys
4848
49−addDataConstructor :: ModuleName -> ProperName -> [String] -> ProperName -> Maybe Type -> Check ()
50−addDataConstructor moduleName name args dctor maybeTy = do
49+addDataConstructor :: ModuleName -> ProperName -> [String] -> ProperName -> [Type] -> Check ()
50+addDataConstructor moduleName name args dctor tys = do
5151 env <- getEnv
5252 dataConstructorIsNotDefined moduleName dctor
5353 when (runModuleName moduleName == dctor) $ throwError "A data constructor may not have the same name as its enclosing module."
5454 let retTy = foldl TypeApp (TypeConstructor (Qualified (Just moduleName) name)) (map TypeVar args)
55− let dctorTy = maybe retTy (flip function retTy) maybeTy
55+ let dctorTy = foldr function retTy tys
5656 let polyType = mkForAll args dctorTy
5757 putEnv $ env { dataConstructors = M.insert (moduleName, dctor) (qualifyAllUnqualifiedNames moduleName env polyType, DataConstructor) (dataConstructors env) }
5858
@@ -117,7 +117,7 @@ typeCheckAll _ [] = return []
117117typeCheckAll moduleName (d@(DataDeclaration name args dctors) : rest) = do
118118 rethrow (("Error in type constructor " ++ show name ++ ":\n") ++) $ do
119119 typeIsNotDefined moduleName name
120− ctorKind <- kindsOf moduleName name args (mapMaybe snd dctors)
120+ ctorKind <- kindsOf moduleName name args (concatMap snd dctors)
121121 addDataType moduleName name args dctors ctorKind
122122 ds <- typeCheckAll moduleName rest
123123 return $ d : ds
@@ -125,7 +125,7 @@ typeCheckAll moduleName (d@(DataBindingGroupDeclaration tys) : rest) = do
125125 rethrow ("Error in data binding group:\n" ++) $ do
126126 let syns = mapMaybe toTypeSynonym tys
127127 let dataDecls = mapMaybe toDataDecl tys
128− (syn_ks, data_ks) <- kindsOfAll moduleName syns (map (\(name, args, dctors) -> (name, args, mapMaybe snd dctors)) dataDecls)
128+ (syn_ks, data_ks) <- kindsOfAll moduleName syns (map (\(name, args, dctors) -> (name, args, concatMap snd dctors)) dataDecls)
129129 forM_ (zip dataDecls data_ks) $ \((name, args, dctors), ctorKind) -> do
130130 typeIsNotDefined moduleName name
131131 addDataType moduleName name args dctors ctorKind
src/Language/PureScript/TypeChecker/Types.hs+9−14
@@ -597,25 +597,20 @@ inferBinder val (StringBinder _) = val =?= tyString >> return M.empty
597597inferBinder val (NumberBinder _) = val =?= tyNumber >> return M.empty
598598inferBinder val (BooleanBinder _) = val =?= tyBoolean >> return M.empty
599599inferBinder val (VarBinder name) = return $ M.singleton name val
600−inferBinder val (NullaryBinder ctor) = do
601− env <- getEnv
602− Just moduleName <- checkCurrentModule <$> get
603− case M.lookup (qualify moduleName ctor) (dataConstructors env) of
604− Just (ty, _) -> do
605− _ <- subsumes Nothing ty val
606− return M.empty
607− _ -> throwError $ "Constructor " ++ show ctor ++ " is not defined"
608−inferBinder val (UnaryBinder ctor binder) = do
600+inferBinder val (ConstructorBinder ctor binders) = do
609601 env <- getEnv
610602 Just moduleName <- checkCurrentModule <$> get
611603 case M.lookup (qualify moduleName ctor) (dataConstructors env) of
612604 Just (ty, _) -> do
613605 (_, fn) <- instantiatePolyTypeWithUnknowns (error "Data constructor types cannot contains constraints") ty
614− case fn of
615− TypeApp (TypeApp t obj) ret | t == tyFunction -> do
616− _ <- subsumes Nothing val ret
617− inferBinder obj binder
618− _ -> throwError $ "Constructor " ++ show ctor ++ " is not a unary constructor"
606+ go binders fn
607+ where
608+ go [] ty = do
609+ subsumes Nothing val ty
610+ return M.empty
611+ go (binder : binders) (TypeApp (TypeApp t obj) ret) | t == tyFunction =
612+ M.union <$> inferBinder obj binder <*> go binders ret
613+ go _ _ = throwError $ "Wrong number of arguments to constructor " ++ show ctor
619614 _ -> throwError $ "Constructor " ++ show ctor ++ " is not defined"
620615inferBinder val (ObjectBinder props) = do
621616 row <- fresh
src/Language/PureScript/Values.hs+2−6
@@ -247,13 +247,9 @@ data Binder
247247 --
248248 | VarBinder Ident
249249 -- |
250− -- A binder which matches a data constructor with no argument
250+ -- A binder which matches a data constructor
251251 --
252− | NullaryBinder (Qualified ProperName)
253− -- |
254− -- A binder which matches a data constructor with one argument
255− --
256− | UnaryBinder (Qualified ProperName) Binder
252+ | ConstructorBinder (Qualified ProperName) [Binder]
257253 -- |
258254 -- A binder which matches a record and binds its properties
259255 --