Skip to content
Snippets Groups Projects
Commit 76a4d11b authored by Jaro Reinders's avatar Jaro Reinders Committed by Marge Bot
Browse files

Remove Ptr example from roles docs

parent 7be4a272
No related branches found
No related tags found
No related merge requests found
......@@ -155,26 +155,7 @@ Role annotations
Allow role annotation syntax.
Sometimes the programmer wants to constrain the inference process. For
example, the base library contains the following definition: ::
data Ptr a = Ptr Addr#
The idea is that ``a`` should really be a representational parameter,
but role inference assigns it to phantom. This makes some level of
sense: a pointer to an ``Int`` really is representationally the same as
a pointer to a ``Bool``. But, that's not at all how we want to use
``Ptr``\ s! So, we want to be able to say ::
type role Ptr representational
data Ptr a = Ptr Addr#
The ``type role`` (enabled with :extension:`RoleAnnotations`) declaration
forces the parameter ``a`` to be at role representational, not role
phantom. GHC then checks the user-supplied roles to make sure they don't
break any promises. It would be bad, for example, if the user could make
``BadIdea``\'s role be representational.
As another example, we can consider a type ``Set a`` that represents a
example, we can consider a type ``Set a`` that represents a
set of data, ordered according to ``a``\'s ``Ord`` instance. While it
would generally be type-safe to consider ``a`` to be at role
representational, it is possible that a ``newtype`` and its base type
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment