ghc-source-gen-0.4.0.0: Constructs Haskell syntax trees for the GHC API.

Safe HaskellNone
LanguageHaskell2010

GHC.SourceGen.Name

Contents

Description

This module defines custom types for defining names of various syntax terms.

These types are all instances of IsString. For ease of use, we recommend enabling the OverloadedStrings extension.

Synopsis

RdrNameStr

data RdrNameStr Source #

A string identifier which may be qualified to a particular module.

RdrNameStr wraps an OccNameStr and thus keeps track of whether it is a "constructor" or "variable" (e.g.: "Foo.Bar" vs "Foo.bar", respectively).

RdrNameStr is simililar in purpose to GHC's RdrName. However, unlike RdrName, RdrNameStr does not differentiate between the namespace of types and of values. Functions in this package that take a RdrNameStr as input will internally convert it to the proper namespace. (This approach makes it easier to implement an IsString instance without the context where a name would be used.)

For example:

fromString "A.B.c" == QualStr (fromString "A.B") (fromString "c")
fromString "c" == UnqualStr (fromString "c")

OccNameStr

data OccNameStr Source #

A string identifier referring to a name.

OccNameStr keeps track of whether it is a "constructor" or "variable" (e.g.: "Foo" vs "foo", respectively).

OccNameStr is simililar in purpose to GHC's OccName. However, unlike OccName, OccNameStr does not differentiate between the namespace of types and of values. Functions in this package that take an OccNameStr as input will internally convert it to the proper namespace. (This approach makes it easier to implement an IsString instance without the context where a name would be used.)

occNameToStr :: OccName -> OccNameStr Source #

Converts a GHC OccName to an OccNameStr. Ignores whether the input came from the namespace of types or of values.

nameToStr :: Name -> OccNameStr Source #

Converts from a GHC Name to an OccNameStr. Ignores whether the input came from the namespace of types or of values, as well as any other information about where the name came from.