On Tue, Mar 27, 2012 at 11:03 AM, Antoine Latter wrote:
> On Mon, Mar 26, 2012 at 4:25 PM, Ting Lei wrote:
>> Hi Antoine and Tobias (and everyone else),
>>
>> Thanks a lot for your answers. They are really helpful
>>
>> Can you please show me how to use the (Eq m) constraint to do this?
>>
>> Als
On Mon, Mar 26, 2012 at 4:25 PM, Ting Lei wrote:
> Hi Antoine and Tobias (and everyone else),
>
> Thanks a lot for your answers. They are really helpful
>
> Can you please show me how to use the (Eq m) constraint to do this?
>
> Also, my general question (probably novice-level) is that in monadic
aslat...@gmail.com
> Date: Mon, 26 Mar 2012 14:24:09 -0500
> Subject: Re: [Haskell-cafe] Is there a generic way to detect "mzero"?
> To: tin...@hotmail.com
> CC: haskell-cafe@haskell.org
>
> On Mon, Mar 26, 2012 at 1:33 PM, Ting Lei wrote:
> > Hi,
> &g
On Mon, Mar 26, 2012 at 21:24, Antoine Latter wrote:
> On Mon, Mar 26, 2012 at 1:33 PM, Ting Lei wrote:
>> Hi,
>>
>> I was writing a code trying to use MonadPlus to detect some error cases
>> (representing missing values etc. in pure code). With the Maybe monad, I can
>> do this:
>>
>> can0 :: (a
* Ting Lei [2012-03-26 11:33:16-0700]
> I was writing a code trying to use MonadPlus to detect some error
> cases (representing missing values etc. in pure code).
You are probably looking for the MonadError class.
There's also the MonadLogic class (which allows to literally detect
mzero), but if
Jeff,
I don't think your code works in general, since it is not guaranteed that
x' == mzero is allowed unless (m b) is an instance of Eq. I'm unsure if you
are able to test for mzero in general.
Harry
On Mon, Mar 26, 2012 at 3:11 PM, Jeff Shaw wrote:
>
> can :: (MonadPlus m) => (a -> m b) ->
On Mon, Mar 26, 2012 at 1:33 PM, Ting Lei wrote:
> Hi,
>
> I was writing a code trying to use MonadPlus to detect some error cases
> (representing missing values etc. in pure code). With the Maybe monad, I can
> do this:
>
> can0 :: (a -> Maybe b) -> a -> Bool
> can0 f x = case f x of
>
On 26 March 2012 21:11, Jeff Shaw wrote:
>
> can :: (MonadPlus m) => (a -> m b) -> a -> Bool
>> can f x = case f x of
>>mzero -> False
>>_ -> True
>>
>>
>> I got a warning:
>>
>> __testError.hs:31:11:
>>Warning: Pattern match(es) are overlapped
>> In a cas
On 26 March 2012 20:33, Ting Lei wrote:
> can :: (MonadPlus m) => (a -> m b) -> a -> Bool
> can f x = case f x of
> mzero -> False
> _ -> True
In the first pattern `mzero' is just a variable and matches
anything, as does `_'. So, naturally, both patterns overlap.
I don't
can :: (MonadPlus m) => (a -> m b) -> a -> Bool
can f x = case f x of
mzero -> False
_ -> True
I got a warning:
__testError.hs:31:11:
Warning: Pattern match(es) are overlapped
In a case alternative: _ -> ...
Ok, modules loaded: Main.
The problem here i
Hi,
I was writing a code trying to use MonadPlus to detect some error cases
(representing missing values etc. in pure code). With the Maybe monad, I can do
this:
can0 :: (a -> Maybe b) -> a -> Bool
can0 f x = case f x of
Nothing -> False
Just x -> True
And
11 matches
Mail list logo