Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Roman Cheplyaka
* Tony Morris tonymor...@gmail.com [2011-01-08 12:56:28+1000] I am wondering if it possible to generalise catMaybes: (Something f, SomethingElse t) = t (f a) - t a I have being doing some gymnastics with Traversable and Foldable and a couple of other things from category-extras to no

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Henning Thielemann
On Sat, 8 Jan 2011, Roman Cheplyaka wrote: I think catMaybes deserves its own typeclass, which would represent truncatable structures: class Truncatable struct where catMaybes :: struct (Maybe a) - Maybe a But catMaybes has the type catMaybes :: struct (Maybe a) - struct a for

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Roman Cheplyaka
* Henning Thielemann lemm...@henning-thielemann.de [2011-01-08 12:06:33+0100] On Sat, 8 Jan 2011, Roman Cheplyaka wrote: I think catMaybes deserves its own typeclass, which would represent truncatable structures: class Truncatable struct where catMaybes :: struct (Maybe a) -

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Henning Thielemann
On Fri, 7 Jan 2011, Brandon S Allbery KF8NH wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 1/7/11 21:56 , Tony Morris wrote: I am wondering if it possible to generalise catMaybes: (Something f, SomethingElse t) = t (f a) - t a I have being doing some gymnastics with Traversable

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Conor McBride
On 8 Jan 2011, at 11:14, Henning Thielemann wrote: For me, the solutions of Dave Menendez make most sense: Generalize Maybe to Foldable and List to MonadPlus. What has it to do with monads? There's no bind in sight. Alternative is certainly a more general alternative, but then I would

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Henning Thielemann
On Sat, 8 Jan 2011, Conor McBride wrote: On 8 Jan 2011, at 11:14, Henning Thielemann wrote: For me, the solutions of Dave Menendez make most sense: Generalize Maybe to Foldable and List to MonadPlus. What has it to do with monads? There's no bind in sight. I see a '=' in front of each of

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 1/8/11 07:11 , Conor McBride wrote: On 8 Jan 2011, at 11:14, Henning Thielemann wrote: For me, the solutions of Dave Menendez make most sense: Generalize Maybe to Foldable and List to MonadPlus. What has it to do with monads? There's no bind

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Conor McBride
On 8 Jan 2011, at 15:27, Henning Thielemann wrote: On Sat, 8 Jan 2011, Conor McBride wrote: On 8 Jan 2011, at 11:14, Henning Thielemann wrote: For me, the solutions of Dave Menendez make most sense: Generalize Maybe to Foldable and List to MonadPlus. What has it to do with monads?

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Henning Thielemann
On Sat, 8 Jan 2011, Conor McBride wrote: Of course, there is an alternative generalisation. [] and Maybe are both Foldable, hence so is their composition. There's got to be a thing of type collapse :: (Foldable f, Alternative a) = f x - a x which would do the job. Nice! It would be

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread David Menendez
On Sat, Jan 8, 2011 at 12:05 PM, Conor McBride co...@strictlypositive.org wrote: On 8 Jan 2011, at 15:27, Henning Thielemann wrote: On Sat, 8 Jan 2011, Conor McBride wrote: On 8 Jan 2011, at 11:14, Henning Thielemann wrote: For me, the solutions of Dave Menendez make most sense:

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thanks guys for all the solutions. A slight correction below. On 09/01/11 03:54, David Menendez wrote: Naturally, if you also have pure and fmap, you also have a monad. You have a pointed functor but not necessarily a monad. There are many pointed

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread David Menendez
On Sat, Jan 8, 2011 at 5:07 PM, Tony Morris tonymor...@gmail.com wrote: Thanks guys for all the solutions. A slight correction below. On 09/01/11 03:54, David Menendez wrote: Naturally, if you also have pure and fmap, you also have a monad. You have a pointed functor but not necessarily a

[Haskell-cafe] Generalizing catMaybes

2011-01-07 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I am wondering if it possible to generalise catMaybes: (Something f, SomethingElse t) = t (f a) - t a I have being doing some gymnastics with Traversable and Foldable and a couple of other things from category-extras to no avail. Perhaps someone

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-07 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 1/7/11 21:56 , Tony Morris wrote: I am wondering if it possible to generalise catMaybes: (Something f, SomethingElse t) = t (f a) - t a I have being doing some gymnastics with Traversable and Foldable and a couple of other things from

Re: [Haskell-cafe] Generalizing catMaybes

2011-01-07 Thread David Menendez
On Fri, Jan 7, 2011 at 9:56 PM, Tony Morris tonymor...@gmail.com wrote:  I am wondering if it possible to generalise catMaybes: (Something f, SomethingElse t) = t (f a) - t a I have being doing some gymnastics with Traversable and Foldable and a couple of other things from category-extras