{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE Safe #-}
module Cryptol.ModuleSystem.Interface (
Iface
, IfaceG(..)
, IfaceDecls(..)
, IfaceDecl(..)
, IfaceNames(..)
, ifModName
, emptyIface
, ifacePrimMap
, ifaceForgetName
, ifaceIsFunctor
, filterIfaceDecls
, ifaceDeclsNames
, ifaceOrigNameMap
) where
import Data.Set(Set)
import qualified Data.Set as Set
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Semigroup
import Data.Text (Text)
import GHC.Generics (Generic)
import Control.DeepSeq
import Prelude ()
import Prelude.Compat
import Cryptol.ModuleSystem.Name
import Cryptol.Utils.Ident (ModName, OrigName(..))
import Cryptol.Utils.Panic(panic)
import Cryptol.Utils.Fixity(Fixity)
import Cryptol.Parser.AST(Pragma)
import Cryptol.TypeCheck.Type
type Iface = IfaceG ModName
data IfaceG name = Iface
{ forall name. IfaceG name -> IfaceNames name
ifNames :: IfaceNames name
, forall name. IfaceG name -> FunctorParams
ifParams :: FunctorParams
, forall name. IfaceG name -> IfaceDecls
ifDefines :: IfaceDecls
} deriving (Int -> IfaceG name -> ShowS
forall name. Show name => Int -> IfaceG name -> ShowS
forall name. Show name => [IfaceG name] -> ShowS
forall name. Show name => IfaceG name -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IfaceG name] -> ShowS
$cshowList :: forall name. Show name => [IfaceG name] -> ShowS
show :: IfaceG name -> String
$cshow :: forall name. Show name => IfaceG name -> String
showsPrec :: Int -> IfaceG name -> ShowS
$cshowsPrec :: forall name. Show name => Int -> IfaceG name -> ShowS
Show, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall name x. Rep (IfaceG name) x -> IfaceG name
forall name x. IfaceG name -> Rep (IfaceG name) x
$cto :: forall name x. Rep (IfaceG name) x -> IfaceG name
$cfrom :: forall name x. IfaceG name -> Rep (IfaceG name) x
Generic, forall name. NFData name => IfaceG name -> ()
forall a. (a -> ()) -> NFData a
rnf :: IfaceG name -> ()
$crnf :: forall name. NFData name => IfaceG name -> ()
NFData)
ifaceForgetName :: IfaceG name -> IfaceG ()
ifaceForgetName :: forall name. IfaceG name -> IfaceG ()
ifaceForgetName IfaceG name
i = IfaceG name
i { ifNames :: IfaceNames ()
ifNames = IfaceNames ()
newNames }
where newNames :: IfaceNames ()
newNames = (forall name. IfaceG name -> IfaceNames name
ifNames IfaceG name
i) { ifsName :: ()
ifsName = () }
ifModName :: IfaceG name -> name
ifModName :: forall name. IfaceG name -> name
ifModName = forall name. IfaceNames name -> name
ifsName forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall name. IfaceG name -> IfaceNames name
ifNames
data IfaceNames name = IfaceNames
{ forall name. IfaceNames name -> name
ifsName :: name
, forall name. IfaceNames name -> Set Name
ifsNested :: Set Name
, forall name. IfaceNames name -> Set Name
ifsDefines :: Set Name
, forall name. IfaceNames name -> Set Name
ifsPublic :: Set Name
, forall name. IfaceNames name -> Maybe Text
ifsDoc :: !(Maybe Text)
} deriving (Int -> IfaceNames name -> ShowS
forall name. Show name => Int -> IfaceNames name -> ShowS
forall name. Show name => [IfaceNames name] -> ShowS
forall name. Show name => IfaceNames name -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IfaceNames name] -> ShowS
$cshowList :: forall name. Show name => [IfaceNames name] -> ShowS
show :: IfaceNames name -> String
$cshow :: forall name. Show name => IfaceNames name -> String
showsPrec :: Int -> IfaceNames name -> ShowS
$cshowsPrec :: forall name. Show name => Int -> IfaceNames name -> ShowS
Show, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall name x. Rep (IfaceNames name) x -> IfaceNames name
forall name x. IfaceNames name -> Rep (IfaceNames name) x
$cto :: forall name x. Rep (IfaceNames name) x -> IfaceNames name
$cfrom :: forall name x. IfaceNames name -> Rep (IfaceNames name) x
Generic, forall name. NFData name => IfaceNames name -> ()
forall a. (a -> ()) -> NFData a
rnf :: IfaceNames name -> ()
$crnf :: forall name. NFData name => IfaceNames name -> ()
NFData)
ifaceIsFunctor :: IfaceG name -> Bool
ifaceIsFunctor :: forall name. IfaceG name -> Bool
ifaceIsFunctor = Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Map k a -> Bool
Map.null forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall name. IfaceG name -> FunctorParams
ifParams
emptyIface :: ModName -> Iface
emptyIface :: ModName -> Iface
emptyIface ModName
nm = Iface
{ ifNames :: IfaceNames ModName
ifNames = IfaceNames { ifsName :: ModName
ifsName = ModName
nm
, ifsDefines :: Set Name
ifsDefines = forall a. Monoid a => a
mempty
, ifsPublic :: Set Name
ifsPublic = forall a. Monoid a => a
mempty
, ifsNested :: Set Name
ifsNested = forall a. Monoid a => a
mempty
, ifsDoc :: Maybe Text
ifsDoc = forall a. Maybe a
Nothing
}
, ifParams :: FunctorParams
ifParams = forall a. Monoid a => a
mempty
, ifDefines :: IfaceDecls
ifDefines = forall a. Monoid a => a
mempty
}
data IfaceDecls = IfaceDecls
{ IfaceDecls -> Map Name TySyn
ifTySyns :: Map.Map Name TySyn
, IfaceDecls -> Map Name Newtype
ifNewtypes :: Map.Map Name Newtype
, IfaceDecls -> Map Name AbstractType
ifAbstractTypes :: Map.Map Name AbstractType
, IfaceDecls -> Map Name IfaceDecl
ifDecls :: Map.Map Name IfaceDecl
, IfaceDecls -> Map Name (IfaceNames Name)
ifModules :: !(Map.Map Name (IfaceNames Name))
, IfaceDecls -> Map Name ModParamNames
ifSignatures :: !(Map.Map Name ModParamNames)
, IfaceDecls -> Map Name (IfaceG Name)
ifFunctors :: !(Map.Map Name (IfaceG Name))
} deriving (Int -> IfaceDecls -> ShowS
[IfaceDecls] -> ShowS
IfaceDecls -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IfaceDecls] -> ShowS
$cshowList :: [IfaceDecls] -> ShowS
show :: IfaceDecls -> String
$cshow :: IfaceDecls -> String
showsPrec :: Int -> IfaceDecls -> ShowS
$cshowsPrec :: Int -> IfaceDecls -> ShowS
Show, forall x. Rep IfaceDecls x -> IfaceDecls
forall x. IfaceDecls -> Rep IfaceDecls x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IfaceDecls x -> IfaceDecls
$cfrom :: forall x. IfaceDecls -> Rep IfaceDecls x
Generic, IfaceDecls -> ()
forall a. (a -> ()) -> NFData a
rnf :: IfaceDecls -> ()
$crnf :: IfaceDecls -> ()
NFData)
filterIfaceDecls :: (Name -> Bool) -> IfaceDecls -> IfaceDecls
filterIfaceDecls :: (Name -> Bool) -> IfaceDecls -> IfaceDecls
filterIfaceDecls Name -> Bool
p IfaceDecls
ifs = IfaceDecls
{ ifTySyns :: Map Name TySyn
ifTySyns = forall a. Map Name a -> Map Name a
filterMap (IfaceDecls -> Map Name TySyn
ifTySyns IfaceDecls
ifs)
, ifNewtypes :: Map Name Newtype
ifNewtypes = forall a. Map Name a -> Map Name a
filterMap (IfaceDecls -> Map Name Newtype
ifNewtypes IfaceDecls
ifs)
, ifAbstractTypes :: Map Name AbstractType
ifAbstractTypes = forall a. Map Name a -> Map Name a
filterMap (IfaceDecls -> Map Name AbstractType
ifAbstractTypes IfaceDecls
ifs)
, ifDecls :: Map Name IfaceDecl
ifDecls = forall a. Map Name a -> Map Name a
filterMap (IfaceDecls -> Map Name IfaceDecl
ifDecls IfaceDecls
ifs)
, ifModules :: Map Name (IfaceNames Name)
ifModules = forall a. Map Name a -> Map Name a
filterMap (IfaceDecls -> Map Name (IfaceNames Name)
ifModules IfaceDecls
ifs)
, ifFunctors :: Map Name (IfaceG Name)
ifFunctors = forall a. Map Name a -> Map Name a
filterMap (IfaceDecls -> Map Name (IfaceG Name)
ifFunctors IfaceDecls
ifs)
, ifSignatures :: Map Name ModParamNames
ifSignatures = forall a. Map Name a -> Map Name a
filterMap (IfaceDecls -> Map Name ModParamNames
ifSignatures IfaceDecls
ifs)
}
where
filterMap :: Map.Map Name a -> Map.Map Name a
filterMap :: forall a. Map Name a -> Map Name a
filterMap = forall k a. (k -> a -> Bool) -> Map k a -> Map k a
Map.filterWithKey (\Name
k a
_ -> Name -> Bool
p Name
k)
ifaceDeclsNames :: IfaceDecls -> Set Name
ifaceDeclsNames :: IfaceDecls -> Set Name
ifaceDeclsNames IfaceDecls
i = forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions [ forall k a. Map k a -> Set k
Map.keysSet (IfaceDecls -> Map Name TySyn
ifTySyns IfaceDecls
i)
, forall k a. Map k a -> Set k
Map.keysSet (IfaceDecls -> Map Name Newtype
ifNewtypes IfaceDecls
i)
, forall k a. Map k a -> Set k
Map.keysSet (IfaceDecls -> Map Name AbstractType
ifAbstractTypes IfaceDecls
i)
, forall k a. Map k a -> Set k
Map.keysSet (IfaceDecls -> Map Name IfaceDecl
ifDecls IfaceDecls
i)
, forall k a. Map k a -> Set k
Map.keysSet (IfaceDecls -> Map Name (IfaceNames Name)
ifModules IfaceDecls
i)
, forall k a. Map k a -> Set k
Map.keysSet (IfaceDecls -> Map Name (IfaceG Name)
ifFunctors IfaceDecls
i)
, forall k a. Map k a -> Set k
Map.keysSet (IfaceDecls -> Map Name ModParamNames
ifSignatures IfaceDecls
i)
]
instance Semigroup IfaceDecls where
IfaceDecls
l <> :: IfaceDecls -> IfaceDecls -> IfaceDecls
<> IfaceDecls
r = IfaceDecls
{ ifTySyns :: Map Name TySyn
ifTySyns = forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union (IfaceDecls -> Map Name TySyn
ifTySyns IfaceDecls
l) (IfaceDecls -> Map Name TySyn
ifTySyns IfaceDecls
r)
, ifNewtypes :: Map Name Newtype
ifNewtypes = forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union (IfaceDecls -> Map Name Newtype
ifNewtypes IfaceDecls
l) (IfaceDecls -> Map Name Newtype
ifNewtypes IfaceDecls
r)
, ifAbstractTypes :: Map Name AbstractType
ifAbstractTypes = forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union (IfaceDecls -> Map Name AbstractType
ifAbstractTypes IfaceDecls
l) (IfaceDecls -> Map Name AbstractType
ifAbstractTypes IfaceDecls
r)
, ifDecls :: Map Name IfaceDecl
ifDecls = forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union (IfaceDecls -> Map Name IfaceDecl
ifDecls IfaceDecls
l) (IfaceDecls -> Map Name IfaceDecl
ifDecls IfaceDecls
r)
, ifModules :: Map Name (IfaceNames Name)
ifModules = forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union (IfaceDecls -> Map Name (IfaceNames Name)
ifModules IfaceDecls
l) (IfaceDecls -> Map Name (IfaceNames Name)
ifModules IfaceDecls
r)
, ifFunctors :: Map Name (IfaceG Name)
ifFunctors = forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union (IfaceDecls -> Map Name (IfaceG Name)
ifFunctors IfaceDecls
l) (IfaceDecls -> Map Name (IfaceG Name)
ifFunctors IfaceDecls
r)
, ifSignatures :: Map Name ModParamNames
ifSignatures = IfaceDecls -> Map Name ModParamNames
ifSignatures IfaceDecls
l forall a. Semigroup a => a -> a -> a
<> IfaceDecls -> Map Name ModParamNames
ifSignatures IfaceDecls
r
}
instance Monoid IfaceDecls where
mempty :: IfaceDecls
mempty = IfaceDecls
{ ifTySyns :: Map Name TySyn
ifTySyns = forall a. Monoid a => a
mempty
, ifNewtypes :: Map Name Newtype
ifNewtypes = forall a. Monoid a => a
mempty
, ifAbstractTypes :: Map Name AbstractType
ifAbstractTypes = forall a. Monoid a => a
mempty
, ifDecls :: Map Name IfaceDecl
ifDecls = forall a. Monoid a => a
mempty
, ifModules :: Map Name (IfaceNames Name)
ifModules = forall a. Monoid a => a
mempty
, ifFunctors :: Map Name (IfaceG Name)
ifFunctors = forall a. Monoid a => a
mempty
, ifSignatures :: Map Name ModParamNames
ifSignatures = forall a. Monoid a => a
mempty
}
mappend :: IfaceDecls -> IfaceDecls -> IfaceDecls
mappend = forall a. Semigroup a => a -> a -> a
(<>)
mconcat :: [IfaceDecls] -> IfaceDecls
mconcat [IfaceDecls]
ds = IfaceDecls
{ ifTySyns :: Map Name TySyn
ifTySyns = forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
Map.unions (forall a b. (a -> b) -> [a] -> [b]
map IfaceDecls -> Map Name TySyn
ifTySyns [IfaceDecls]
ds)
, ifNewtypes :: Map Name Newtype
ifNewtypes = forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
Map.unions (forall a b. (a -> b) -> [a] -> [b]
map IfaceDecls -> Map Name Newtype
ifNewtypes [IfaceDecls]
ds)
, ifAbstractTypes :: Map Name AbstractType
ifAbstractTypes = forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
Map.unions (forall a b. (a -> b) -> [a] -> [b]
map IfaceDecls -> Map Name AbstractType
ifAbstractTypes [IfaceDecls]
ds)
, ifDecls :: Map Name IfaceDecl
ifDecls = forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
Map.unions (forall a b. (a -> b) -> [a] -> [b]
map IfaceDecls -> Map Name IfaceDecl
ifDecls [IfaceDecls]
ds)
, ifModules :: Map Name (IfaceNames Name)
ifModules = forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
Map.unions (forall a b. (a -> b) -> [a] -> [b]
map IfaceDecls -> Map Name (IfaceNames Name)
ifModules [IfaceDecls]
ds)
, ifFunctors :: Map Name (IfaceG Name)
ifFunctors = forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
Map.unions (forall a b. (a -> b) -> [a] -> [b]
map IfaceDecls -> Map Name (IfaceG Name)
ifFunctors [IfaceDecls]
ds)
, ifSignatures :: Map Name ModParamNames
ifSignatures = forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
Map.unions (forall a b. (a -> b) -> [a] -> [b]
map IfaceDecls -> Map Name ModParamNames
ifSignatures [IfaceDecls]
ds)
}
data IfaceDecl = IfaceDecl
{ IfaceDecl -> Name
ifDeclName :: !Name
, IfaceDecl -> Schema
ifDeclSig :: Schema
, IfaceDecl -> Bool
ifDeclIsPrim :: !Bool
, IfaceDecl -> [Pragma]
ifDeclPragmas :: [Pragma]
, IfaceDecl -> Bool
ifDeclInfix :: Bool
, IfaceDecl -> Maybe Fixity
ifDeclFixity :: Maybe Fixity
, IfaceDecl -> Maybe Text
ifDeclDoc :: Maybe Text
} deriving (Int -> IfaceDecl -> ShowS
[IfaceDecl] -> ShowS
IfaceDecl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IfaceDecl] -> ShowS
$cshowList :: [IfaceDecl] -> ShowS
show :: IfaceDecl -> String
$cshow :: IfaceDecl -> String
showsPrec :: Int -> IfaceDecl -> ShowS
$cshowsPrec :: Int -> IfaceDecl -> ShowS
Show, forall x. Rep IfaceDecl x -> IfaceDecl
forall x. IfaceDecl -> Rep IfaceDecl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IfaceDecl x -> IfaceDecl
$cfrom :: forall x. IfaceDecl -> Rep IfaceDecl x
Generic, IfaceDecl -> ()
forall a. (a -> ()) -> NFData a
rnf :: IfaceDecl -> ()
$crnf :: IfaceDecl -> ()
NFData)
ifacePrimMap :: Iface -> PrimMap
ifacePrimMap :: Iface -> PrimMap
ifacePrimMap = IfaceDecls -> PrimMap
ifaceDeclsPrimMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall name. IfaceG name -> IfaceDecls
ifDefines
ifaceDeclsPrimMap :: IfaceDecls -> PrimMap
ifaceDeclsPrimMap :: IfaceDecls -> PrimMap
ifaceDeclsPrimMap IfaceDecls { Map Name AbstractType
Map Name Newtype
Map Name TySyn
Map Name ModParamNames
Map Name IfaceDecl
Map Name (IfaceNames Name)
Map Name (IfaceG Name)
ifFunctors :: Map Name (IfaceG Name)
ifSignatures :: Map Name ModParamNames
ifModules :: Map Name (IfaceNames Name)
ifDecls :: Map Name IfaceDecl
ifAbstractTypes :: Map Name AbstractType
ifNewtypes :: Map Name Newtype
ifTySyns :: Map Name TySyn
ifFunctors :: IfaceDecls -> Map Name (IfaceG Name)
ifSignatures :: IfaceDecls -> Map Name ModParamNames
ifModules :: IfaceDecls -> Map Name (IfaceNames Name)
ifDecls :: IfaceDecls -> Map Name IfaceDecl
ifAbstractTypes :: IfaceDecls -> Map Name AbstractType
ifNewtypes :: IfaceDecls -> Map Name Newtype
ifTySyns :: IfaceDecls -> Map Name TySyn
.. } =
PrimMap { primDecls :: Map PrimIdent Name
primDecls = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(PrimIdent, Name)]
newtypes forall a. [a] -> [a] -> [a]
++ [(PrimIdent, Name)]
exprs)
, primTypes :: Map PrimIdent Name
primTypes = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(PrimIdent, Name)]
newtypes forall a. [a] -> [a] -> [a]
++ [(PrimIdent, Name)]
types)
}
where
entry :: Name -> (PrimIdent, Name)
entry Name
n = case Name -> Maybe PrimIdent
asPrim Name
n of
Just PrimIdent
pid -> (PrimIdent
pid,Name
n)
Maybe PrimIdent
Nothing ->
forall a. HasCallStack => String -> [String] -> a
panic String
"ifaceDeclsPrimMap"
[ String
"Top level name not declared in a module?"
, forall a. Show a => a -> String
show Name
n ]
newtypes :: [(PrimIdent, Name)]
newtypes = forall a b. (a -> b) -> [a] -> [b]
map Name -> (PrimIdent, Name)
entry (forall k a. Map k a -> [k]
Map.keys Map Name Newtype
ifNewtypes)
exprs :: [(PrimIdent, Name)]
exprs = forall a b. (a -> b) -> [a] -> [b]
map Name -> (PrimIdent, Name)
entry (forall k a. Map k a -> [k]
Map.keys Map Name IfaceDecl
ifDecls)
types :: [(PrimIdent, Name)]
types = forall a b. (a -> b) -> [a] -> [b]
map Name -> (PrimIdent, Name)
entry (forall k a. Map k a -> [k]
Map.keys Map Name TySyn
ifTySyns)
ifaceOrigNameMap :: IfaceG name -> Map Namespace (Map OrigName Name)
ifaceOrigNameMap :: forall name. IfaceG name -> Map Namespace (Map OrigName Name)
ifaceOrigNameMap IfaceG name
ifa = forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
(a -> a -> a) -> f (Map k a) -> Map k a
Map.unionsWith forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union (Map Namespace (Map OrigName Name)
here forall a. a -> [a] -> [a]
: [Map Namespace (Map OrigName Name)]
nested)
where
here :: Map Namespace (Map OrigName Name)
here = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList forall a b. (a -> b) -> a -> b
$
[ (Namespace
NSValue, Set Name -> Map OrigName Name
toMap Set Name
vaNames) | Bool -> Bool
not (forall a. Set a -> Bool
Set.null Set Name
vaNames) ] forall a. [a] -> [a] -> [a]
++
[ (Namespace
NSType, Set Name -> Map OrigName Name
toMap Set Name
tyNames) | Bool -> Bool
not (forall a. Set a -> Bool
Set.null Set Name
tyNames) ] forall a. [a] -> [a] -> [a]
++
[ (Namespace
NSValue, Set Name -> Map OrigName Name
toMap Set Name
moNames) | Bool -> Bool
not (forall a. Set a -> Bool
Set.null Set Name
moNames) ]
nested :: [Map Namespace (Map OrigName Name)]
nested = forall a b. (a -> b) -> [a] -> [b]
map forall name. IfaceG name -> Map Namespace (Map OrigName Name)
ifaceOrigNameMap (forall k a. Map k a -> [a]
Map.elems (IfaceDecls -> Map Name (IfaceG Name)
ifFunctors IfaceDecls
decls))
toMap :: Set Name -> Map OrigName Name
toMap Set Name
names = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (OrigName
og,Name
x) | Name
x <- forall a. Set a -> [a]
Set.toList Set Name
names, Just OrigName
og <- [ Name -> Maybe OrigName
asOrigName Name
x ] ]
decls :: IfaceDecls
decls = forall name. IfaceG name -> IfaceDecls
ifDefines IfaceG name
ifa
from :: (IfaceDecls -> Map k a) -> Set k
from IfaceDecls -> Map k a
f = forall k a. Map k a -> Set k
Map.keysSet (IfaceDecls -> Map k a
f IfaceDecls
decls)
tyNames :: Set Name
tyNames = forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions [ forall {k} {a}. (IfaceDecls -> Map k a) -> Set k
from IfaceDecls -> Map Name TySyn
ifTySyns, forall {k} {a}. (IfaceDecls -> Map k a) -> Set k
from IfaceDecls -> Map Name Newtype
ifNewtypes, forall {k} {a}. (IfaceDecls -> Map k a) -> Set k
from IfaceDecls -> Map Name AbstractType
ifAbstractTypes ]
moNames :: Set Name
moNames = forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions [ forall {k} {a}. (IfaceDecls -> Map k a) -> Set k
from IfaceDecls -> Map Name (IfaceNames Name)
ifModules, forall {k} {a}. (IfaceDecls -> Map k a) -> Set k
from IfaceDecls -> Map Name ModParamNames
ifSignatures, forall {k} {a}. (IfaceDecls -> Map k a) -> Set k
from IfaceDecls -> Map Name (IfaceG Name)
ifFunctors ]
vaNames :: Set Name
vaNames = forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions [ Set Name
newtypeCons, forall {k} {a}. (IfaceDecls -> Map k a) -> Set k
from IfaceDecls -> Map Name IfaceDecl
ifDecls ]
newtypeCons :: Set Name
newtypeCons = forall a. Ord a => [a] -> Set a
Set.fromList (forall a b. (a -> b) -> [a] -> [b]
map Newtype -> Name
ntConName (forall k a. Map k a -> [a]
Map.elems (IfaceDecls -> Map Name Newtype
ifNewtypes IfaceDecls
decls)))