Commit c799a5ac authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Improved documentation

parent 58546d4f
{- |
Module : $Header$
Description : Extraction of free and bound variables
Copyright : (c) Wolfgang Lux
Copyright : (c) Wolfgang Lux
2011 - 2012 Björn Peemöller
License : OtherLicense
......
......@@ -2,7 +2,7 @@
Module : $Header$
Description : Environment of imported interfaces
Copyright : (c) 2002 - 2004, Wolfgang Lux
2011 , Björn Peemöller
2011 - 20113, Björn Peemöller
License : OtherLicense
Maintainer : bjp@informatik.uni-kiel.de
......@@ -18,10 +18,14 @@ import qualified Data.Map as Map (Map, empty, lookup)
import Curry.Base.Ident (ModuleIdent)
import Curry.Syntax (Interface)
-- |Environment which maps the 'ModuleIdent' of an imported module
-- to the corresponding 'Interface'.
type InterfaceEnv = Map.Map ModuleIdent Interface
lookupInterface :: ModuleIdent -> InterfaceEnv -> Maybe Interface
lookupInterface = Map.lookup
-- |Initial 'InterfaceEnv'.
initInterfaceEnv :: InterfaceEnv
initInterfaceEnv = Map.empty
-- |Lookup the 'Interface' for an imported module.
lookupInterface :: ModuleIdent -> InterfaceEnv -> Maybe Interface
lookupInterface = Map.lookup
......@@ -2,7 +2,7 @@
Module : $Header$
Description : Environment of module aliases
Copyright : (c) 2002 - 2004, Wolfgang Lux
2011 , Björn Peemöller
2011 - 2013, Björn Peemöller
License : OtherLicense
Maintainer : bjp@informatik.uni-kiel.de
......@@ -17,9 +17,7 @@
then @FM@ is an alias for @FiniteMap@, and @FiniteMap@ is aliased by @FM@.
-}
module Env.ModuleAlias
( AliasEnv, initAliasEnv, importAliases
) where
module Env.ModuleAlias ( AliasEnv, initAliasEnv, importAliases ) where
import qualified Data.Map as Map (Map, empty, insert)
import Data.Maybe (fromMaybe)
......@@ -27,7 +25,7 @@ import Data.Maybe (fromMaybe)
import Curry.Base.Ident (ModuleIdent)
import Curry.Syntax (ImportDecl (..))
-- |Mapping from original name to alias.
-- |Mapping from the original name of an imported module to its alias.
type AliasEnv = Map.Map ModuleIdent ModuleIdent
-- |Initial alias environment
......
......@@ -2,7 +2,7 @@
Module : $Header$
Description : Environment of operator precedences
Copyright : (c) 2002 - 2004, Wolfgang Lux
2011 , Björn Peemöller
2011 - 2013, Björn Peemöller
License : OtherLicense
Maintainer : bjp@informatik.uni-kiel.de
......@@ -23,17 +23,17 @@
for representing the precedence. This change had to be done due to the
introduction of unlimited integer constants in the parser / lexer.
-}
module Env.OpPrec
( OpPrecEnv, PrecInfo (..), OpPrec (..)
, defaultP, bindP, lookupP, qualLookupP, initOpPrecEnv
( OpPrec (..), defaultP
, OpPrecEnv, PrecInfo (..), bindP, lookupP, qualLookupP, initOpPrecEnv
) where
import Curry.Base.Ident
import Curry.Syntax (Infix (..))
import Curry.Syntax (Infix (..))
import Base.TopEnv
-- |Operator precedence.
data OpPrec = OpPrec Infix Integer deriving Eq
instance Show OpPrec where
......@@ -42,16 +42,28 @@ instance Show OpPrec where
assoc InfixR = "right "
assoc Infix = "non-assoc "
-- |Default operator precedence.
defaultP :: OpPrec
defaultP = OpPrec InfixL 9
-- |Precedence information for an identifier.
data PrecInfo = PrecInfo QualIdent OpPrec deriving (Eq, Show)
instance Entity PrecInfo where
origName (PrecInfo op _) = op
-- |Environment mapping identifiers to their operator precedence.
type OpPrecEnv = TopEnv PrecInfo
-- |Initial 'OpPrecEnv'.
initOpPrecEnv :: OpPrecEnv
initOpPrecEnv = predefTopEnv qConsId consPrec emptyTopEnv
-- |Precedence of list constructor.
consPrec :: PrecInfo
consPrec = PrecInfo qConsId (OpPrec InfixR 5)
-- |Bind an operator precedence.
bindP :: ModuleIdent -> Ident -> OpPrec -> OpPrecEnv -> OpPrecEnv
bindP m op p
| hasGlobalScope op = bindTopEnv fun op info . qualBindTopEnv fun qop info
......@@ -64,14 +76,10 @@ bindP m op p
-- precedences are simpler than for the type and value environments
-- because they do not need to handle tuple constructors.
-- |Lookup the operator precedence for an 'Ident'.
lookupP :: Ident -> OpPrecEnv -> [PrecInfo]
lookupP = lookupTopEnv
-- |Lookup the operator precedence for an 'QualIdent'.
qualLookupP :: QualIdent -> OpPrecEnv -> [PrecInfo]
qualLookupP = qualLookupTopEnv
initOpPrecEnv :: OpPrecEnv
initOpPrecEnv = predefTopEnv qConsId consPrec emptyTopEnv
consPrec :: PrecInfo
consPrec = PrecInfo qConsId (OpPrec InfixR 5)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment