Permalink
Browse files

Import lists.

  • Loading branch information...
1 parent 3bb0a0d commit 4aa418064e7108a497c68379d1969576f6e58c04 @marcotmarcot committed Oct 9, 2012
Showing with 25 additions and 1 deletion.
  1. +25 −1 src/Iface/IfaceDriver.hs
View
@@ -12,6 +12,7 @@ module Iface.IfaceDriver where
-- in a module to write / read and to
-- report error messages
+import Control.Applicative
import Data.List
import qualified Data.Map as Map
@@ -40,7 +41,30 @@ readIface :: FilePath -> ImportDecl -> IO Iface
readIface dir i
= do
let v = gen dir (importModule i)
- parseInterface v
+ filterIl (importSpecs i) <$> parseInterface v
+
+filterIl :: Maybe (Bool, [ImportSpec]) -> Iface -> Iface
+filterIl Nothing i = i
+filterIl
+ (Just (hid, is))
+ i@(Iface {synonyms = s, classes = c, assumps = a})
+ = i
+ {synonyms = doFilterIl hid is s,
+ classes = doFilterIl hid is c,
+ assumps = doFilterIl hid is a}
+
+doFilterIl :: ToId a => Bool -> [ImportSpec] -> [a] -> [a]
+doFilterIl hid is
+ = filter ((\x -> any (f x) $ map isToName is) . idToName . toId)
+ where
+ f :: Eq a => a -> a -> Bool
+ f
+ | hid = (/=)
+ | otherwise = (==)
+
+isToName :: ImportSpec -> Name
+isToName (IVar n) = n
+isToName (IAbs n) = n
-- write Iface file using the export list

0 comments on commit 4aa4180

Please sign in to comment.