category feedKeywords and syntaxLanguage referenceeditdelete

This category is a stub, contributions are welcome!






Reference for keywords.

edit description
or press Ctrl+Enter to savemarkdown supported
#
rec
GHC extension
move item up move item down edit item info delete item
Summary edit summary

write something here!

Summary quit editing summary
#
role, nominal, representational, phantom
GHC extension
move item up move item down edit item info delete item
Summary edit summary

In recent versions of GHC there is a notion of roles (see GHC Guide).

Types that have the same representation (e.g. a type and its newtype) can be converted between each other with coerce or with -XGeneralizedNewtypeDeriving. Roles exist to constrain ways in which types can be converted. For instance, this definition will disallow converting Set a to Set b even if b is a newtype of a:

type role Set nominal

The reason it's not safe to convert a Set is that the set will have a different structure depending on the Ord instance of what's stored inside, and instances can be different for newtypes even if the representations are the same.

There are three roles:

  • nominal: types must be completely identical after type family reduction
  • representational: types must have the same representation
  • phantom: the type can be disregarded
Summary quit editing summary
#
proc
GHC extension
move item up move item down edit item info delete item
Summary edit summary

write something here!

Summary quit editing summary
#
mdo
GHC extension
move item up move item down edit item info delete item
Summary edit summary

hello

Summary quit editing summary
#
pattern
GHC extension
move item up move item down edit item info delete item
Summary edit summary

write something here!

Summary quit editing summary
#
stock, newtype, anyclass
GHC extension
move item up move item down edit item info delete item
Summary quit editing summary
#
type family
GHC extension
move item up move item down edit item info delete item
Summary edit summary

write something here!

Summary quit editing summary
#
data family
GHC extension
move item up move item down edit item info delete item
Summary edit summary

write something here!

Summary quit editing summary