purescript-0.15.12: PureScript Programming Language Compiler

Safe Haskell | Safe-Inferred
Language | Haskell2010

Language.PureScript.TypeChecker.Roles

Description

Role inference

Synopsis

- lookupRoles :: Environment -> Qualified (ProperName 'TypeName) -> [Role]
- checkRoles :: forall m. MonadError MultipleErrors m => [(Text, Maybe SourceType, Role)] -> [Role] -> m ()
- checkRoleDeclarationArity :: forall m. MonadError MultipleErrors m => ProperName 'TypeName -> [Role] -> Int -> m ()
- inferRoles :: Environment -> ModuleName -> ProperName 'TypeName -> [(Text, Maybe SourceType)] -> [DataConstructorDeclaration] -> [Role]
- inferDataBindingGroupRoles :: Environment -> ModuleName -> [RoleDeclarationData] -> [DataDeclaration] -> ProperName 'TypeName -> [(Text, Maybe SourceType)] -> [Role]

# Documentation

lookupRoles :: Environment -> Qualified (ProperName 'TypeName) -> [Role] #

Lookup the roles for a type in the environment. If the type does not have roles (e.g. is a type synonym or a type variable), then this function returns an empty list.

checkRoles #

Arguments

:: forall m. MonadError MultipleErrors m |
=> [(Text, Maybe SourceType, Role)] | type parameters for the data type whose roles we are checking
-> [Role] | roles declared for the data type
-> m () |

Compares the inferred roles to the explicitly declared roles and ensures that the explicitly declared roles are not more permissive than the inferred ones.

checkRoleDeclarationArity :: forall m. MonadError MultipleErrors m => ProperName 'TypeName -> [Role] -> Int -> m () #

inferRoles #

Arguments

:: Environment |
-> ModuleName |
-> ProperName 'TypeName | The name of the data type whose roles we are checking
-> [(Text, Maybe SourceType)] | type parameters for the data type whose roles we are checking
-> [DataConstructorDeclaration] | constructors of the data type whose roles we are checking
-> [Role] |

Infers roles for the given data type declaration.

inferDataBindingGroupRoles :: Environment -> ModuleName -> [RoleDeclarationData] -> [DataDeclaration] -> ProperName 'TypeName -> [(Text, Maybe SourceType)] -> [Role] #