Skip to content

genericAdaptor does not infer #42

@tomjaguarpaw

Description

@tomjaguarpaw

@hesselink I have hit a snag with genericAdaptor. It does not infer properly. For example, if I use p2 I get nice inference behaviour

> p2 (("hello " ++), reverse) ("world", [1..5])
("hello world",[5,4,3,2,1])

On the other hand, using genericAdaptor for the same purpose gives the error shown at the bottom of this comment. I managed to add a functional dependency which ends up giving us essentially a -> p. I think what we need is a -> p b c, p b c -> a. I can't see how to achieve this because Rep seems to get in the way.

Do you have any ideas how to address this? @Lysxia, you may also have some clever idea. about this.

Thanks!

genericAdaptor type error:

>  genericAdaptor (("hello " ++), reverse) ("world", [1..10])

<interactive>:11:2:
    Couldn't match expected type GHC.Generics.M1
                                    GHC.Generics.D
                                    GHC.Generics.D1(,)
                                    (GHC.Generics.M1
                                       GHC.Generics.C
                                       GHC.Generics.C1_0(,)
                                       (GHC.Generics.M1
                                          GHC.Generics.S
                                          GHC.Generics.NoSelector
                                          (GHC.Generics.K1 GHC.Generics.R [Char])
                                        GHC.Generics.:*: GHC.Generics.M1
                                                           GHC.Generics.S
                                                           GHC.Generics.NoSelector
                                                           (GHC.Generics.K1 GHC.Generics.R [a1])))
                with actual type GHC.Generics.Rep a0
    The type variables a0, a1 are ambiguous
    In the first argument of print, namely it
    In a stmt of an interactive GHCi command: print it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions