Skip to content

Types of f_1 and f_2 cannot be inferred #3

Description

@Lysxia

Trying to type

:t (,)
  $>> f_1 >-< pure ()
  >>> f_2 >-< pure 'a' :: (Applicative fr, Applicative fw) => Codec fr fw ((), Char)

results in some "could not deduce" errors

Could not deduce (Buildable ((), Char) y0)
Could not deduce (Field1 ((), Char) () (a0 -> b0 -> (a0, b0)) b1)
Could not deduce (Field2 ((), Char) Char b1 y0)

While an instance Field1 (a, b) a (a -> c -> (a, b)) (X -> c -> (a, b)) exists, it cannot be selected here because the compiler cannot first deduce that ((), Char) should be equal to (a0, b0) (fundeps would then take care of the rest).

Annotating (,) :: () -> Char -> ((), Char) makes the above typecheck, though this causes f_1 and f_2 to be rather annoying to use.

Making them regular functions would be a better fix IMO. Is there a reason why they are defined in typeclasses that I am missing?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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