Hi folks
I have been known to venture the viewpoint that the
"newtype trick" might benefit from improved library
support, for example, here
http://www.mail-archive.com/[email protected]/msg37213.html
This is in a similar vein to Derek's approach, if
accompanied by a little more grotesque whizzbangery.
On 19 Jan 2009, at 21:51, Derek Elkins wrote:
On Mon, 2009-01-19 at 12:10 -0800, Iavor Diatchki wrote:
Sure, the point is that you are essentially adding a type annotation,
which is like using a non-overloaded function. Compare, for example:
"mappend add x y" and "getSum (mappend (Sum x) (Sum y))". I think
that the first one is quite a bit more readable but, of course, this
is somewhat subjective.
data Iso a b = Iso { to :: a -> b, from :: b -> a }
under :: Iso a b -> (b -> b) -> (a -> a)
under iso = to iso ~> from iso
under2 :: Iso a b -> (b -> b -> b) -> (a -> a -> a)
under2 iso = to iso ~> under iso
sumIso = Iso Sum getSum
(+) = under2 sumIso mappend
Perhaps it's worth trying to push in this direction,
in search of a coherent kit.
After all, there's a lot of structure out there.
All the best
Conor
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe