Skip to content
  • Ross Paterson's avatar
    fix #5022: polymorphic definitions inside arrow rec · 4c8e0307
    Ross Paterson authored
    This is quite tricky, with examples like this:
    
    import Control.Arrow
    
    pRepeat :: a -> [a]
    pRepeat =
        proc x -> do
          rec
            s <- returnA -< f_rec x:s       -- f_rec is monomorphic here
            let f_later y = y               -- f_later is polymorphic here
            _ <- returnA -< (f_later True, f_later 'a')
            let f_rec y = y                 -- f_rec is polymorphic here
          returnA -< f_later s              -- f_later is monomorphic here
    
    Fixed the typechecking of arrow RecStmt to track changes to the monad
    version.  It was simplest to add a field recS_later_rets corresponding
    to recS_rec_rets.  It's only used for the arrow version, and always
    empty for the monad version.  But I think it would be cleaner to put
    the rec_ids and later_ids in a single list with supplementary info
    saying how they're used.
    
    Also fixed several glitches in the desugaring of arrow RecStmt.  The fact
    that the monomorphic variables shadow their polymorphic counterparts is a
    major pain.  Also a bit of general cleanup of DsArrows while I was there.
    4c8e0307