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)
It seems only fixed types are supported by
makeAction
. If I change the type ofreadFile
in the test case slightly, to say:Then the code produced by
makeAction
will not compile: