Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Environment = Environment {
- names :: Map (Qualified Ident) (SourceType, NameKind, NameVisibility)
- types :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- dataConstructors :: Map (Qualified (ProperName 'ConstructorName)) (DataDeclType, ProperName 'TypeName, SourceType, [Ident])
- typeSynonyms :: Map (Qualified (ProperName 'TypeName)) ([(Text, Maybe SourceType)], SourceType)
- typeClassDictionaries :: Map QualifiedBy (Map (Qualified (ProperName 'ClassName)) (Map (Qualified Ident) (NonEmpty NamedDict)))
- typeClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData
- data TypeClassData = TypeClassData {}
- data FunctionalDependency = FunctionalDependency {
- fdDeterminers :: [Int]
- fdDetermined :: [Int]
- initEnvironment :: Environment
- makeTypeClassData :: [(Text, Maybe SourceType)] -> [(Ident, SourceType)] -> [SourceConstraint] -> [FunctionalDependency] -> Bool -> TypeClassData
- type Frontier = Map IntSet (First (IntMap (NonEmpty IntSet)))
- computeCoveringSets :: Int -> [FunctionalDependency] -> (Set Int, Set (Set Int))
- data NameVisibility
- data NameKind
- data TypeKind
- = DataType DataDeclType [(Text, Maybe SourceType, Role)] [(ProperName 'ConstructorName, [SourceType])]
- | TypeSynonym
- | ExternData [Role]
- | LocalTypeVariable
- | ScopedTypeVar
- data DataDeclType
- showDataDeclType :: DataDeclType -> Text
- kindType :: SourceType
- kindConstraint :: SourceType
- kindSymbol :: SourceType
- kindDoc :: SourceType
- kindOrdering :: SourceType
- kindRowList :: SourceType -> SourceType
- kindRow :: SourceType -> SourceType
- kindOfREmpty :: SourceType
- tyFunction :: SourceType
- tyString :: SourceType
- tyChar :: SourceType
- tyNumber :: SourceType
- tyInt :: SourceType
- tyBoolean :: SourceType
- tyArray :: SourceType
- tyRecord :: SourceType
- tyVar :: Text -> SourceType
- tyForall :: Text -> SourceType -> SourceType -> SourceType
- function :: SourceType -> SourceType -> SourceType
- (-:>) :: SourceType -> SourceType -> SourceType
- primClass :: Qualified (ProperName 'ClassName) -> (SourceType -> SourceType) -> [(Qualified (ProperName 'TypeName), (SourceType, TypeKind))]
- primTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- allPrimTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- primBooleanTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- primCoerceTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- primOrderingTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- primRowTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- primRowListTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- primSymbolTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- primIntTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- primTypeErrorTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind)
- primClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData
- allPrimClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData
- primCoerceClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData
- primRowClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData
- primRowListClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData
- primSymbolClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData
- primIntClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData
- primTypeErrorClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData
- lookupConstructor :: Environment -> Qualified (ProperName 'ConstructorName) -> (DataDeclType, ProperName 'TypeName, SourceType, [Ident])
- lookupValue :: Environment -> Qualified Ident -> Maybe (SourceType, NameKind, NameVisibility)
- dictTypeName' :: Text -> Text
- dictTypeName :: ProperName a -> ProperName a
- isDictTypeName :: ProperName a -> Bool
- nominalRolesForKind :: Type a -> [Role]
- kindArity :: Type a -> Int
- unapplyKinds :: Type a -> ([Type a], Type a)
Documentation
data Environment Source #
The Environment
defines all values and types which are currently in scope:
Environment | |
|
Instances
data TypeClassData Source #
Information about a type class
TypeClassData | |
|
Instances
data FunctionalDependency Source #
A functional dependency indicates a relationship between two sets of type arguments in a class declaration.
FunctionalDependency | |
|
Instances
initEnvironment :: Environment Source #
The initial environment with no values and only the default javascript types defined
makeTypeClassData :: [(Text, Maybe SourceType)] -> [(Ident, SourceType)] -> [SourceConstraint] -> [FunctionalDependency] -> Bool -> TypeClassData Source #
A constructor for TypeClassData that computes which type class arguments are fully determined and argument covering sets. Fully determined means that this argument cannot be used when selecting a type class instance. A covering set is a minimal collection of arguments that can be used to find an instance and therefore determine all other type arguments.
An example of the difference between determined and fully determined would be with the class:
```class C a b c | a -> b, b -> a, b -> c```
In this case, a
must differ when b
differs, and vice versa - each is determined by the other.
Both a
and b
can be used in selecting a type class instance. However, c
cannot - it is
fully determined by a
and b
.
Define a graph of type class arguments with edges being fundep determiners to determined. Each argument also has a self looping edge. An argument is fully determined if doesn't appear at the start of a path of strongly connected components. An argument is not fully determined otherwise.
The way we compute this is by saying: an argument X is fully determined if there are arguments that determine X that X does not determine. This is the same thing: everything X determines includes everything in its SCC, and everything determining X is either before it in an SCC path, or in the same SCC.
computeCoveringSets :: Int -> [FunctionalDependency] -> (Set Int, Set (Set Int)) Source #
data NameVisibility Source #
The visibility of a name in scope
Undefined | The name is defined in the current binding group, but is not visible |
Defined | The name is defined in the another binding group, or has been made visible by a function binder |
Instances
Generic NameVisibility Source # | |
Defined in Language.PureScript.Environment type Rep NameVisibility :: Type -> Type # from :: NameVisibility -> Rep NameVisibility x # to :: Rep NameVisibility x -> NameVisibility # | |
Show NameVisibility Source # | |
Defined in Language.PureScript.Environment showsPrec :: Int -> NameVisibility -> ShowS # show :: NameVisibility -> String # showList :: [NameVisibility] -> ShowS # | |
NFData NameVisibility Source # | |
Defined in Language.PureScript.Environment rnf :: NameVisibility -> () # | |
Eq NameVisibility Source # | |
Defined in Language.PureScript.Environment (==) :: NameVisibility -> NameVisibility -> Bool # (/=) :: NameVisibility -> NameVisibility -> Bool # | |
Serialise NameVisibility Source # | |
Defined in Language.PureScript.Environment encode :: NameVisibility -> Encoding # decode :: Decoder s NameVisibility # encodeList :: [NameVisibility] -> Encoding # decodeList :: Decoder s [NameVisibility] # | |
type Rep NameVisibility Source # | |
Defined in Language.PureScript.Environment |
A flag for whether a name is for an private or public value - only public values will be included in a generated externs file.
Private | A private value introduced as an artifact of code generation (class instances, class member accessors, etc.) |
Public | A public value for a module member or foreign import declaration |
External | A name for member introduced by foreign import |
Instances
Generic NameKind Source # | |
Show NameKind Source # | |
NFData NameKind Source # | |
Defined in Language.PureScript.Environment | |
Eq NameKind Source # | |
Serialise NameKind Source # | |
type Rep NameKind Source # | |
Defined in Language.PureScript.Environment type Rep NameKind = D1 ('MetaData "NameKind" "Language.PureScript.Environment" "purescript-0.15.7-3xSYkQR1O27GufieOHVqoE" 'False) (C1 ('MetaCons "Private" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Public" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "External" 'PrefixI 'False) (U1 :: Type -> Type))) |
The kinds of a type
DataType DataDeclType [(Text, Maybe SourceType, Role)] [(ProperName 'ConstructorName, [SourceType])] | Data type |
TypeSynonym | Type synonym |
ExternData [Role] | Foreign data |
LocalTypeVariable | A local type variable |
ScopedTypeVar | A scoped type variable |
Instances
data DataDeclType Source #
The type ('data' or 'newtype') of a data type declaration
Instances
showDataDeclType :: DataDeclType -> Text Source #
kindType :: SourceType Source #
Kind of ground types
kindDoc :: SourceType Source #
kindRowList :: SourceType -> SourceType Source #
kindRow :: SourceType -> SourceType Source #
tyFunction :: SourceType Source #
Type constructor for functions
tyString :: SourceType Source #
Type constructor for strings
tyChar :: SourceType Source #
Type constructor for strings
tyNumber :: SourceType Source #
Type constructor for numbers
tyInt :: SourceType Source #
Type constructor for integers
tyBoolean :: SourceType Source #
Type constructor for booleans
tyArray :: SourceType Source #
Type constructor for arrays
tyRecord :: SourceType Source #
Type constructor for records
tyVar :: Text -> SourceType Source #
tyForall :: Text -> SourceType -> SourceType -> SourceType Source #
function :: SourceType -> SourceType -> SourceType Source #
Smart constructor for function types
(-:>) :: SourceType -> SourceType -> SourceType infixr 4 Source #
primClass :: Qualified (ProperName 'ClassName) -> (SourceType -> SourceType) -> [(Qualified (ProperName 'TypeName), (SourceType, TypeKind))] Source #
primTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
The primitive types in the external environment with their
associated kinds. There are also pseudo Fail
, Warn
, and Partial
types
that correspond to the classes with the same names.
allPrimTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
This Map
contains all of the prim types from all Prim modules.
primBooleanTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
primCoerceTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
primOrderingTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
primRowTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
primRowListTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
primSymbolTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
primIntTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
primTypeErrorTypes :: Map (Qualified (ProperName 'TypeName)) (SourceType, TypeKind) Source #
primClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData Source #
The primitive class map. This just contains the Partial
class.
Partial
is used as a kind of magic constraint for partial functions.
allPrimClasses :: Map (Qualified (ProperName 'ClassName)) TypeClassData Source #
This contains all of the type classes from all Prim modules.
lookupConstructor :: Environment -> Qualified (ProperName 'ConstructorName) -> (DataDeclType, ProperName 'TypeName, SourceType, [Ident]) Source #
Finds information about data constructors from the current environment.
lookupValue :: Environment -> Qualified Ident -> Maybe (SourceType, NameKind, NameVisibility) Source #
Finds information about values from the current environment.
dictTypeName' :: Text -> Text Source #
dictTypeName :: ProperName a -> ProperName a Source #
isDictTypeName :: ProperName a -> Bool Source #
nominalRolesForKind :: Type a -> [Role] Source #
Given the kind of a type, generate a list Nominal
roles. This is used for
opaque foreign types as well as type classes.