We can define type synonyms with arguments, and this works great 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 the results does not cause errors:
$ghc --make test.hs
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
However, this does not work if it Testis 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' applies to two arguments, so why does the GHC complain that I didn't pass arguments?
Shouldn't a synonym be entered completely transparent and impossible to distinguish from other types?
Is there a way to achieve the expected behavior?
source
share