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

Import converted to normal Haskell file

parent 7e9510a9
......@@ -3,21 +3,25 @@
> module Base.Import
> ( ImportEnv, bindAlias, lookupAlias, sureLookupAlias, initIEnv
> , fromDeclList
> ) where
> import qualified Data.Map as Map (Map, empty, insert, lookup)
> import Data.Maybe (fromMaybe)
> import Curry.Base.Ident
> import qualified Curry.Syntax as CS
> import Curry.Base.Ident (ModuleIdent)
> import qualified Curry.Syntax as CS (Decl (..))
> type ImportEnv = Map.Map ModuleIdent ModuleIdent
> bindAlias :: CS.Decl -> ImportEnv -> ImportEnv
> bindAlias (CS.ImportDecl _ mid _ mmid _)
> = Map.insert mid (fromMaybe mid mmid)
> bindAlias (CS.ImportDecl _ mid _ alias _)
> = Map.insert mid $ fromMaybe mid alias
> bindAlias _ = error "Base.bindAlias: no import declaration"
> fromDeclList :: [CS.Decl] -> ImportEnv
> fromDeclList = foldr bindAlias initIEnv
> lookupAlias :: ModuleIdent -> ImportEnv -> Maybe ModuleIdent
> lookupAlias = Map.lookup
......
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