[Haskell-cafe] ismzero operator possible without equal constraint

2011-12-03 Thread edgar klerks
Hi list, I am using MonadSplit (from http://www.haskell.org/haskellwiki/New_monads/MonadSplit ) for a project and now I want to make a library out of it. This seems to be straightforward, but I got stuck when I tried to move miszero out of the class: miszero :: m a - Bool It tests if the

Re: [Haskell-cafe] ismzero operator possible without equal constraint

2011-12-03 Thread Arseniy Alekseyev
Of course it is not possible! Take a simple composition of reader and Maybe functors for an example: miszero :: (b - Maybe a) - Bool I'm pretty sure (b - Maybe a) for a is a MonadPlus, but you can't implement miszero for it. Arseniy. On 3 December 2011 16:55, edgar klerks

Re: [Haskell-cafe] ismzero operator possible without equal constraint

2011-12-03 Thread edgar klerks
Hi Arseniy, Yes, I see it now. :) . I had some feeling there should be some structural equality: Just _ == Just _ = True Nothing == Nothing = True _ == _ = False But this doesn't work for functions. Thanks for your answer! Greets, Edgar On Sat, Dec 3, 2011 at 6:23 PM, Arseniy Alekseyev

Re: [Haskell-cafe] ismzero operator possible without equal constraint

2011-12-03 Thread Antoine Latter
On Sat, Dec 3, 2011 at 10:55 AM, edgar klerks edgar.kle...@gmail.com wrote: Hi list, I am using MonadSplit (from http://www.haskell.org/haskellwiki/New_monads/MonadSplit )  for a project and now I want to make a library out of it. This seems to be straightforward, but I got stuck when I

Re: [Haskell-cafe] ismzero operator possible without equal constraint

2011-12-03 Thread David Menendez
On Sat, Dec 3, 2011 at 3:55 PM, Antoine Latter aslat...@gmail.com wrote: On Sat, Dec 3, 2011 at 10:55 AM, edgar klerks edgar.kle...@gmail.com wrote: Hi list, I am using MonadSplit (from http://www.haskell.org/haskellwiki/New_monads/MonadSplit )  for a project and now I want to make a library

Re: [Haskell-cafe] ismzero operator possible without equal constraint

2011-12-03 Thread edgar klerks
No not for lists, but it is not a bad direction. If I modify it a bit, I can get an ifmzero function: ifmzero :: (MonadSplit m) = m a - m b - m b - m b ifmzero p b f = join $ mhead $ (liftM (const f) p) `mplus` (return b) mhead :: (MonadSplit m) = m a - m a mhead = liftM fst . msplit Which I