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
I believe this should be equivalent to the MonadFix instance for []:
instanceMonadFixVectorwhere
mfix f
|V.null v0 =V.empty
|otherwise= v
where
v =V.generate (V.length v0)
(\i ->if i ==0thenV.head v0
else f (v ! i) ! i)
v0 = fix (f .V.head)
Of course, that generate can be replaced with something slightly more efficient, but I don't know if it's worth the trouble.
Actually, it may be worth the trouble. We don't really want to hold on to v0 any longer than necessary. So we should likely walk over it monadically to pull the thunks out, using the MonadFix instance for ST s. I'm not completely sure that works, but I think it probably does.
Activity
treeowl commentedon Jul 5, 2017
Actually, it may be worth the trouble. We don't really want to hold on to
v0any longer than necessary. So we should likely walk over it monadically to pull the thunks out, using theMonadFixinstance forST s. I'm not completely sure that works, but I think it probably does.Add MonadFix instance
Add MonadFix instance
Add MonadFix instance
Add MonadFix instance
treeowl commentedon Jul 11, 2017
Actually, some of this attempt to avoid leaks may be useless (particularly the part that forces use of
runST). I'll post an update and explanation.