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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Compiler.Program

Description

Low-level compilation parts. Look at Futhark.Compiler for a more high-level API.

Synopsis

- readLibrary :: [Name] -> [FilePath] -> IO (Either (NonEmpty ProgError) (Warnings, Imports, VNameSource))
- readUntypedLibrary :: [FilePath] -> IO (Either (NonEmpty ProgError) [(ImportName, UncheckedProg)])
- type Imports = [(ImportName, FileModule)]
- data FileModule = FileModule {
  - fileAbs :: TySet
  - fileEnv :: Env
  - fileProg :: Prog
  - fileScope :: Env
  }
- data Warnings
- prettyWarnings :: Warnings -> Doc AnsiStyle
- data ProgError
  - = ProgError Loc (Doc ())
  - | ProgWarning Loc (Doc ())
- data LoadedProg
- noLoadedProg :: LoadedProg
- lpImports :: LoadedProg -> Imports
- lpWarnings :: LoadedProg -> Warnings
- lpFilePaths :: LoadedProg -> [FilePath]
- reloadProg :: LoadedProg -> [FilePath] -> VFS -> IO (Either (NonEmpty ProgError) LoadedProg)
- extendProg :: LoadedProg -> [FilePath] -> VFS -> IO (Either (NonEmpty ProgError) LoadedProg)
- type VFS = Map FilePath Text

# Documentation

readLibrary Source #

Arguments

:: [Name] | Extra functions that should be marked as entry points; only applies to the immediate files, not any imports imported.
-> [FilePath] | The files to read.
-> IO (Either (NonEmpty ProgError) (Warnings, Imports, VNameSource)) |

Read and type-check some Futhark files.

readUntypedLibrary :: [FilePath] -> IO (Either (NonEmpty ProgError) [(ImportName, UncheckedProg)]) Source #

Read (and parse) all source files (including the builtin prelude) corresponding to a set of root files.

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

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

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.

data Warnings Source #

The warnings produced by the compiler. The `Show` instance produces a human-readable description.

#### Instances

Instances details

Monoid Warnings Source # |
Instance details Defined in Language.Futhark.Warnings Methods mempty :: Warnings Source # mappend :: Warnings -> Warnings -> Warnings Source # mconcat :: [Warnings] -> Warnings Source #
Semigroup Warnings Source # |
Instance details Defined in Language.Futhark.Warnings Methods (<>) :: Warnings -> Warnings -> Warnings Source # sconcat :: NonEmpty Warnings -> Warnings Source # stimes :: Integral b => b -> Warnings -> Warnings Source #

prettyWarnings :: Warnings -> Doc AnsiStyle Source #

Prettyprint warnings, making use of colours and such.

data ProgError Source #

Note that the location may be `NoLoc`. This essentially only happens when the problem is that a root file cannot be found.

Constructors

ProgError Loc (Doc ()) |
ProgWarning Loc (Doc ()) | Not actually an error, but we want them reported with errors.

#### Instances

Instances details

Located ProgError Source # |
Instance details Defined in Futhark.Compiler.Program Methods locOf :: ProgError -> Loc Source # locOfList :: [ProgError] -> Loc Source #

data LoadedProg Source #

A loaded, type-checked program. This can be used to extract information about the program, but also to speed up subsequent reloads.

noLoadedProg :: LoadedProg Source #

A "loaded program" containing no actual files. Use this as a starting point for `reloadProg`

lpImports :: LoadedProg -> Imports Source #

The `Imports` of a `LoadedProg`, as expected by e.g. type checking functions.

lpWarnings :: LoadedProg -> Warnings Source #

All warnings of a `LoadedProg`.

lpFilePaths :: LoadedProg -> [FilePath] Source #

The absolute paths of the files that are part of this program.

reloadProg :: LoadedProg -> [FilePath] -> VFS -> IO (Either (NonEmpty ProgError) LoadedProg) Source #

Load some new files, reusing as much of the previously loaded program as possible. This does not *extend* the currently loaded program the way `extendProg` does it, so it is always correct (if less efficient) to pass `noLoadedProg`.

extendProg :: LoadedProg -> [FilePath] -> VFS -> IO (Either (NonEmpty ProgError) LoadedProg) Source #

Extend a loaded program with (possibly new) files.

type VFS = Map FilePath Text Source #

A mapping from absolute pathnames to pretty representing a virtual file system. Before loading a file from the file system, this mapping is consulted. If the desired pathname has an entry here, the corresponding pretty is used instead of loading the file from disk.