@@ -234,13 +234,13 @@ caseGen tipe (p, ce@(C _ span e)) = do
234234 return ( as', Set.union cs cs', t )
235235
236236patternGen :: (Constraint -> Context Constraint)
237− -> Type
237+ -> Type -- Type of e in `case e of ...`
238238 -> TVarMap
239239 -> Pattern
240240 -> GuidCounter (TVarMap, ConstraintSet, Type)
241241patternGen ctxt tipe as pattern =
242242 case pattern of
243− PAnything -> do b <- beta ; return (Map.empty, Set.empty, b)
243+ PAnything -> do b <- beta ; return ( as, Set.empty, b )
244244 PVar v -> do
245245 b <- beta
246246 let cs = map (ctxt . (b :=:) . VarT) (Map.findWithDefault [] v as)
@@ -255,6 +255,15 @@ patternGen ctxt tipe as pattern =
255255 return ( Map.insert name [constr] as'
256256 , Set.insert (ctxt (VarT constr :=: t)) cs
257257 , output )
258+ PRecord fs ->
259+ do pairs <- mapM (\f -> do b <- beta; return (f,b)) fs
260+ b <- beta
261+ let t = RecordT (Map.fromList $ map (second (:[])) pairs) b
262+ mkCs (name,tipe) = map (ctxt . (tipe :=:) . VarT)
263+ (Map.findWithDefault [] name as)
264+ return ( foldr Map.delete as fs
265+ , Set.fromList (ctxt (t :=: tipe) : concatMap mkCs pairs)
266+ , t )
258267
259268
260269defScheme :: Def -> GuidCounter (Map.Map String [X], Scheme)