HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduledhall-1.42.3Haskell2010

Dhall.Substitution

This module provides types and functions used in the substitution step which is done before type checking and normalization.

  • 1 type
  • 2 values
  • Packagedhall-1.42.3
  • Exports3
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceSubstitution.hs
typetype Substitutions s a = Map Text (Expr s a)
#

Substitutions map variables to arbitrary Dhall expressions. Note that we use Dhall.Map.Map as an underlying structure. Hence we respect insertion order.

valuesubstitute :: Expr s a -> Substitutions s a -> Expr s a
#

substitute expr s replaces all variables in expr (or its subexpression) with their substitute. For example, if the substitution map maps the variable Foo to the text "Foo" all occurrences of Foo with the text "Foo".

The substitutions will be done in the order they are inserted into the substitution map:

{-# LANGUAGE OverloadedStrings #-}

substitute (Dhall.Core.Var "Foo") (Dhall.Map.fromList [("Foo", Dhall.Core.Var "Bar"), ("Bar", Dhall.Core.Var "Baz")])

results in Dhall.Core.Var "Baz" since we first substitute "Foo" with "Bar" and then the resulting "Bar" with the final "Baz".