Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Members with Type Variable Cause Compile Error in makeAction #4

Open
jeremyjh opened this issue May 13, 2018 · 0 comments
Open

Comments

@jeremyjh
Copy link

It seems only fixed types are supported by makeAction. If I change the type of readFile in the test case slightly, to say:

class MonadError e m => MonadFileSystem e m | m -> e where
  readFile :: Show a => a -> m String
  writeFile :: FilePath -> String -> m ()

Then the code produced by makeAction will not compile:

    • Could not deduce: a1 ~ a
      from the context: (r ~ [Char], Show a)
        bound by a pattern with constructor:
                   ReadFile :: forall a_XrHB.
                               Show a_XrHB =>
                               a_XrHB -> FileSystemAction String,
                 in an equation for ‘==’
        at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1-60
      ‘a1’ is a rigid type variable bound by
        a pattern with constructor:
          ReadFile :: forall a_XrHB.
                      Show a_XrHB =>
                      a_XrHB -> FileSystemAction String,
        in an equation for ‘==’
        at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1
      ‘a’ is a rigid type variable bound by
        a pattern with constructor:
          ReadFile :: forall a_XrHB.
                      Show a_XrHB =>
                      a_XrHB -> FileSystemAction String,
        in an equation for ‘==’
        at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1
    • In the second argument of ‘(==)’, namely ‘b1’
      In the expression: ((a1 == b1))
      In an equation for ‘==’:
          (==) (ReadFile a1) (ReadFile b1) = ((a1 == b1))
      When typechecking the code for ‘==’
        in a derived instance for ‘Eq (FileSystemAction r)’:
        To see the code I am typechecking, use -ddump-deriv
    • Relevant bindings include
        b1 :: a1
          (bound at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1)
        a1 :: a
          (bound at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1)

/Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1: warning: [-Wdeferred-type-errors]
    • Could not deduce: a2 ~ a1
      from the context: (a ~ [Char], Show a1)
        bound by a pattern with constructor:
                   ReadFile :: forall a_XrHB.
                               Show a_XrHB =>
                               a_XrHB -> FileSystemAction String,
                 in an equation for ‘eqAction’
        at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1-60
      or from: (b ~ [Char], Show a2)
        bound by a pattern with constructor:
                   ReadFile :: forall a_XrHB.
                               Show a_XrHB =>
                               a_XrHB -> FileSystemAction String,
                 in an equation for ‘eqAction’
        at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1-60
      ‘a2’ is a rigid type variable bound by
        a pattern with constructor:
          ReadFile :: forall a_XrHB.
                      Show a_XrHB =>
                      a_XrHB -> FileSystemAction String,
        in an equation for ‘eqAction’
        at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1
      ‘a1’ is a rigid type variable bound by
        a pattern with constructor:
          ReadFile :: forall a_XrHB.
                      Show a_XrHB =>
                      a_XrHB -> FileSystemAction String,
        in an equation for ‘eqAction’
        at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1
    • In the second argument of ‘(==)’, namely ‘y_arVc’
      In the first argument of ‘(&&)’, namely ‘(==) x_arVb y_arVc’
      In the expression: (&&) ((==) x_arVb y_arVc) True
    • Relevant bindings include
        y_arVc :: a2
          (bound at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1)
        x_arVb :: a1
          (bound at /Users/jeremy/repos/haskell/monad-mock/test-suite/Control/Monad/MockSpec.hs:20:1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant