@@ -234,13 +234,13 @@ caseGen tipe (p, ce@(C _ span e)) = do
234 return ( as', Set.union cs cs', t )
234 return ( as', Set.union cs cs', t )
236patternGen :: (Constraint -> Context Constraint)
236patternGen :: (Constraint -> Context Constraint)
237− -> Type
237+ -> Type -- Type of e in `case e of ...`
238 -> TVarMap
238 -> TVarMap
239 -> Pattern
239 -> Pattern
240 -> GuidCounter (TVarMap, ConstraintSet, Type)
240 -> GuidCounter (TVarMap, ConstraintSet, Type)
241patternGen ctxt tipe as pattern =
241patternGen ctxt tipe as pattern =
242 case pattern of
242 case pattern of
243− PAnything -> do b <- beta ; return (Map.empty, Set.empty, b)
243+ PAnything -> do b <- beta ; return ( as, Set.empty, b )
244 PVar v -> do
244 PVar v -> do
245 b <- beta
245 b <- beta
246 let cs = map (ctxt . (b :=:) . VarT) (Map.findWithDefault [] v as)
246 let cs = map (ctxt . (b :=:) . VarT) (Map.findWithDefault [] v as)
@@ -255,6 +255,15 @@ patternGen ctxt tipe as pattern =
255 return ( Map.insert name [constr] as'
255 return ( Map.insert name [constr] as'
256 , Set.insert (ctxt (VarT constr :=: t)) cs
256 , Set.insert (ctxt (VarT constr :=: t)) cs
257 , output )
257 , output )
259+ do pairs <- mapM (\f -> do b <- beta; return (f,b)) fs
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)
260defScheme :: Def -> GuidCounter (Map.Map String [X], Scheme)
269defScheme :: Def -> GuidCounter (Map.Map String [X], Scheme)