# FunctorFix

19 messages
Open this post in threaded view
|

## FunctorFix

 Hi! There is the MonadFix class with the mfix method. However, there are situations where you need a fixed point operator of type a -> f a for some f, but f is not necessarily a monad. What about adding a FunctorFix class that is identical to MonadFix, except that it has a Functor, not a Monad, superclass constraint? All the best, Wolfgang _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

## Re: FunctorFix

 I assume you want to impose the MonadFix sliding law, ffix (fmap h . f) = fmap h (ffix (f . h)), for strict h. Do you also want the nesting law? ffix (\x -> ffix (\y -> f x y)) = ffix (\x -> f x x) Are there any other laws you'd like to add in place of the seemingly irrelevant purity and left shrinking laws? Can you give some sample instances and how one might use them? On Wed, Aug 30, 2017 at 2:59 PM, Wolfgang Jeltsch <[hidden email]> wrote: > Hi! > > There is the MonadFix class with the mfix method. However, there are > situations where you need a fixed point operator of type a -> f a for > some f, but f is not necessarily a monad. What about adding a FunctorFix > class that is identical to MonadFix, except that it has a Functor, not a > Monad, superclass constraint? > > All the best, > Wolfgang > _______________________________________________ > Libraries mailing list > [hidden email] > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries_______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

 In reply to this post by Jonathan S Am Samstag, den 02.09.2017, 14:08 -0500 schrieb Jonathan S: > I think that in addition to nesting and sliding, we should have the > following law: > > ffix (\x -> fmap (f x) g) = fmap (\y -> fix (\x -> f x y)) g > > I guess I'd call this the "pure left shrinking" law because it is the > composition of left shrinking and purity: I wonder whether “pure left shrinking” is an appropriate name for this. The shrinking is on the left, but the purity is on the right. Note that in “pure right shrinking”, a derived property discussed in Erkok’s thesis, both the shrinking and the purity are on the right. All the best, Wolfgang _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

## Re: FunctorFix

 Am Donnerstag, den 07.09.2017, 04:54 +0300 schrieb Wolfgang Jeltsch: > Am Samstag, den 02.09.2017, 14:08 -0500 schrieb Jonathan S: > > > > I think that in addition to nesting and sliding, we should have the > > following law: > > > > ffix (\x -> fmap (f x) g) = fmap (\y -> fix (\x -> f x y)) g > > > > I guess I'd call this the "pure left shrinking" law because it is > > the composition of left shrinking and purity: > > I wonder whether “pure left shrinking” is an appropriate name for > this. The shrinking is on the left, but the purity is on the right. > Note that in “pure right shrinking”, a derived property discussed in > Erkok’s thesis, both the shrinking and the purity are on the right. While we are at pure right shrinking, let me bring up another question: Why is there no general right shrinking axiom for MonadFix? Something like the following: Right Shrinking:     mfix (\ ~(x, _) -> f x >>= \ y -> g y >>= \z -> return (y, z)) >>= return . snd     =     mfix f >>= g Can this be derived from the MonadFix axioms? Or are there reasonable MonadFix instances for which it does not hold? All the best, Wolfgang _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

## Re: FunctorFix

 I think you'll at least have to specify that g is lazy, because f may let its argument "leak" arbitrarily into the return value of the action it produces. But I don't have a clear sense of whether this is a good law otherwise.On Sep 6, 2017 10:04 PM, "Wolfgang Jeltsch" <[hidden email]> wrote: While we are at pure right shrinking, let me bring up another question: Why is there no general right shrinking axiom for MonadFix? Something like the following: Right Shrinking:     mfix (\ ~(x, _) -> f x >>= \ y -> g y >>= \z -> return (y, z)) >>= return . snd     =     mfix f >>= g Can this be derived from the MonadFix axioms? Or are there reasonable MonadFix instances for which it does not hold? All the best, Wolfgang _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries _______________________________________________ Libraries mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|

## Re: FunctorFix

Open this post in threaded view
|