curry-base-0.4.2: Functions for manipulating Curry programs

Copyright(c) 1999 - 2004, Wolfgang Lux 2011 - 2013, Björn Peemöller
LicenseBSD-3-clause
Maintainerbjp@informatik.uni-kiel.de
Stabilityexperimental
Portabilitynon-portable (DeriveDataTypeable)
Safe HaskellNone
LanguageHaskell2010

Curry.Base.Ident

Contents

Description

This module provides the implementation of identifiers and some utility functions for identifiers.

Identifiers comprise the name of the denoted entity and an id, which can be used for renaming identifiers, e.g., in order to resolve name conflicts between identifiers from different scopes. An identifier with an id 0 is considered as not being renamed and, hence, its id will not be shown.

Qualified identifiers may optionally be prefixed by a module name.

Synopsis

Module identifiers

data ModuleIdent Source #

Module identifier

Constructors

ModuleIdent 

Fields

Instances

Eq ModuleIdent Source # 
Data ModuleIdent Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ModuleIdent -> c ModuleIdent #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ModuleIdent #

toConstr :: ModuleIdent -> Constr #

dataTypeOf :: ModuleIdent -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ModuleIdent) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModuleIdent) #

gmapT :: (forall b. Data b => b -> b) -> ModuleIdent -> ModuleIdent #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ModuleIdent -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ModuleIdent -> r #

gmapQ :: (forall d. Data d => d -> u) -> ModuleIdent -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ModuleIdent -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ModuleIdent -> m ModuleIdent #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ModuleIdent -> m ModuleIdent #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ModuleIdent -> m ModuleIdent #

Ord ModuleIdent Source # 
Read ModuleIdent Source # 
Show ModuleIdent Source # 
Pretty ModuleIdent Source # 
SrcRefOf ModuleIdent Source # 
HasPosition ModuleIdent Source # 

mkMIdent :: [String] -> ModuleIdent Source #

Construct a ModuleIdent from a list of Strings forming the the hierarchical module name.

moduleName :: ModuleIdent -> String Source #

Retrieve the hierarchical name of a module

escModuleName :: ModuleIdent -> String Source #

Show the name of an ModuleIdent escaped by ticks

fromModuleName :: String -> ModuleIdent Source #

Resemble the hierarchical module name from a String by splitting the String at inner dots.

Note: This function does not check the String to be a valid module identifier, use isValidModuleName for this purpose.

isValidModuleName :: String -> Bool Source #

Check whether a String is a valid module name.

Valid module names must satisfy the following conditions:

  • The name must not be empty
  • The name must consist of one or more single identifiers, seperated by dots
  • Each single identifier must be non-empty, start with a letter and consist of letter, digits, single quotes or underscores only

Local identifiers

data Ident Source #

Simple identifier

Constructors

Ident 

Fields

Instances

Eq Ident Source # 

Methods

(==) :: Ident -> Ident -> Bool #

(/=) :: Ident -> Ident -> Bool #

Data Ident Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ident -> c Ident #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Ident #

toConstr :: Ident -> Constr #

dataTypeOf :: Ident -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Ident) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Ident) #

gmapT :: (forall b. Data b => b -> b) -> Ident -> Ident #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ident -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ident -> r #

gmapQ :: (forall d. Data d => d -> u) -> Ident -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Ident -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ident -> m Ident #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ident -> m Ident #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ident -> m Ident #

Ord Ident Source # 

Methods

compare :: Ident -> Ident -> Ordering #

(<) :: Ident -> Ident -> Bool #

(<=) :: Ident -> Ident -> Bool #

(>) :: Ident -> Ident -> Bool #

(>=) :: Ident -> Ident -> Bool #

max :: Ident -> Ident -> Ident #

min :: Ident -> Ident -> Ident #

Read Ident Source # 
Show Ident Source # 

Methods

showsPrec :: Int -> Ident -> ShowS #

show :: Ident -> String #

showList :: [Ident] -> ShowS #

Pretty Ident Source # 
SrcRefOf Ident Source # 
HasPosition Ident Source # 

mkIdent :: String -> Ident Source #

Construct an Ident from a String

showIdent :: Ident -> String Source #

Show function for an Ident

escName :: Ident -> String Source #

Show the name of an Ident escaped by ticks

identSupply :: [Ident] Source #

Infinite list of different Idents

globalScope :: Integer Source #

Global scope for renaming

hasGlobalScope :: Ident -> Bool Source #

Has the identifier global scope?

isRenamed :: Ident -> Bool Source #

Is the Ident renamed?

renameIdent :: Ident -> Integer -> Ident Source #

Rename an Ident by changing its unique number

unRenameIdent :: Ident -> Ident Source #

Revert the renaming of an Ident by resetting its unique number

updIdentName :: (String -> String) -> Ident -> Ident Source #

Change the name of an Ident using a renaming function

isInfixOp :: Ident -> Bool Source #

Check whether an Ident identifies an infix operation

Qualified identifiers

data QualIdent Source #

Qualified identifier

Constructors

QualIdent 

Fields

Instances

Eq QualIdent Source # 
Data QualIdent Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> QualIdent -> c QualIdent #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c QualIdent #

toConstr :: QualIdent -> Constr #

dataTypeOf :: QualIdent -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c QualIdent) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c QualIdent) #

gmapT :: (forall b. Data b => b -> b) -> QualIdent -> QualIdent #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> QualIdent -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> QualIdent -> r #

gmapQ :: (forall d. Data d => d -> u) -> QualIdent -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> QualIdent -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> QualIdent -> m QualIdent #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> QualIdent -> m QualIdent #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> QualIdent -> m QualIdent #

Ord QualIdent Source # 
Read QualIdent Source # 
Show QualIdent Source # 
Pretty QualIdent Source # 
SrcRefOf QualIdent Source # 
HasPosition QualIdent Source # 

qualName :: QualIdent -> String Source #

show function for qualified identifiers

escQualName :: QualIdent -> String Source #

Show the name of an QualIdent escaped by ticks

isQInfixOp :: QualIdent -> Bool Source #

Check whether an QualIdent identifies an infix operation

qualQualify :: ModuleIdent -> QualIdent -> QualIdent Source #

Convert an QualIdent to a new QualIdent with a given ModuleIdent. If the original QualIdent already contains an ModuleIdent it remains unchanged.

qualifyLike :: QualIdent -> Ident -> QualIdent Source #

Qualify an Ident with the ModuleIdent of the given QualIdent, if present.

isQualified :: QualIdent -> Bool Source #

Check whether a QualIdent contains a ModuleIdent

unqualify :: QualIdent -> Ident Source #

Remove the qualification of an QualIdent

qualUnqualify :: ModuleIdent -> QualIdent -> QualIdent Source #

Remove the qualification with a specific ModuleIdent. If the original QualIdent has no ModuleIdent or a different one, it remains unchanged.

localIdent :: ModuleIdent -> QualIdent -> Maybe Ident Source #

Extract the Ident of an QualIdent if it is local to the ModuleIdent, i.e. if the Ident is either unqualified or qualified with the given ModuleIdent.

isLocalIdent :: ModuleIdent -> QualIdent -> Bool Source #

Check whether the given QualIdent is local to the given ModuleIdent.

updQualIdent :: (ModuleIdent -> ModuleIdent) -> (Ident -> Ident) -> QualIdent -> QualIdent Source #

Update a QualIdent by applying functions to its components

Predefined simple identifiers

Identifiers for modules

emptyMIdent :: ModuleIdent Source #

ModuleIdent for the empty module

mainMIdent :: ModuleIdent Source #

ModuleIdent for the main module

Identifiers for types

unitId :: Ident Source #

Ident for the type/value unit ('()')

boolId :: Ident Source #

Ident for the type Bool

charId :: Ident Source #

Ident for the type Char

intId :: Ident Source #

Ident for the type Int

floatId :: Ident Source #

Ident for the type Float

listId :: Ident Source #

Ident for the type '[]'

ioId :: Ident Source #

Ident for the type IO

successId :: Ident Source #

Ident for the type Success

Identifiers for constructors

trueId :: Ident Source #

Ident for the value True

falseId :: Ident Source #

Ident for the value False

nilId :: Ident Source #

Ident for the value '[]'

consId :: Ident Source #

Ident for the function :

tupleId :: Int -> Ident Source #

Construct an Ident for an n-ary tuple where n > 1

isTupleId :: Ident -> Bool Source #

Check whether an Ident is an identifier for an tuple type

tupleArity :: Ident -> Int Source #

Compute the arity of a tuple identifier

Identifiers for values

mainId :: Ident Source #

Ident for the main function

minusId :: Ident Source #

Ident for the minus function

fminusId :: Ident Source #

Ident for the minus function for Floats

anonId :: Ident Source #

Ident for anonymous variable

isAnonId :: Ident -> Bool Source #

Check whether an Ident represents an anonymous identifier (anonId)

Predefined qualified identifiers

Identifiers for types

qUnitId :: QualIdent Source #

QualIdent for the type/value unit ('()')

qListId :: QualIdent Source #

QualIdent for the type '[]'

qSuccessId :: QualIdent Source #

QualIdent for the type Success

Identifiers for constructors

qTrueId :: QualIdent Source #

QualIdent for the constructor True

qFalseId :: QualIdent Source #

QualIdent for the constructor False

qNilId :: QualIdent Source #

QualIdent for the constructor '[]'

qConsId :: QualIdent Source #

QualIdent for the constructor :

qTupleId :: Int -> QualIdent Source #

QualIdent for the type of n-ary tuples

isQTupleId :: QualIdent -> Bool Source #

Check whether an QualIdent is an identifier for an tuple type

qTupleArity :: QualIdent -> Int Source #

Compute the arity of an qualified tuple identifier

Extended functionality

Functional patterns

fpSelectorId :: Int -> Ident Source #

Construct an Ident for a functional pattern

isFpSelectorId :: Ident -> Bool Source #

Check whether an Ident is an identifier for a functional pattern

isQualFpSelectorId :: QualIdent -> Bool Source #

Check whether an QualIdent is an identifier for a function pattern

Records

recSelectorId Source #

Arguments

:: QualIdent

identifier of the record

-> Ident

identifier of the label

-> Ident 

Construct an Ident for a record selection pattern

qualRecSelectorId Source #

Arguments

:: ModuleIdent

default module

-> QualIdent

record identifier

-> Ident

label identifier

-> QualIdent 

Construct a QualIdent for a record selection pattern

recUpdateId Source #

Arguments

:: QualIdent

record identifier

-> Ident

label identifier

-> Ident 

Construct an Ident for a record update pattern

qualRecUpdateId Source #

Arguments

:: ModuleIdent

default module

-> QualIdent

record identifier

-> Ident

label identifier

-> QualIdent 

Construct a QualIdent for a record update pattern

recordExt :: String Source #

Annotation for record identifiers

recordExtId :: Ident -> Ident Source #

Construct an Ident for a record

isRecordExtId :: Ident -> Bool Source #

Check whether an Ident is an identifier for a record

fromRecordExtId :: Ident -> Ident Source #

Retrieve the Ident from a record identifier

labelExt :: String Source #

Annotation for record label identifiers

labelExtId :: Ident -> Ident Source #

Construct an Ident for a record label

isLabelExtId :: Ident -> Bool Source #

Check whether an Ident is an identifier for a record label

fromLabelExtId :: Ident -> Ident Source #

Retrieve the Ident from a record label identifier

renameLabel :: Ident -> Ident Source #

Rename an Ident for a record label

mkLabelIdent :: String -> Ident Source #

Construct an Ident for a record label