@@ -99,6 +99,14 @@ typeFromDef (def, _, _, _) = get def where
9999 get (CaseOp _ ty _ _ _ _) = Just ty
100100 get _ = Nothing
101101
102+-- Replace all occurences of `Lazy' s t` with `t` in a type
103+unLazy :: Type -> Type
104+unLazy typ = case typ of
105+ App (App (P _ lazy _) _) ty | lazy == sUN "Lazy'" -> unLazy ty
106+ Bind name binder ty -> Bind name (fmap unLazy binder) (unLazy ty)
107+ App t1 t2 -> App (unLazy t1) (unLazy t2)
108+ Proj ty i -> Proj (unLazy ty) i
109+ _ -> typ
102110
103111-- | reverse the edges for a directed acyclic graph
104112reverseDag :: Ord k => [((k, a), Set k)] -> [((k, a), Set k)]
@@ -362,7 +370,7 @@ matchTypesBulk istate maxScore type1 types = getAllResults startQueueOfQueues wh
362370 argNames1 = map fst dag1
363371 makeDag :: Type -> (ArgsDAG, Classes, Type)
364372 makeDag = first3 (zipWith (\i (ty, deps) -> (ty, (i, deps))) [0..] . reverseDag) .
365− computeDagP (isTypeClassArg classInfo) . vToP
373+ computeDagP (isTypeClassArg classInfo) . vToP . unLazy
366374 first3 f (a,b,c) = (f a, b, c)
367375
368376 -- update our state with the unification resolutions