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

Refactoring

parent f141d68a
-- % -*- LaTeX -*- {- |
-- % $Id: IntfEquiv.lhs 2148 2007-04-02 13:56:20Z wlux $ Module : $Header$
-- % Description : Comparison of Interfaces
-- % Copyright (c) 2000-2007, Wolfgang Lux Copyright : (c) 2000 - 2007, Wolfgang Lux
-- % See LICENSE for the full license. 2014 , Björn Peemöller
-- % License : OtherLicense
-- \nwfilename{IntfEquiv.lhs}
-- \section{Comparing Module Interfaces} Maintainer : bjp@informatik.uni-kiel.de
-- If a module is recompiled, the compiler has to check whether the Stability : experimental
-- interface file must be updated. This must be done if any exported Portability : portable
-- entity has been changed, or an export was removed or added. The
-- function \texttt{intfEquiv} checks whether two interfaces are If a module is recompiled, the compiler has to check whether the
-- equivalent, i.e., whether they define the same entities. interface file must be updated. This must be done if any exported
entity has been changed, or an export was removed or added. The
-- \textbf{Note:} There is deliberately no list instance for function 'intfEquiv' checks whether two interfaces are
-- \texttt{IntfEquiv} because the order of interface declarations is equivalent, i.e., whether they define the same entities.
-- irrelevant, whereas it is decisive for the constructor declarations
-- of a data type. By not providing a list instance, we cannot /Note: There is deliberately no list instance for
-- inadvertently mix up these cases. 'IntfEquiv' because the order of interface declarations is
-- \begin{verbatim} irrelevant, whereas it is decisive for the constructor declarations
of a data type. By not providing a list instance, we cannot
inadvertently mix up these cases.
-}
module InterfaceEquivalence (fixInterface, intfEquiv) where module InterfaceEquivalence (fixInterface, intfEquiv) where
import Data.List (deleteFirstsBy) import Data.List (deleteFirstsBy)
...@@ -27,10 +29,6 @@ import qualified Data.Set as Set ...@@ -27,10 +29,6 @@ import qualified Data.Set as Set
import Curry.Base.Ident import Curry.Base.Ident
import Curry.Syntax import Curry.Syntax
-- import Base
-- import List
-- import Set
infix 4 =~=, `eqvList`, `eqvSet` infix 4 =~=, `eqvList`, `eqvSet`
intfEquiv :: Interface -> Interface -> Bool intfEquiv :: Interface -> Interface -> Bool
...@@ -84,14 +82,10 @@ instance IntfEquiv NewConstrDecl where ...@@ -84,14 +82,10 @@ instance IntfEquiv NewConstrDecl where
NewConstrDecl _ evs1 c1 ty1 =~= NewConstrDecl _ evs2 c2 ty2 = NewConstrDecl _ evs1 c1 ty1 =~= NewConstrDecl _ evs2 c2 ty2 =
c1 == c2 && evs1 == evs2 && ty1 == ty2 c1 == c2 && evs1 == evs2 && ty1 == ty2
-- \end{verbatim}
-- If we check for a change in the interface, we do not need to check the -- If we check for a change in the interface, we do not need to check the
-- interface declarations, but still must disambiguate (nullary) type -- interface declarations, but still must disambiguate (nullary) type
-- constructors and type variables in type expressions. This is handled -- constructors and type variables in type expressions. This is handled
-- by function \texttt{fixInterface} and the associated type class -- by function 'fixInterface' and the associated type class 'FixInterface'.
-- \texttt{FixInterface}.
-- \begin{verbatim}
fixInterface :: Interface -> Interface fixInterface :: Interface -> Interface
fixInterface (Interface m is ds) = Interface m is $ fixInterface (Interface m is ds) = Interface m is $
fix (Set.fromList (typeConstructors ds)) ds fix (Set.fromList (typeConstructors ds)) ds
...@@ -137,8 +131,7 @@ instance FixInterface TypeExpr where ...@@ -137,8 +131,7 @@ instance FixInterface TypeExpr where
where fixField (lbl, ty) = (lbl, fix tcs ty) where fixField (lbl, ty) = (lbl, fix tcs ty)
typeConstructors :: [IDecl] -> [Ident] typeConstructors :: [IDecl] -> [Ident]
typeConstructors ds = typeConstructors ds = [tc | (QualIdent Nothing tc) <- foldr tyCons [] ds]
[tc | (QualIdent Nothing tc) <- foldr tyCons [] ds]
where tyCons (IInfixDecl _ _ _ _) tcs = tcs where tyCons (IInfixDecl _ _ _ _) tcs = tcs
tyCons (HidingDataDecl _ tc _) tcs = tc : tcs tyCons (HidingDataDecl _ tc _) tcs = tc : tcs
tyCons (IDataDecl _ tc _ _) tcs = tc : tcs tyCons (IDataDecl _ tc _ _) tcs = tc : tcs
...@@ -148,5 +141,3 @@ typeConstructors ds = ...@@ -148,5 +141,3 @@ typeConstructors ds =
isPrimTypeId :: QualIdent -> Bool isPrimTypeId :: QualIdent -> Bool
isPrimTypeId tc = tc `elem` [qUnitId, qListId] || isQTupleId tc isPrimTypeId tc = tc `elem` [qUnitId, qListId] || isQTupleId tc
-- \end{verbatim}
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
-} -}
module Modules module Modules
( compileModule, loadAndCheckModule, checkModuleHeader ( compileModule, loadAndCheckModule, loadModule, checkModule
, parseModule, checkModuleHeader
) where ) where
import qualified Control.Exception as C (catch, IOException) import qualified Control.Exception as C (catch, IOException)
......
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