[Haskell-cafe] help with multiparam type class

gbwey9 gbwey9 at gmail.com
Thu Jul 17 01:40:09 UTC 2014


Given any Event constructor, the 'conv' method passes in the field name to
'val' for each field. There is a Z instance for each Event arity. The call
"conv E1::E1" works but requires that I explicitly specify the type. Is
there any way to avoid that having to do that?

For some reason 'conv' does not have enough information to know the type.
Is there a way to do this with functional dependencies or type classes or
something else?

Here is the paste http://lpaste.net/107632 and here is the error:

*Main> conv E1

    No instance for (Z e0 (String -> E1)) arising from a use of `conv'
    The type variable `e0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there are several potential instances:
      instance (Event e, Field a) => Z e (a -> e)
        -- Defined at testfamily.hs:28:10
      instance Event e => Z e e -- Defined at testfamily.hs:20:10
    Possible fix: add an instance declaration for (Z e0 (String -> E1))
    In the expression: conv E1
    In an equation for `it': it = conv E1

Thanks for any help,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140716/b5506d21/attachment.html>

More information about the Haskell-Cafe mailing list