purescript-0.11.6: PureScript Programming Language Compiler

Safe HaskellNone
LanguageHaskell2010

Language.PureScript.Environment

Synopsis

Documentation

data Environment #

The Environment defines all values and types which are currently in scope:

Constructors

Environment 

Fields

Instances

Show Environment # 
Generic Environment # 

Associated Types

type Rep Environment :: * -> * #

NFData Environment # 

Methods

rnf :: Environment -> () #

type Rep Environment # 

data TypeClassData #

Information about a type class

Constructors

TypeClassData 

Fields

Instances

Show TypeClassData # 
Generic TypeClassData # 

Associated Types

type Rep TypeClassData :: * -> * #

NFData TypeClassData # 

Methods

rnf :: TypeClassData -> () #

type Rep TypeClassData # 
type Rep TypeClassData = D1 (MetaData "TypeClassData" "Language.PureScript.Environment" "purescript-0.11.6-FH7waWkD6GQKRwiG3siRFE" False) (C1 (MetaCons "TypeClassData" PrefixI True) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "typeClassArguments") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(Text, Maybe Kind)])) ((:*:) (S1 (MetaSel (Just Symbol "typeClassMembers") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(Ident, Type)])) (S1 (MetaSel (Just Symbol "typeClassSuperclasses") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Constraint])))) ((:*:) (S1 (MetaSel (Just Symbol "typeClassDependencies") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [FunctionalDependency])) ((:*:) (S1 (MetaSel (Just Symbol "typeClassDeterminedArguments") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Set Int))) (S1 (MetaSel (Just Symbol "typeClassCoveringSets") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Set (Set Int))))))))

data FunctionalDependency #

A functional dependency indicates a relationship between two sets of type arguments in a class declaration.

Constructors

FunctionalDependency 

Fields

initEnvironment :: Environment #

The initial environment with no values and only the default javascript types defined

makeTypeClassData :: [(Text, Maybe Kind)] -> [(Ident, Type)] -> [Constraint] -> [FunctionalDependency] -> TypeClassData #

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.

data NameVisibility #

The visibility of a name in scope

Constructors

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

Eq NameVisibility # 
Show NameVisibility # 
Generic NameVisibility # 

Associated Types

type Rep NameVisibility :: * -> * #

NFData NameVisibility # 

Methods

rnf :: NameVisibility -> () #

type Rep NameVisibility # 
type Rep NameVisibility = D1 (MetaData "NameVisibility" "Language.PureScript.Environment" "purescript-0.11.6-FH7waWkD6GQKRwiG3siRFE" False) ((:+:) (C1 (MetaCons "Undefined" PrefixI False) U1) (C1 (MetaCons "Defined" PrefixI False) U1))

data NameKind #

A flag for whether a name is for an private or public value - only public values will be included in a generated externs file.

Constructors

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 foreing import declaration

External

A name for member introduced by foreign import

Instances

Eq NameKind # 
Show NameKind # 
Generic NameKind # 

Associated Types

type Rep NameKind :: * -> * #

Methods

from :: NameKind -> Rep NameKind x #

to :: Rep NameKind x -> NameKind #

NFData NameKind # 

Methods

rnf :: NameKind -> () #

type Rep NameKind # 
type Rep NameKind = D1 (MetaData "NameKind" "Language.PureScript.Environment" "purescript-0.11.6-FH7waWkD6GQKRwiG3siRFE" False) ((:+:) (C1 (MetaCons "Private" PrefixI False) U1) ((:+:) (C1 (MetaCons "Public" PrefixI False) U1) (C1 (MetaCons "External" PrefixI False) U1)))

data TypeKind #

The kinds of a type

Constructors

DataType [(Text, Maybe Kind)] [(ProperName ConstructorName, [Type])]

Data type

TypeSynonym

Type synonym

ExternData

Foreign data

LocalTypeVariable

A local type variable

ScopedTypeVar

A scoped type variable

Instances

Eq TypeKind # 
Show TypeKind # 
Generic TypeKind # 

Associated Types

type Rep TypeKind :: * -> * #

Methods

from :: TypeKind -> Rep TypeKind x #

to :: Rep TypeKind x -> TypeKind #

ToJSON TypeKind # 
FromJSON TypeKind # 
NFData TypeKind # 

Methods

rnf :: TypeKind -> () #

type Rep TypeKind # 
type Rep TypeKind = D1 (MetaData "TypeKind" "Language.PureScript.Environment" "purescript-0.11.6-FH7waWkD6GQKRwiG3siRFE" False) ((:+:) ((:+:) (C1 (MetaCons "DataType" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(Text, Maybe Kind)])) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(ProperName ConstructorName, [Type])])))) (C1 (MetaCons "TypeSynonym" PrefixI False) U1)) ((:+:) (C1 (MetaCons "ExternData" PrefixI False) U1) ((:+:) (C1 (MetaCons "LocalTypeVariable" PrefixI False) U1) (C1 (MetaCons "ScopedTypeVar" PrefixI False) U1))))

data DataDeclType #

The type ('data' or 'newtype') of a data type declaration

Constructors

Data

A standard data constructor

Newtype

A newtype constructor

primName :: Text -> Qualified (ProperName a) #

Construct a ProperName in the Prim module

kindType :: Kind #

Kind of ground types

primTy :: Text -> Type #

Construct a type in the Prim module

tyFunction :: Type #

Type constructor for functions

tyString :: Type #

Type constructor for strings

tyChar :: Type #

Type constructor for strings

tyNumber :: Type #

Type constructor for numbers

tyInt :: Type #

Type constructor for integers

tyBoolean :: Type #

Type constructor for booleans

tyArray :: Type #

Type constructor for arrays

tyRecord :: Type #

Type constructor for records

isObject :: Type -> Bool #

Check whether a type is a record

isFunction :: Type -> Bool #

Check whether a type is a function

function :: Type -> Type -> Type #

Smart constructor for function types

primKinds :: Set (Qualified (ProperName KindName)) #

The primitive kinds

primTypes :: Map (Qualified (ProperName TypeName)) (Kind, TypeKind) #

The primitive types in the external javascript environment with their associated kinds. There are also pseudo Fail, Warn, and Partial types that correspond to the classes with the same names.

primClasses :: Map (Qualified (ProperName ClassName)) TypeClassData #

The primitive class map. This just contains the Fail, Warn, and Partial classes. Partial is used as a kind of magic constraint for partial functions. Fail is used for user-defined type errors. Warn for user-defined warnings.

lookupConstructor :: Environment -> Qualified (ProperName ConstructorName) -> (DataDeclType, ProperName TypeName, Type, [Ident]) #

Finds information about data constructors from the current environment.

isNewtypeConstructor :: Environment -> Qualified (ProperName ConstructorName) -> Bool #

Checks whether a data constructor is for a newtype.

lookupValue :: Environment -> Qualified Ident -> Maybe (Type, NameKind, NameVisibility) #

Finds information about values from the current environment.