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

Extended value and type constructor env with unique lookup function

parent 9080edff
......@@ -38,8 +38,8 @@
-}
module Env.TypeConstructor
( TCEnv, TypeInfo (..), tcArity, bindTypeInfo, lookupTC, qualLookupTC
, initTCEnv
( TCEnv, TypeInfo (..), initTCEnv, tcArity, bindTypeInfo
, lookupTC, qualLookupTC, qualLookupTCUnique
, TypeEnv, TypeKind (..), typeKind
) where
......@@ -99,6 +99,12 @@ qualLookupTC :: QualIdent -> TCEnv -> [TypeInfo]
qualLookupTC tc tcEnv = qualLookupTopEnv tc tcEnv
++! lookupTupleTC (unqualify tc)
qualLookupTCUnique :: ModuleIdent -> QualIdent -> TCEnv -> [TypeInfo]
qualLookupTCUnique m x tyEnv = case qualLookupTC x tyEnv of
[] -> []
[v] -> [v]
_ -> qualLookupTC (qualQualify m x) tyEnv
lookupTupleTC :: Ident -> [TypeInfo]
lookupTupleTC tc | isTupleId tc = [tupleTCs !! (tupleArity tc - 2)]
| otherwise = []
......
......@@ -25,7 +25,7 @@
module Env.Value
( ValueEnv, ValueInfo (..)
, bindGlobalInfo, bindFun, qualBindFun, rebindFun, unbindFun
, lookupValue, qualLookupValue
, lookupValue, qualLookupValue, qualLookupValueUnique
, initDCEnv, ppTypes
, conType
) where
......@@ -126,6 +126,12 @@ qualLookupValue :: QualIdent -> ValueEnv -> [ValueInfo]
qualLookupValue x tyEnv = qualLookupTopEnv x tyEnv
++! lookupTuple (unqualify x)
qualLookupValueUnique :: ModuleIdent -> QualIdent -> ValueEnv -> [ValueInfo]
qualLookupValueUnique m x tyEnv = case qualLookupValue x tyEnv of
[] -> []
[v] -> [v]
_ -> qualLookupValue (qualQualify m x) tyEnv
lookupTuple :: Ident -> [ValueInfo]
lookupTuple c | isTupleId c = [tupleDCs !! (tupleArity c - 2)]
| otherwise = []
......
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