Hello again,
> I think that I have done all of the above in different situations, and
> so I don't think that there is a single correct answer. I usually
> avoid using the "newtype" trick as I find it inconvenient: usually
> the newtype does not have the same operations as the underlying type
>
Patai Gergely wrote:
Hi everyone,
I have a general program design question, but I can't really think of
good examples so it will be a bit vague. There was a discussion on Show
not long ago which brought up the problem that there are several ways to
"show" a data structure, and it depends on the
Luke Palmer wrote:
On Mon, Jan 19, 2009 at 3:58 AM, Patai Gergely wrote:
However, there are other type classes that are too general to assign
such concrete uses to. For instance, if a data structure can have more
than one meaningful (and useful) Functor or Monoid instance,
As a side curiosit
Hello,
I don't mean to be negative here but I really fail to see how do any
of these ideas help the situation. (I do think it would be cool to
have a generic way to lift functions from one type to another that is
isomorphic to it). The fundamental problem is that there are multiple
functions of t
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/haskell-cafe@haskell.org/msg37213.html
This is in a similar vein to Derek's approach, if
accompanied by a little more grotesq
On Mon, 2009-01-19 at 12:10 -0800, Iavor Diatchki wrote:
> Hi,
>
> On Mon, Jan 19, 2009 at 11:06 AM, Jonathan Cast
> wrote:
> > On Mon, 2009-01-19 at 10:59 -0800, Iavor Diatchki wrote:
> >> Hello,
> >> The multitude of newtypes in the Monoid module are a good indication
> >> that the Monoid class
I'd prefer something like
Sum :: Monoid Integer
Sum = Monoid {mappend = (+), mempty = 0}
Prod :: Monoid Integer
Prod = Monoid {mappend = (*), mempty = 1}
instance Sum in [some code using mempty and mappend]
On 19 Jan 2009, at 23:18, Alberto G. Corona wrote:
This is one of the shortcomings of
On Mon, 2009-01-19 at 21:18 +0100, Alberto G. Corona wrote:
> This is one of the shortcomings of haskell not to mention other
> programming languages. Mathemathicist would find it very annoying.
>
>
> Instead of
>
>
> instance Monoid Integer where
> mappend = (+)
> mempty = 0
>
> inst
On Mon, 2009-01-19 at 12:10 -0800, Iavor Diatchki wrote:
> >> I usually
> >> avoid using the "newtype" trick as I find it inconvenient: usually
> >> the newtype does not have the same operations as the underlying type
> >> and so it cannot be used directly, and if you are going to wrap thing
> >>
This is one of the shortcomings of haskell not to mention other programming
languages. Mathemathicist would find it very annoying.
Instead of
instance Monoid Integer where
mappend = (+)
mempty = 0
instance Monoid Integer where
mappend = (*)
mempty = 1
which is not legal and the
Hi,
On Mon, Jan 19, 2009 at 11:06 AM, Jonathan Cast
wrote:
> On Mon, 2009-01-19 at 10:59 -0800, Iavor Diatchki wrote:
>> Hello,
>> The multitude of newtypes in the Monoid module are a good indication
>> that the Monoid class is not a good fit for the class system
>
> I would say rather that the c
On Mon, 2009-01-19 at 10:59 -0800, Iavor Diatchki wrote:
> Hello,
> The multitude of newtypes in the Monoid module are a good indication
> that the Monoid class is not a good fit for the class system
I would say rather that the class system is not a good fit for Monoid.
Proposals for local instanc
Hello,
The multitude of newtypes in the Monoid module are a good indication
that the Monoid class is not a good fit for the class system (it is
ironic that discussing it resulted in such a huge thread recently :-).
How I'd approach the situation that you describe would depend on
the context (did
> As a side curiosity, I would love to see an example of any data structure
> which has more than one Functor instance. Especially those which have
> more than one useful functor instance.
data Record a b = R { field1 :: a, field2 :: b }
If I want to use fmap to transform either field, I have to
The desugaring of (, a) would involve some type level lambda, and
that's not something that is available (yet).
-- Lennart
On Mon, Jan 19, 2009 at 1:49 PM, Holger Siegel wrote:
> Am Montag, den 19.01.2009, 14:47 +0100 schrieb Daniel Fischer:
>> Am Montag, 19. Januar 2009 14:31 schrieb Antoine
Am Montag, den 19.01.2009, 14:47 +0100 schrieb Daniel Fischer:
> Am Montag, 19. Januar 2009 14:31 schrieb Antoine Latter:
> > 2009/1/19 Luke Palmer :
> > > As a side curiosity, I would love to see an example of any data structure
> > > which has more than one Functor instance. Especially those whi
Am Montag, 19. Januar 2009 14:31 schrieb Antoine Latter:
> 2009/1/19 Luke Palmer :
> > As a side curiosity, I would love to see an example of any data structure
> > which has more than one Functor instance. Especially those which have
> > more than one useful functor instance.
>
> (,) ?
>
> -Anto
2009/1/19 Luke Palmer :
> On Mon, Jan 19, 2009 at 3:58 AM, Patai Gergely
> wrote:
>>
>> However, there are other type classes that are too general to assign
>> such concrete uses to. For instance, if a data structure can have more
>> than one meaningful (and useful) Functor or Monoid instance,
>
>
2009/1/19 Luke Palmer :
> As a side curiosity, I would love to see an example of any data structure
> which has more than one Functor instance. Especially those which have more
> than one useful functor instance.
(,) ?
-Antoine
___
Haskell-Cafe mailin
On Mon, Jan 19, 2009 at 3:58 AM, Patai Gergely wrote:
> However, there are other type classes that are too general to assign
> such concrete uses to. For instance, if a data structure can have more
> than one meaningful (and useful) Functor or Monoid instance,
As a side curiosity, I would love t
As for multiple Monoid or Functor instances, simply define a newtype,
as it is done in Data.Monoid.
What part of your question does that answer and what part doesn't it?
2009/1/19 Patai Gergely :
> Hi everyone,
>
> I have a general program design question, but I can't really think of
> good exampl
Hi everyone,
I have a general program design question, but I can't really think of
good examples so it will be a bit vague. There was a discussion on Show
not long ago which brought up the problem that there are several ways to
"show" a data structure, and it depends on the context (or should I ca
22 matches
Mail list logo