You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mapWithIndex f = foldrWithIndex (\i x acc -> f i x : acc) nil
The implementation of FunctorWithIndex for Lazy List uses folding, which, unlike Functor, is not lazy.
It should be:
instancefunctorWithIndexList :: FunctorWithIndexIntListwhere
mapWithIndex f xs = List (go 0 <$> unwrap xs)
where
go i = \step ->case step ofNil->NilCons x xs' ->Cons (f i x) (List (go (i + 1) <$> unwrap xs'))
Activity