Fixing Fix

M Farkas-Dyck strake888 at gmail.com
Tue Mar 24 06:23:44 UTC 2015


On 22/03/2015 at 23:01:47 -0400, David Feuer wrote:
> There are a good number of different packages that define either
> 
> newtype Fix f = Fix (f (Fix f))
> 
> or something equivalent except for naming. Most of the name variation
> is in the name of the data constructor and/or record selector. This
> does not look like an ideal situation to me. Most problematically, the
> only way to convert one to another is with unsafeCoerce.
> 
> I think it would be rather nice to choose one canonical place for this
> definition, and let everyone else use it.

+1

I propose

module Data.Fix where

newtype Fix f = Fix { unFix :: f (Fix f) }

Perhaps too we ought to name and define _ :: (∀ a . f a -> g a) -> Fix f -> Fix g there.


More information about the Libraries mailing list