I am learning so may be this is a trivial question.
In the code generated by yesod scaffolding开发者_运维知识库 tool I found this expression:
type YesodPersistBackend PersistTest = SqlPersist
My understanding is that it creates a parameterised type YesodPersistBackend
that has one type argument PersistTest
, and this is equivalent to the type SqlPersist
.
Is this correct? If so, why would one create a type synonym with parameters for a type that does not have parameters?
This is not a vanilla type declaration. If you see the full code, it looks something like this -
instance YesodPersist PersistTest where
type YesodPersistBackend PersistTest = SqlPersist
This is using an extension to Haskell98 called TypeFamilies. Read about this specific syntax here - http://www.haskell.org/ghc/docs/latest/html/users_guide/type-families.html#assoc-type-instance
精彩评论