Martin Huschenbett wrote:
>
> readValue :: Field -> (forall s. SqlBind s => s) -> Value
> readValue _ = ...
> 
> 
> That works just fine. But now I want a version of readValue that has a
> Maybe wrapped around the second parameter and that shall call readValue
> in the case of a Just and emptyValue in the case of Nothing. But I can't
> figure out how to write this function as I always get compiler errors.
>
> 
> -- The type I want to get.
> readValue' :: Field -> (forall s. SqlBind s => Maybe s) -> Value
> [..]
> -- Fourth trial:
> readValue fld s = case s of
>   Just s' -> readValue fld s'
>   Nothing -> emptyValue fld

For me, the fourth trial works, at least on

    f :: (forall s . Num s => Maybe s) -> Int
    f y = case y of
        Just x  -> x
        Nothing -> 0

Your definition has a typo (missing tick '), maybe that's the cause why
it doesn't work?

Furthermore, I guess that let-binding any troublesome rank-2-variables
is beneficial.

Regards,
apfelmus

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to