futhark-0.25.32: An optimising compiler for a functional, array-oriented language.

Safe Haskell | Safe-Inferred
Language | GHC2021

Language.Futhark.Semantic

Description

Definitions of various semantic objects (*not* the Futhark semantics themselves).

Synopsis

- data ImportName
- mkInitialImport :: FilePath -> ImportName
- mkImportFrom :: ImportName -> String -> ImportName
- includeToFilePath :: ImportName -> FilePath
- includeToString :: ImportName -> String
- includeToText :: ImportName -> Text
- data FileModule = FileModule {
  - fileAbs :: TySet
  - fileEnv :: Env
  - fileProg :: Prog
  - fileScope :: Env
  }
- type Imports = [(ImportName, FileModule)]
- data Namespace
  - = Term
  - | Type
  - | Signature
- data Env = Env {
  - envVtable :: Map VName BoundV
  - envTypeTable :: Map VName TypeBinding
  - envModTypeTable :: Map VName MTy
  - envModTable :: Map VName Mod
  - envNameMap :: NameMap
  }
- type TySet = Map (QualName VName) Liftedness
- data FunModType = FunModType {
  - funModTypeAbs :: TySet
  - funModTypeMod :: Mod
  - funModTypeMty :: MTy
  }
- type NameMap = Map (Namespace, Name) (QualName VName)
- data BoundV = BoundV {
  - boundValTParams :: [TypeParam]
  - boundValType :: StructType
  }
- data Mod
  - = ModEnv Env
  - | ModFun FunModType
- data TypeBinding = TypeAbbr Liftedness [TypeParam] StructRetType
- data MTy = MTy {
  - mtyAbs :: TySet
  - mtyMod :: Mod
  }

# Documentation

data ImportName Source #

Canonical reference to a Futhark code file. Does not include the `.fut` extension. This is most often a path relative to the working directory of the compiler. In a multi-file program, a file is known by exactly one import name, even if it is referenced relatively by different names by files in different subdirectories.

#### Instances

Instances details

Show ImportName Source # |
Instance details Defined in Language.Futhark.Syntax Methods showsPrec :: Int -> ImportName -> ShowS Source # show :: ImportName -> String Source # showList :: [ImportName] -> ShowS Source #
Eq ImportName Source # |
Instance details Defined in Language.Futhark.Syntax Methods (==) :: ImportName -> ImportName -> Bool Source # (/=) :: ImportName -> ImportName -> Bool Source #
Ord ImportName Source # |

Instance details

Defined in Language.Futhark.Syntax

Methods

compare :: ImportName -> ImportName -> Ordering Source #

(<) :: ImportName -> ImportName -> Bool Source #

(<=) :: ImportName -> ImportName -> Bool Source #

(>) :: ImportName -> ImportName -> Bool Source #

(>=) :: ImportName -> ImportName -> Bool Source #

max :: ImportName -> ImportName -> ImportName Source #

min :: ImportName -> ImportName -> ImportName Source #

mkInitialImport :: FilePath -> ImportName Source #

Create an import name immediately from a file path specified by the user.

mkImportFrom :: ImportName -> String -> ImportName Source #

We resolve '..' paths here and assume that no shenanigans are going on with symbolic links. If there is, too bad. Don't do that.

includeToFilePath :: ImportName -> FilePath Source #

Create a `.fut` file corresponding to an `ImportName`.

includeToString :: ImportName -> String Source #

Produce a human-readable canonicalized string from an `ImportName`.

includeToText :: ImportName -> Text Source #

Produce a human-readable canonicalized text from an `ImportName`.

data FileModule Source #

The result of type checking some file. Can be passed to further invocations of the type checker.

Constructors

FileModule |

Fields

- fileAbs :: TySet

  Abstract types.

- fileEnv :: Env

  The environment made available when importing this module.

- fileProg :: Prog
- fileScope :: Env

  The environment at the bottom of the file. Includes local parts.

type Imports = [(ImportName, FileModule)] Source #

A mapping from import names to imports. The ordering is significant.

data Namespace Source #

The space inhabited by a name.

Constructors

Term | Functions and values.
Type |
Signature |

#### Instances

Instances details

Enum Namespace Source # |

Instance details

Defined in Language.Futhark.Semantic

Methods

succ :: Namespace -> Namespace Source #

pred :: Namespace -> Namespace Source #

toEnum :: Int -> Namespace Source #

fromEnum :: Namespace -> Int Source #

enumFrom :: Namespace -> [Namespace] Source #

enumFromThen :: Namespace -> Namespace -> [Namespace] Source #

enumFromTo :: Namespace -> Namespace -> [Namespace] Source #

enumFromThenTo :: Namespace -> Namespace -> Namespace -> [Namespace] Source #

Show Namespace Source # |
Instance details Defined in Language.Futhark.Semantic Methods showsPrec :: Int -> Namespace -> ShowS Source # show :: Namespace -> String Source # showList :: [Namespace] -> ShowS Source #
Eq Namespace Source # |
Instance details Defined in Language.Futhark.Semantic Methods (==) :: Namespace -> Namespace -> Bool Source # (/=) :: Namespace -> Namespace -> Bool Source #
Ord Namespace Source # |

Instance details

Defined in Language.Futhark.Semantic

Methods

compare :: Namespace -> Namespace -> Ordering Source #

(<) :: Namespace -> Namespace -> Bool Source #

(<=) :: Namespace -> Namespace -> Bool Source #

(>) :: Namespace -> Namespace -> Bool Source #

(>=) :: Namespace -> Namespace -> Bool Source #

max :: Namespace -> Namespace -> Namespace Source #

min :: Namespace -> Namespace -> Namespace Source #

Pretty Namespace Source # |
Instance details Defined in Language.Futhark.Semantic Methods pretty :: Namespace -> Doc ann Source # prettyList :: [Namespace] -> Doc ann Source #

data Env Source #

Modules produces environment with this representation.

Constructors

Env |

Fields

- envVtable :: Map VName BoundV
- envTypeTable :: Map VName TypeBinding
- envModTypeTable :: Map VName MTy
- envModTable :: Map VName Mod
- envNameMap :: NameMap

#### Instances

Instances details

Monoid Env Source # |
Instance details Defined in Language.Futhark.Semantic Methods mempty :: Env Source # mappend :: Env -> Env -> Env Source # mconcat :: [Env] -> Env Source #
Semigroup Env Source # |
Instance details Defined in Language.Futhark.Semantic Methods (<>) :: Env -> Env -> Env Source # sconcat :: NonEmpty Env -> Env Source # stimes :: Integral b => b -> Env -> Env Source #
Show Env Source # |
Instance details Defined in Language.Futhark.Semantic Methods showsPrec :: Int -> Env -> ShowS Source # show :: Env -> String Source # showList :: [Env] -> ShowS Source #
Pretty Env Source # |
Instance details Defined in Language.Futhark.Semantic Methods pretty :: Env -> Doc ann Source # prettyList :: [Env] -> Doc ann Source #

type TySet = Map (QualName VName) Liftedness Source #

A mapping of abstract types to their liftedness.

data FunModType Source #

A parametric functor consists of a set of abstract types, the environment of its parameter, and the resulting module type.

Constructors

FunModType |

Fields

- funModTypeAbs :: TySet
- funModTypeMod :: Mod
- funModTypeMty :: MTy

#### Instances

Instances details

Show FunModType Source # |
Instance details Defined in Language.Futhark.Semantic Methods showsPrec :: Int -> FunModType -> ShowS Source # show :: FunModType -> String Source # showList :: [FunModType] -> ShowS Source #

type NameMap = Map (Namespace, Name) (QualName VName) Source #

A mapping from names (which always exist in some namespace) to a unique (tagged) name.

data BoundV Source #

Type parameters, list of parameter types (optinally named), and return type. The type parameters are in scope in both parameter types and the return type. Non-functional values have only a return type.

Constructors

BoundV |

Fields

- boundValTParams :: [TypeParam]
- boundValType :: StructType

#### Instances

Instances details

Show BoundV Source # |
Instance details Defined in Language.Futhark.Semantic Methods showsPrec :: Int -> BoundV -> ShowS Source # show :: BoundV -> String Source # showList :: [BoundV] -> ShowS Source #

data Mod Source #

Representation of a module, which is either a plain environment, or a parametric module ("functor" in SML).

Constructors

ModEnv Env |
ModFun FunModType |

#### Instances

Instances details

Show Mod Source # |
Instance details Defined in Language.Futhark.Semantic Methods showsPrec :: Int -> Mod -> ShowS Source # show :: Mod -> String Source # showList :: [Mod] -> ShowS Source #
Pretty Mod Source # |
Instance details Defined in Language.Futhark.Semantic Methods pretty :: Mod -> Doc ann Source # prettyList :: [Mod] -> Doc ann Source #

data TypeBinding Source #

A binding from a name to its definition as a type. We allow a return type here to support type abbreviations that hide some inner sizes (these must necessarily be `Lifted` or `SizeLifted`).

Constructors

TypeAbbr Liftedness [TypeParam] StructRetType |

#### Instances

Instances details

Show TypeBinding Source # |
Instance details Defined in Language.Futhark.Semantic Methods showsPrec :: Int -> TypeBinding -> ShowS Source # show :: TypeBinding -> String Source # showList :: [TypeBinding] -> ShowS Source #
Eq TypeBinding Source # |
Instance details Defined in Language.Futhark.Semantic Methods (==) :: TypeBinding -> TypeBinding -> Bool Source # (/=) :: TypeBinding -> TypeBinding -> Bool Source #

data MTy Source #

Representation of a module type.

Constructors

MTy |

Fields

- mtyAbs :: TySet

  Abstract types in the module type.

- mtyMod :: Mod

#### Instances

Instances details

Show MTy Source # |
Instance details Defined in Language.Futhark.Semantic Methods showsPrec :: Int -> MTy -> ShowS Source # show :: MTy -> String Source # showList :: [MTy] -> ShowS Source #
Pretty MTy Source # |
Instance details Defined in Language.Futhark.Semantic Methods pretty :: MTy -> Doc ann Source # prettyList :: [MTy] -> Doc ann Source #