Chris Kuklewicz wrote:
> Nicolas Frisby wrote:
> >> Not portably.
> >>
> >> [EMAIL PROTECTED]:~$ ghc-6.4.2 -e '( ("foo"++) `Data.Monoid.mappend`
> >> ("bar"++) ) "END"'
> >> "foobarEND"
> >> [EMAIL PROTECTED]:~$ ghc-6.6 -e '( ("foo"++) `Data.Monoid.mappend`
> >> ("bar"++) ) "END"'
> >> "fooENDbar
Nicolas Frisby wrote:
>> Not portably.
>>
>> [EMAIL PROTECTED]:~$ ghc-6.4.2 -e '( ("foo"++) `Data.Monoid.mappend`
>> ("bar"++) ) "END"'
>> "foobarEND"
>> [EMAIL PROTECTED]:~$ ghc-6.6 -e '( ("foo"++) `Data.Monoid.mappend`
>> ("bar"++) ) "END"'
>> "fooENDbarEND"
>>
>>
>> -- 6.6 sources
>> instance
Using the Endo newtype can avoid such ambiguities:
http://darcs.haskell.org/packages/base/Data/Monoid.hs
newtype Endo a = Endo { appEndo :: a -> a }
instance Monoid (Endo a) where
mempty = Endo id
Endo f `mappend` Endo g = Endo (f . g)
Endo allows you to explicitly select the m
On Tue, Apr 10, 2007 at 02:33:41PM +0100, Chris Kuklewicz wrote:
> Well, since ((.) :: ShowS -> ShowS -> ShowS) is a Monoid, you can use Writer
> to
> create the result:
Not portably.
[EMAIL PROTECTED]:~$ ghc-6.4.2 -e '( ("foo"++) `Data.Monoid.mappend` ("bar"++)
) "END"'
"foobarEND"
[EMAIL PRO
Maxime Henrion wrote:
> Hello all,
>
>
> I have found myself writing instances of Show for some types of
> mine, and I did so by defining the showsPrec function, for performance
> reasons. I ended up with code that I find quite inelegant. Here's
> an example:
>
> data Move = Move {
>
Hello all,
I have found myself writing instances of Show for some types of
mine, and I did so by defining the showsPrec function, for performance
reasons. I ended up with code that I find quite inelegant. Here's
an example:
data Move = Move {
movePiece :: PieceType