Safe Haskell | None |
---|---|
Language | Haskell2010 |
FreeC.Pass.QualifierPass
Description
This module contains a compiler pass that qualifies the names of all top-level declarations of the converted module with the name of that module.
Example
Consider the following module.
module Data.Tree where data Tree a = Leaf a | Branch (Tree a) (Tree a) mapTree :: (a -> b) -> Tree a -> Tree b mapTree f t = case t of Leaf x -> Leaf (f x) Branch l r -> Branch (mapTree f l) (mapTree f r)
After this pass the declarations of Tree
and mapTree
as well
as the type signature for mapTree
and the constructors Leaf
and Branch
are qualified.
module Data.Tree where data Data.Tree.Tree a = Data.Tree.Leaf a | Data.Tree.Branch (Tree a) (Tree a) Data.Tree.mapTree :: (a -> b) -> Tree a -> Tree b Data.Tree.mapTree f t = case t of Leaf x -> Leaf (f x) Branch l r -> Branch (mapTree f l) (mapTree f r)
However, references to Tree
, Leaf
, Branch
and mapTree
in the fields of the constructor declarations and on the right-hand
side of the function's type signature and declaration remain unqualified.
Also (type) arguments and local variable are not affected.
Specification
Precondition
There are no special requirements.
Translation
In a module M
all declarations, type signatures and pragmas of the forms
type T α₁ … αₘ = τ
data D α₁ … αₘ = C₁ τ₍₁,₁₎ … τ₍₁,ₖ₁₎ | … | Cₙ τ₍ₙ,₁₎ … τ₍ₙ,ₖₙ₎
f₁, …, fₙ :: τ
f x₁ … xₙ = e
{-# FreeC f DECREASES ON x #-}
are translated to
type M.T α₁ … αₘ = τ
data M.D α₁ … αₘ = M.C₁ τ₍₁,₁₎ … τ₍₁,ₖ₁₎ | … | M.Cₙ τ₍ₙ,₁₎ … τ₍ₙ,ₖₙ₎
M.f₁, …, M.fₙ :: τ
M.f x₁ … xₙ = e
{-# FreeC M.f DECREASES ON x #-}
If an identifier is qualified already, it keeps its original qualifier.
Postcondition
All DeclIdent
s in the module contain qualified identifiers
(i.e., Qual
s).