[Haskell-cafe] Monoid wants a (++) equivalent
Richard O'Keefe
ok at cs.otago.ac.nz
Thu Jul 2 18:32:02 EDT 2009
It is claimed that making ++ become another name for the
Monoid mappend operation "will break some Haskell 98 code"
such as
append = (++)
That example can easily be fixed by adding a type signature, no?
append :: [a] -> [a] -> [a]
append = (++)
In ghci, at any rate, using mappend instead of (++),
the first is rejected, but the sceond works perfectly.
The nice thing about this is that the code _with_ the type
signature is perfectly legal Haskell 98, so the fix leaves
you with something that works with either reading of (++).
Do we have any other uses of ++ that would be hard to fix
by adding a type signature?
More information about the Haskell-Cafe
mailing list