@@ -128,16 +128,16 @@ constrain env (L _ _ expr) tipe =
128 recordType = record fieldTypes (TermN EmptyRecord1)
128 recordType = record fieldTypes (TermN EmptyRecord1)
129 return $ ex (map snd pairs) (CAnd (tipe === recordType : cs))
129 return $ ex (map snd pairs) (CAnd (tipe === recordType : cs))
131− field (name, args, body) = do
131+ field (name, body) = do
132− let value = List.foldl' (\e arg -> Loc.none (Lambda (PVar arg) e)) body args
133 v <- flexibleVar -- needs an ex
132 v <- flexibleVar -- needs an ex
134− c <- constrain env value (VarN v)
133+ c <- constrain env body (VarN v)
135 return ((name, v), c)
134 return ((name, v), c)
138 Markdown _ ->
137 Markdown _ ->
139 return $ tipe === Env.get env builtin "Element"
138 return $ tipe === Env.get env builtin "Element"
141 Let defs body ->
141 Let defs body ->
142 do c <- constrain env body tipe
142 do c <- constrain env body tipe
143 (schemes, rqs, fqs, header, c2, c1) <-
143 (schemes, rqs, fqs, header, c2, c1) <-
@@ -149,12 +149,12 @@ constrain env (L _ _ expr) tipe =
149 (c1 /\ c))
149 (c1 /\ c))
152−constrainDef env info (name, args, expr, maybeTipe) =
152+constrainDef env info (name, qs, expr, maybeTipe) =
153 let (schemes, rigidQuantifiers, flexibleQuantifiers, headers, c2, c1) = info in
153 let (schemes, rigidQuantifiers, flexibleQuantifiers, headers, c2, c1) = info in
154 case maybeTipe of
154 case maybeTipe of
155 Just tipe ->
155 Just tipe ->
156− do flexiVars <- mapM (\_ -> flexibleVar) args
156+ do flexiVars <- mapM (\_ -> flexibleVar) qs
157− let inserts = zipWith (\arg typ -> Map.insert arg (VarN typ)) args flexiVars
157+ let inserts = zipWith (\arg typ -> Map.insert arg (VarN typ)) qs flexiVars
158 env' = env { value = List.foldl' (\x f -> f x) (value env) inserts }
158 env' = env { value = List.foldl' (\x f -> f x) (value env) inserts }
159 typ = error "This should be the internal representation of the user defined type."
159 typ = error "This should be the internal representation of the user defined type."
160 scheme = Scheme { rigidQuantifiers = [],
160 scheme = Scheme { rigidQuantifiers = [],
@@ -171,9 +171,9 @@ constrainDef env info (name, args, expr, maybeTipe) =
172 Nothing ->
172 Nothing ->
173 do var <- flexibleVar
173 do var <- flexibleVar
174− rigidVars <- mapM (\_ -> rigidVar) args
174+ rigidVars <- mapM (\_ -> rigidVar) qs
175 let tipe = VarN var
175 let tipe = VarN var
176− inserts = zipWith (\arg typ -> Map.insert arg (VarN typ)) args rigidVars
176+ inserts = zipWith (\arg typ -> Map.insert arg (VarN typ)) qs rigidVars
177 env' = env { value = List.foldl' (\x f -> f x) (value env) inserts }
177 env' = env { value = List.foldl' (\x f -> f x) (value env) inserts }
178 c <- constrain env' expr tipe
178 c <- constrain env' expr tipe
179 return ( schemes
179 return ( schemes
@@ -185,7 +185,7 @@ constrainDef env info (name, args, expr, maybeTipe) =
186--collapseDefs :: [Def t v] -> [(String, [String], LExpr t v, Maybe Type)]
186--collapseDefs :: [Def t v] -> [(String, [String], LExpr t v, Maybe Type)]
187collapseDefs definitions =
187collapseDefs definitions =
188− map (\(name, (args, expr, tipe)) -> (name, args, expr, tipe)) defPairs
188+ map (\(name, (expr, tipe)) -> (name, expr, tipe)) defPairs
190 defPairs = Map.toList (go Map.empty Map.empty definitions)
190 defPairs = Map.toList (go Map.empty Map.empty definitions)
@@ -193,7 +193,8 @@ collapseDefs definitions =
193 (Map.map ($ Nothing) (Map.difference defs typs))
193 (Map.map ($ Nothing) (Map.difference defs typs))
194 go defs typs (d:ds) =
194 go defs typs (d:ds) =
195 case d of
195 case d of
196− Def name args body ->
196+ Def name body ->
197− go (Map.insert name ((,,) args body) defs) typs ds
197+ go (Map.insert name ((,) body) defs) typs ds
198 TypeAnnotation name typ ->
198 TypeAnnotation name typ ->
199 go defs (Map.insert name typ typs) ds
199 go defs (Map.insert name typ typs) ds