We can define type synonyms with arguments and this works fine when used with actual types:
type MyType t = t String String
data Test a b = Test a b
f :: MyType Test
f = undefined
main = undefined
Compiling this results in no errors:
$ghc --make test.hs
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
However this doesn't work when Test
is a type synonym:
type MyType t = t String String
data Test a b = Test a b
type Test' a b = Test a b
f :: MyType Test'
f = undefined
main = undefined
Which gives the following error:
$ghc --make test.hs
[1 of 1] Compiling Main ( test.hs, test.o )
test.hs:7:6:
Type synonym Test' should have 2 arguments, but has been given none
In the type signature for `f': f :: MyType (Test')
What puzzles me is that Test'
is being applied to two arguments, so why is GHC complaining that I didn't pass the arguments?
Shouldn't type synonym be completely transparent and impossible to distinguish from other kind of types?
Is there any way to achieve the expected behaviour?