[Haskell-cafe] [Alternative] change some/many semantics
Gregory Crosswhite
gcrosswhite at gmail.com
Thu Dec 15 08:23:41 CET 2011
On Dec 15, 2011, at 3:36 PM, Antoine Latter wrote:
> That's the interesting thing about type-classes like Alternative and
> Functor - they mean very little, and are used in widely varying
> contexts.
So... your point is that in the Haskell community we don't tend to care about whether our types, typeclasses, typeclass instances, etc. make any sense at all?
> Heck, Control.Monad.void has the type signature "Functor f a
> => f a -> f ()" - how many functors is that operator sensible for?
All of them. I can't conceive of a single case where this would result in an undefined operation; can you?
Furthermore when people write code using monadic combinators they toss out results all the time so this kind of function makes perfect sense.
> There are a lot of combinators you can build from (<|>) and empty that
> go terribly wrong for Maybe and List but are still quite useful.
Yes, you *could* do that, but the whole point is that you shouldn't. Typeclasses generally come with informal laws that must be obeyed. If your instance does not obey those laws, then it should not be an instance.
Incidentally, exactly what use cases do you have in mind?
> Even
> the operators at hand ('many' and 'some') are partial in parsing, but
> I'm not prepared to throw them out.
Okay, I must confess that this straw man has been causing my patience to get a little thing. *Nobody* here is saying that many and some should be thrown out, since there are clearly many contexts where they are very useful. The *most* that has been suggested is that they should be moved into a subclass in order to make it explicit when they are sensible, and that is *hardly* banning them.
Cheers,
Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111215/a4131564/attachment.htm>
More information about the Haskell-Cafe
mailing list