Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data DataDeclaration v a = DataDeclaration {
- modifier :: Modifier
- annotation :: a
- bound :: [v]
- constructors' :: [(a, v, Type v a)]
- newtype EffectDeclaration v a = EffectDeclaration {
- toDataDecl :: DataDeclaration v a
- type Decl v a = Either (EffectDeclaration v a) (DataDeclaration v a)
- data DeclOrBuiltin v a
- = Builtin ConstructorType
- | Decl (Decl v a)
- data Modifier
- = Structural
- | Unique Text
- allVars :: Ord v => DataDeclaration v a -> Set v
- asDataDecl :: Decl v a -> DataDeclaration v a
- bindReferences :: Var v => (v -> Name) -> Set v -> Map Name Reference -> DataDeclaration v a -> ResolutionResult a (DataDeclaration v a)
- constructorCount :: DataDeclaration v a -> Int
- constructorNames :: Var v => DataDeclaration v a -> [Text]
- constructors :: DataDeclaration v a -> [(v, Type v a)]
- constructorType :: Decl v a -> ConstructorType
- constructorTypes :: DataDeclaration v a -> [Type v a]
- constructorVars :: DataDeclaration v a -> [v]
- constructorIds :: DataDeclaration v a -> [ConstructorId]
- declConstructorReferents :: TypeReferenceId -> Decl v a -> [Id]
- declTypeDependencies :: Ord v => Decl v a -> Set Reference
- labeledDeclTypeDependencies :: Ord v => Decl v a -> Set LabeledDependency
- labeledDeclDependenciesIncludingSelf :: Ord v => TypeReference -> Decl v a -> Set LabeledDependency
- declFields :: Var v => Decl v a -> Either [Int] [Int]
- typeDependencies :: Ord v => DataDeclaration v a -> Set TypeReference
- labeledTypeDependencies :: Ord v => DataDeclaration v a -> Set LabeledDependency
- unhashComponent :: forall v a. Var v => Map Id (Decl v a) -> Map Id (v, Decl v a)
- mkDataDecl' :: Modifier -> a -> [v] -> [(a, v, Type v a)] -> DataDeclaration v a
- mkEffectDecl' :: Modifier -> a -> [v] -> [(a, v, Type v a)] -> EffectDeclaration v a
- typeOfConstructor :: DataDeclaration v a -> ConstructorId -> Maybe (Type v a)
- withEffectDeclM :: Functor f => (DataDeclaration v a -> f (DataDeclaration v' a')) -> EffectDeclaration v a -> f (EffectDeclaration v' a')
- amap :: (a -> a2) -> Decl v a -> Decl v a2
- updateDependencies :: Ord v => Map Reference Reference -> Decl v a -> Decl v a
- constructors_ :: Lens' (DataDeclaration v a) [(a, v, Type v a)]
- asDataDecl_ :: Iso' (EffectDeclaration v a) (DataDeclaration v a)
- declAsDataDecl_ :: Lens' (Decl v a) (DataDeclaration v a)
- setConstructorNames :: [v] -> Decl v a -> Decl v a
Documentation
data DataDeclaration v a Source #
DataDeclaration | |
|
Instances
newtype EffectDeclaration v a Source #
Instances
type Decl v a = Either (EffectDeclaration v a) (DataDeclaration v a) Source #
data DeclOrBuiltin v a Source #
Builtin ConstructorType | |
Decl (Decl v a) |
Instances
(Show a, Show v) => Show (DeclOrBuiltin v a) Source # | |
Defined in Unison.DataDeclaration showsPrec :: Int -> DeclOrBuiltin v a -> ShowS # show :: DeclOrBuiltin v a -> String # showList :: [DeclOrBuiltin v a] -> ShowS # | |
(Var v, Eq a) => Eq (DeclOrBuiltin v a) Source # | |
Defined in Unison.DataDeclaration (==) :: DeclOrBuiltin v a -> DeclOrBuiltin v a -> Bool # (/=) :: DeclOrBuiltin v a -> DeclOrBuiltin v a -> Bool # | |
(Var v, Ord a) => Ord (DeclOrBuiltin v a) Source # | |
Defined in Unison.DataDeclaration compare :: DeclOrBuiltin v a -> DeclOrBuiltin v a -> Ordering # (<) :: DeclOrBuiltin v a -> DeclOrBuiltin v a -> Bool # (<=) :: DeclOrBuiltin v a -> DeclOrBuiltin v a -> Bool # (>) :: DeclOrBuiltin v a -> DeclOrBuiltin v a -> Bool # (>=) :: DeclOrBuiltin v a -> DeclOrBuiltin v a -> Bool # max :: DeclOrBuiltin v a -> DeclOrBuiltin v a -> DeclOrBuiltin v a # min :: DeclOrBuiltin v a -> DeclOrBuiltin v a -> DeclOrBuiltin v a # |
allVars :: Ord v => DataDeclaration v a -> Set v Source #
All variables mentioned in the given data declaration. Includes both term and type variables, both free and bound.
asDataDecl :: Decl v a -> DataDeclaration v a Source #
bindReferences :: Var v => (v -> Name) -> Set v -> Map Name Reference -> DataDeclaration v a -> ResolutionResult a (DataDeclaration v a) Source #
constructorCount :: DataDeclaration v a -> Int Source #
constructorNames :: Var v => DataDeclaration v a -> [Text] Source #
constructors :: DataDeclaration v a -> [(v, Type v a)] Source #
constructorType :: Decl v a -> ConstructorType Source #
constructorTypes :: DataDeclaration v a -> [Type v a] Source #
constructorVars :: DataDeclaration v a -> [v] Source #
constructorIds :: DataDeclaration v a -> [ConstructorId] Source #
The constructor ids for the given data declaration.
declConstructorReferents :: TypeReferenceId -> Decl v a -> [Id] Source #
labeledDeclTypeDependencies :: Ord v => Decl v a -> Set LabeledDependency Source #
labeledDeclDependenciesIncludingSelf :: Ord v => TypeReference -> Decl v a -> Set LabeledDependency Source #
Compute the dependencies of a data declaration, including the type itself and references for each of its constructors.
NOTE: You may prefer labeledDeclDependenciesIncludingSelfAndFieldAccessors in Unison.DataDeclaration.Dependencies, it also includes Referents for accessors of record fields.
typeDependencies :: Ord v => DataDeclaration v a -> Set TypeReference Source #
All references to types mentioned in the given data declaration's fields/constructors Note: Does not include references to the constructors or the decl itself (unless the decl is self-referential) Note: Does NOT include the referents for fields and field accessors. Those must be computed separately because we need access to the typechecker to do so.
labeledTypeDependencies :: Ord v => DataDeclaration v a -> Set LabeledDependency Source #
mkDataDecl' :: Modifier -> a -> [v] -> [(a, v, Type v a)] -> DataDeclaration v a Source #
mkEffectDecl' :: Modifier -> a -> [v] -> [(a, v, Type v a)] -> EffectDeclaration v a Source #
typeOfConstructor :: DataDeclaration v a -> ConstructorId -> Maybe (Type v a) Source #
withEffectDeclM :: Functor f => (DataDeclaration v a -> f (DataDeclaration v' a')) -> EffectDeclaration v a -> f (EffectDeclaration v' a') Source #
constructors_ :: Lens' (DataDeclaration v a) [(a, v, Type v a)] Source #
asDataDecl_ :: Iso' (EffectDeclaration v a) (DataDeclaration v a) Source #
declAsDataDecl_ :: Lens' (Decl v a) (DataDeclaration v a) Source #
setConstructorNames :: [v] -> Decl v a -> Decl v a Source #
Overwrite the constructor names with the given list, given in canonical order, which is assumed to be of the correct length.
Presumably this is called because the decl was loaded from the database outside of the context of a namespace, since it's not stored with names there, so we had plugged in dummy names like Constructor1, Constructor2, ...
Then, at some point, we discover the constructors' names in a namespace, and now we'd like to combine the two together to get a Decl structure in memory with good/correct names for constructors.