Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2011-01-06 Thread Henning Thielemann
Edward Amsden schrieb: Aditya: Not quite, because I'm actually looking to extract values from a functor (Maybe) with a default. Stephen: Thanks, I'll take a look at those. I do have a need for it. I'm writing a very similar library to Yampa. (I would be patching Yampa, but the code is a

[Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Edward Amsden
Hello all: I'd like to right a function that could take a structure with type (random example): (Int, (String, (Int, Int))) and another where each individual value is a Maybe of the corresponding type, for example: (Maybe Int, (Maybe String, (Maybe Int, Maybe Int))) and perform a fromMaybe

Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Jake McArthur
Maybe something like this would work for you (requires the TypeFamilies extension). class FromMaybe a where type Maybe' a fromMaybe :: a - Maybe' a - a instance FromMaybe Int where type Maybe' Int = Maybe Int fromMaybe = Data.Maybe.fromMaybe instance

Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Stephen Tetley
On 28 December 2010 19:23, Edward Amsden eca7...@cs.rit.edu wrote: Hello all: I'd like to right a function that could take a structure with type (random example): (Int, (String, (Int, Int))) and another where each individual value is a Maybe of the corresponding type, for example: (Maybe

Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread aditya siram
Although I don't understand it myself Oleg's deepest functor [1] seems to be what you're looking for. -deech [1] http://okmij.org/ftp/Haskell/deepest-functor.lhs On Tue, Dec 28, 2010 at 1:23 PM, Edward Amsden eca7...@cs.rit.edu wrote: Hello all: I'd like to right a function that could take a

Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Max Rabkin
On Tue, Dec 28, 2010 at 21:23, Edward Amsden eca7...@cs.rit.edu wrote: (Int, (String, (Int, Int))) and another where each individual value is a Maybe of the corresponding type, for example: (Maybe Int, (Maybe String, (Maybe Int, Maybe Int))) This example demonstrates exactly why you might

Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Edward Amsden
Aditya: Not quite, because I'm actually looking to extract values from a functor (Maybe) with a default. Stephen: Thanks, I'll take a look at those. I do have a need for it. I'm writing a very similar library to Yampa. (I would be patching Yampa, but the code is a mess, so I decided to try

Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Sterling Clover
Basically, I have a signal processing loop, where values are passed updated with a Maybe, representing whether there is or is not a change to the value. I could use a single Maybe around the whole thing, but that would require then re-updating a potentially large structure entirely. I want to

Re: [Haskell-cafe] Polymorphic function over pairs of maybes.

2010-12-28 Thread Stephen Tetley
On 28 December 2010 21:44, Edward Amsden eca7...@cs.rit.edu wrote: [SNIP] I'm writing a very similar library to Yampa. (I would be patching Yampa, but the code is a mess, so I decided to try starting from scratch.) Basically, I have a signal processing loop, where values are passed updated