Re: [Haskell-cafe] Turning all the Nothings into Just defaultValue using Data.Generics

2008-11-13 Thread Alexey Rodriguez
Hi David! 2008/11/12 David Fox [EMAIL PROTECTED]: I want to use Data.Generics to write a function to turn all the Nothings in a data structure into Just defaultValue, as shown below. I get the following error because the compiler doesn't know enough about Maybe a for mkT to create the

[Haskell-cafe] Turning all the Nothings into Just defaultValue using Data.Generics

2008-11-12 Thread David Fox
I want to use Data.Generics to write a function to turn all the Nothings in a data structure into Just defaultValue, as shown below. I get the following error because the compiler doesn't know enough about Maybe a for mkT to create the generic function that everywhere requires, I guess.

Re: [Haskell-cafe] Turning all the Nothings into Just defaultValue using Data.Generics

2008-11-12 Thread Jeremy Shaw
Hello, I can *almost* do it like this: test = (id `ext1T` justDefault) (defaultValue :: A) justDefault :: forall f. (Default f, Data f) = Maybe f - Maybe f justDefault Nothing = defaultValue justDefault (Just x) = Just x Except it fails with: Could not deduce (Default d1) from the