Data.Fixed.Fixed constructor

Jules Bean jules at
Fri Jul 24 07:13:59 EDT 2009

Ashley Yakeley wrote:
> On Fri, 2009-07-24 at 00:58 -0400, David Menendez wrote:
>> It depends on how abstract you want Fixed to be. If you use the
>> derived Data instances, then gshow and gread (from Data.Generics.Text)
>> expose the implementation.
> But I'm going to expose the MkFixed constructor anyway. What's lost with
> a derived instance?

What's lost is that if I have the user-defined type:

data Foo = Foo Integer Micro

and I use, for example "everywhere" on it, then my everywhere functionn 
gets applied to the secret Integer subterm inside Fixed.

For example:

everywhere (mkT ((+1) :: Integer -> Integer))

(I hope I got this right, I'm very rusty on the details of generics) is 
intended to add one to all Integer subterms - and only Integer subterms 
- no matter how deep they are.

When this actually alters the integer inside my Micro, I'm going to be 
pretty surprised.

Or maybe I'm not that surprised, but the point is, it exposes the 
internals of Fixed. It's an abstraction hole.


More information about the Libraries mailing list