June 8th, 2009

mutual y combinator

Blaaargh!!

do x     <- SM newVar
   as    <- SM (newVars (length fs))
   bs    <- SM (newVars (length fs))
   g'    <- return $ addSymbols (zip (map (\(n,_,_,_) -> n) fs) (map ATVar as)) Function g
   threadSM () (zipWith3 (ff g' x) as bs fs)
   collect t g' q
   SM (updateEqs (xqNewVars (as ++ bs) []))
   SM (updateEqs (uqNewVar x []))
   return q
where ff g x a b (f, p, ps, cs) =
   do (y:_) <- return $ getConstructorType g Function f l
      xs    <- SM (newVars (length ps))
      atype <- return $ mkArrows ((zipmatch (== p) y ps (map ATVar xs)) ++ [ATVar q])
      btype <- return $ mkArrows (map ATVar $ (zipmatch (== p) x ps xs) ++ [q])
      eqs   <- return [Assign b btype, Assign a atype]
      threadSM () (map (cf g a) cs)
      SM (updateEqs (xqNewVars xs eqs))
      return ()


Why won't it work??!?