Hi,
On Sun, Sep 14, 2008 at 7:01 AM, Stephan Friedrichs
<[EMAIL PROTECTED]> wrote:
> I agree that the MonadZero class with a useful 'zero' :: m a would be
> the right abstraction for views. But MonadZero is not part of base, mtl
> or any other common package, or am I missing something? Changing th
On 2008 Sep 14, at 10:01, Stephan Friedrichs wrote:
Johannes Waldmann wrote:
I think the crux of
the matter was that a monad is too general. Either there is a
result or
there is not. That's precisely the intended use of a Maybe.
Indeed "Monad m =>" is dangerous here
because not every Monad
Johannes Waldmann wrote:
>> I think the crux of
>> the matter was that a monad is too general. Either there is a result or
>> there is not. That's precisely the intended use of a Maybe.
>
> Indeed "Monad m =>" is dangerous here
> because not every Monad has a reasonable definition of "fail".
>
>
I think the crux of
the matter was that a monad is too general. Either there is a result or
there is not. That's precisely the intended use of a Maybe.
Indeed "Monad m =>" is dangerous here
because not every Monad has a reasonable definition of "fail".
But that seems to be a problem in the (c
Johannes Waldmann wrote:
>> a) ... to use Maybe
>> b) ... to provide my own Data.Heap.View type
>
> leave the choice up to the programmer,
> and provide a generic interface,
> accepting any MonadZero (*) instance.
>
> cf. Data.Set.maxView
AFAIK there has been a vivid discussion about that. I thi
On Sat, Sep 13, 2008 at 11:19 AM, Stephan Friedrichs
<[EMAIL PROTECTED]> wrote:
> data View
> = Empty
> | Cons a (SomeDataStructure a)
>
> A good example for this is Data.Sequence. My question is: Why is this
> not expressed in terms of Maybe?
>
> view :: SomeDataStructure a -> Maybe (a, SomeData
> a) ... to use Maybe
> b) ... to provide my own Data.Heap.View type
leave the choice up to the programmer,
and provide a generic interface,
accepting any MonadZero (*) instance.
cf. Data.Set.maxView
http://www.haskell.org/hoogle/?hoogle=maxView
(*) ah - I forgot, MonadZero didn't quite make i
Hello!
List-like data structures should IMHO provide safe versions of 'head'
and 'tail' (with safe I mean 'not partial', i. e. functions that don't
provoke an 'error' when called with an empty collection). As far as I
know, this is usually called 'view' and and has a type signature like
view :: S