{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE GADTs #-}
module Agda.Syntax.Scope.Base where
import Prelude hiding ( null )
import Control.Arrow (first, second)
import Control.Monad
import Data.Either (partitionEithers)
import Data.Function
import qualified Data.List as List
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NonEmpty
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Maybe
import qualified Data.Semigroup as Sgrp
import Data.Data (Data)
import Agda.Benchmarking
import Agda.Syntax.Position
import Agda.Syntax.Common
import Agda.Syntax.Fixity
import Agda.Syntax.Abstract.Name as A
import Agda.Syntax.Concrete.Name as C
import qualified Agda.Syntax.Concrete as C
import Agda.Syntax.Concrete.Fixity as C
import Agda.Utils.AssocList (AssocList)
import qualified Agda.Utils.AssocList as AssocList
import Agda.Utils.Functor
import Agda.Utils.Lens
import Agda.Utils.List
import Agda.Utils.Maybe (filterMaybe)
import Agda.Utils.Null
import Agda.Utils.Pretty
import Agda.Utils.Singleton
import qualified Agda.Utils.Map as Map
import Agda.Utils.Impossible
data Scope = Scope
{ Scope -> ModuleName
scopeName :: A.ModuleName
, Scope -> [ModuleName]
scopeParents :: [A.ModuleName]
, Scope -> ScopeNameSpaces
scopeNameSpaces :: ScopeNameSpaces
, Scope -> Map QName ModuleName
scopeImports :: Map C.QName A.ModuleName
, Scope -> Maybe DataOrRecord
scopeDatatypeModule :: Maybe DataOrRecord
}
deriving (Typeable Scope
DataType
Constr
Typeable Scope
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Scope -> c Scope)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Scope)
-> (Scope -> Constr)
-> (Scope -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Scope))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Scope))
-> ((forall b. Data b => b -> b) -> Scope -> Scope)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Scope -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Scope -> r)
-> (forall u. (forall d. Data d => d -> u) -> Scope -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Scope -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Scope -> m Scope)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Scope -> m Scope)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Scope -> m Scope)
-> Data Scope
Scope -> DataType
Scope -> Constr
(forall b. Data b => b -> b) -> Scope -> Scope
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Scope -> c Scope
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Scope
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Scope -> u
forall u. (forall d. Data d => d -> u) -> Scope -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Scope -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Scope -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Scope -> m Scope
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Scope -> m Scope
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Scope
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Scope -> c Scope
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Scope)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Scope)
$cScope :: Constr
$tScope :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Scope -> m Scope
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Scope -> m Scope
gmapMp :: (forall d. Data d => d -> m d) -> Scope -> m Scope
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Scope -> m Scope
gmapM :: (forall d. Data d => d -> m d) -> Scope -> m Scope
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Scope -> m Scope
gmapQi :: Int -> (forall d. Data d => d -> u) -> Scope -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Scope -> u
gmapQ :: (forall d. Data d => d -> u) -> Scope -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Scope -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Scope -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Scope -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Scope -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Scope -> r
gmapT :: (forall b. Data b => b -> b) -> Scope -> Scope
$cgmapT :: (forall b. Data b => b -> b) -> Scope -> Scope
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Scope)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Scope)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Scope)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Scope)
dataTypeOf :: Scope -> DataType
$cdataTypeOf :: Scope -> DataType
toConstr :: Scope -> Constr
$ctoConstr :: Scope -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Scope
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Scope
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Scope -> c Scope
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Scope -> c Scope
$cp1Data :: Typeable Scope
Data, Scope -> Scope -> Bool
(Scope -> Scope -> Bool) -> (Scope -> Scope -> Bool) -> Eq Scope
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Scope -> Scope -> Bool
$c/= :: Scope -> Scope -> Bool
== :: Scope -> Scope -> Bool
$c== :: Scope -> Scope -> Bool
Eq, Int -> Scope -> ShowS
[Scope] -> ShowS
Scope -> String
(Int -> Scope -> ShowS)
-> (Scope -> String) -> ([Scope] -> ShowS) -> Show Scope
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Scope] -> ShowS
$cshowList :: [Scope] -> ShowS
show :: Scope -> String
$cshow :: Scope -> String
showsPrec :: Int -> Scope -> ShowS
$cshowsPrec :: Int -> Scope -> ShowS
Show)
data NameSpaceId
= PrivateNS
| PublicNS
| ImportedNS
deriving (Typeable NameSpaceId
DataType
Constr
Typeable NameSpaceId
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpaceId -> c NameSpaceId)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpaceId)
-> (NameSpaceId -> Constr)
-> (NameSpaceId -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameSpaceId))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameSpaceId))
-> ((forall b. Data b => b -> b) -> NameSpaceId -> NameSpaceId)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpaceId -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpaceId -> r)
-> (forall u. (forall d. Data d => d -> u) -> NameSpaceId -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> NameSpaceId -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId)
-> Data NameSpaceId
NameSpaceId -> DataType
NameSpaceId -> Constr
(forall b. Data b => b -> b) -> NameSpaceId -> NameSpaceId
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpaceId -> c NameSpaceId
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpaceId
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> NameSpaceId -> u
forall u. (forall d. Data d => d -> u) -> NameSpaceId -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpaceId -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpaceId -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpaceId
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpaceId -> c NameSpaceId
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameSpaceId)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameSpaceId)
$cImportedNS :: Constr
$cPublicNS :: Constr
$cPrivateNS :: Constr
$tNameSpaceId :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId
gmapMp :: (forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId
gmapM :: (forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameSpaceId -> m NameSpaceId
gmapQi :: Int -> (forall d. Data d => d -> u) -> NameSpaceId -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NameSpaceId -> u
gmapQ :: (forall d. Data d => d -> u) -> NameSpaceId -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NameSpaceId -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpaceId -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpaceId -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpaceId -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpaceId -> r
gmapT :: (forall b. Data b => b -> b) -> NameSpaceId -> NameSpaceId
$cgmapT :: (forall b. Data b => b -> b) -> NameSpaceId -> NameSpaceId
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameSpaceId)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameSpaceId)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NameSpaceId)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameSpaceId)
dataTypeOf :: NameSpaceId -> DataType
$cdataTypeOf :: NameSpaceId -> DataType
toConstr :: NameSpaceId -> Constr
$ctoConstr :: NameSpaceId -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpaceId
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpaceId
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpaceId -> c NameSpaceId
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpaceId -> c NameSpaceId
$cp1Data :: Typeable NameSpaceId
Data, NameSpaceId -> NameSpaceId -> Bool
(NameSpaceId -> NameSpaceId -> Bool)
-> (NameSpaceId -> NameSpaceId -> Bool) -> Eq NameSpaceId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NameSpaceId -> NameSpaceId -> Bool
$c/= :: NameSpaceId -> NameSpaceId -> Bool
== :: NameSpaceId -> NameSpaceId -> Bool
$c== :: NameSpaceId -> NameSpaceId -> Bool
Eq, NameSpaceId
NameSpaceId -> NameSpaceId -> Bounded NameSpaceId
forall a. a -> a -> Bounded a
maxBound :: NameSpaceId
$cmaxBound :: NameSpaceId
minBound :: NameSpaceId
$cminBound :: NameSpaceId
Bounded, Int -> NameSpaceId
NameSpaceId -> Int
NameSpaceId -> [NameSpaceId]
NameSpaceId -> NameSpaceId
NameSpaceId -> NameSpaceId -> [NameSpaceId]
NameSpaceId -> NameSpaceId -> NameSpaceId -> [NameSpaceId]
(NameSpaceId -> NameSpaceId)
-> (NameSpaceId -> NameSpaceId)
-> (Int -> NameSpaceId)
-> (NameSpaceId -> Int)
-> (NameSpaceId -> [NameSpaceId])
-> (NameSpaceId -> NameSpaceId -> [NameSpaceId])
-> (NameSpaceId -> NameSpaceId -> [NameSpaceId])
-> (NameSpaceId -> NameSpaceId -> NameSpaceId -> [NameSpaceId])
-> Enum NameSpaceId
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: NameSpaceId -> NameSpaceId -> NameSpaceId -> [NameSpaceId]
$cenumFromThenTo :: NameSpaceId -> NameSpaceId -> NameSpaceId -> [NameSpaceId]
enumFromTo :: NameSpaceId -> NameSpaceId -> [NameSpaceId]
$cenumFromTo :: NameSpaceId -> NameSpaceId -> [NameSpaceId]
enumFromThen :: NameSpaceId -> NameSpaceId -> [NameSpaceId]
$cenumFromThen :: NameSpaceId -> NameSpaceId -> [NameSpaceId]
enumFrom :: NameSpaceId -> [NameSpaceId]
$cenumFrom :: NameSpaceId -> [NameSpaceId]
fromEnum :: NameSpaceId -> Int
$cfromEnum :: NameSpaceId -> Int
toEnum :: Int -> NameSpaceId
$ctoEnum :: Int -> NameSpaceId
pred :: NameSpaceId -> NameSpaceId
$cpred :: NameSpaceId -> NameSpaceId
succ :: NameSpaceId -> NameSpaceId
$csucc :: NameSpaceId -> NameSpaceId
Enum, Int -> NameSpaceId -> ShowS
[NameSpaceId] -> ShowS
NameSpaceId -> String
(Int -> NameSpaceId -> ShowS)
-> (NameSpaceId -> String)
-> ([NameSpaceId] -> ShowS)
-> Show NameSpaceId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NameSpaceId] -> ShowS
$cshowList :: [NameSpaceId] -> ShowS
show :: NameSpaceId -> String
$cshow :: NameSpaceId -> String
showsPrec :: Int -> NameSpaceId -> ShowS
$cshowsPrec :: Int -> NameSpaceId -> ShowS
Show)
allNameSpaces :: [NameSpaceId]
allNameSpaces :: [NameSpaceId]
allNameSpaces = [NameSpaceId
forall a. Bounded a => a
minBound..NameSpaceId
forall a. Bounded a => a
maxBound]
type ScopeNameSpaces = [(NameSpaceId, NameSpace)]
localNameSpace :: Access -> NameSpaceId
localNameSpace :: Access -> NameSpaceId
localNameSpace Access
PublicAccess = NameSpaceId
PublicNS
localNameSpace PrivateAccess{} = NameSpaceId
PrivateNS
nameSpaceAccess :: NameSpaceId -> Access
nameSpaceAccess :: NameSpaceId -> Access
nameSpaceAccess NameSpaceId
PrivateNS = Origin -> Access
PrivateAccess Origin
Inserted
nameSpaceAccess NameSpaceId
_ = Access
PublicAccess
scopeNameSpace :: NameSpaceId -> Scope -> NameSpace
scopeNameSpace :: NameSpaceId -> Scope -> NameSpace
scopeNameSpace NameSpaceId
ns = NameSpace -> Maybe NameSpace -> NameSpace
forall a. a -> Maybe a -> a
fromMaybe NameSpace
forall a. HasCallStack => a
__IMPOSSIBLE__ (Maybe NameSpace -> NameSpace)
-> (Scope -> Maybe NameSpace) -> Scope -> NameSpace
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpaceId -> ScopeNameSpaces -> Maybe NameSpace
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup NameSpaceId
ns (ScopeNameSpaces -> Maybe NameSpace)
-> (Scope -> ScopeNameSpaces) -> Scope -> Maybe NameSpace
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Scope -> ScopeNameSpaces
scopeNameSpaces
updateScopeNameSpaces :: (ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope
updateScopeNameSpaces :: (ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope
updateScopeNameSpaces ScopeNameSpaces -> ScopeNameSpaces
f Scope
s = Scope
s { scopeNameSpaces :: ScopeNameSpaces
scopeNameSpaces = ScopeNameSpaces -> ScopeNameSpaces
f (Scope -> ScopeNameSpaces
scopeNameSpaces Scope
s) }
updateScopeNameSpacesM ::
(Functor m) => (ScopeNameSpaces -> m ScopeNameSpaces) -> Scope -> m Scope
updateScopeNameSpacesM :: (ScopeNameSpaces -> m ScopeNameSpaces) -> Scope -> m Scope
updateScopeNameSpacesM ScopeNameSpaces -> m ScopeNameSpaces
f Scope
s = m ScopeNameSpaces -> (ScopeNameSpaces -> Scope) -> m Scope
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
for (ScopeNameSpaces -> m ScopeNameSpaces
f (ScopeNameSpaces -> m ScopeNameSpaces)
-> ScopeNameSpaces -> m ScopeNameSpaces
forall a b. (a -> b) -> a -> b
$ Scope -> ScopeNameSpaces
scopeNameSpaces Scope
s) ((ScopeNameSpaces -> Scope) -> m Scope)
-> (ScopeNameSpaces -> Scope) -> m Scope
forall a b. (a -> b) -> a -> b
$ \ ScopeNameSpaces
x ->
Scope
s { scopeNameSpaces :: ScopeNameSpaces
scopeNameSpaces = ScopeNameSpaces
x }
data ScopeInfo = ScopeInfo
{ ScopeInfo -> ModuleName
_scopeCurrent :: A.ModuleName
, ScopeInfo -> Map ModuleName Scope
_scopeModules :: Map A.ModuleName Scope
, ScopeInfo -> LocalVars
_scopeVarsToBind :: LocalVars
, ScopeInfo -> LocalVars
_scopeLocals :: LocalVars
, ScopeInfo -> PrecedenceStack
_scopePrecedence :: PrecedenceStack
, ScopeInfo -> NameMap
_scopeInverseName :: NameMap
, ScopeInfo -> ModuleMap
_scopeInverseModule :: ModuleMap
, ScopeInfo -> InScopeSet
_scopeInScope :: InScopeSet
, ScopeInfo -> Fixities
_scopeFixities :: C.Fixities
, ScopeInfo -> Polarities
_scopePolarities :: C.Polarities
}
deriving (Typeable ScopeInfo
DataType
Constr
Typeable ScopeInfo
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ScopeInfo -> c ScopeInfo)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ScopeInfo)
-> (ScopeInfo -> Constr)
-> (ScopeInfo -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ScopeInfo))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ScopeInfo))
-> ((forall b. Data b => b -> b) -> ScopeInfo -> ScopeInfo)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ScopeInfo -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ScopeInfo -> r)
-> (forall u. (forall d. Data d => d -> u) -> ScopeInfo -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> ScopeInfo -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo)
-> Data ScopeInfo
ScopeInfo -> DataType
ScopeInfo -> Constr
(forall b. Data b => b -> b) -> ScopeInfo -> ScopeInfo
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ScopeInfo -> c ScopeInfo
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ScopeInfo
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ScopeInfo -> u
forall u. (forall d. Data d => d -> u) -> ScopeInfo -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ScopeInfo -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ScopeInfo -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ScopeInfo
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ScopeInfo -> c ScopeInfo
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ScopeInfo)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ScopeInfo)
$cScopeInfo :: Constr
$tScopeInfo :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo
gmapMp :: (forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo
gmapM :: (forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ScopeInfo -> m ScopeInfo
gmapQi :: Int -> (forall d. Data d => d -> u) -> ScopeInfo -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ScopeInfo -> u
gmapQ :: (forall d. Data d => d -> u) -> ScopeInfo -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ScopeInfo -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ScopeInfo -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ScopeInfo -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ScopeInfo -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ScopeInfo -> r
gmapT :: (forall b. Data b => b -> b) -> ScopeInfo -> ScopeInfo
$cgmapT :: (forall b. Data b => b -> b) -> ScopeInfo -> ScopeInfo
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ScopeInfo)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ScopeInfo)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ScopeInfo)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ScopeInfo)
dataTypeOf :: ScopeInfo -> DataType
$cdataTypeOf :: ScopeInfo -> DataType
toConstr :: ScopeInfo -> Constr
$ctoConstr :: ScopeInfo -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ScopeInfo
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ScopeInfo
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ScopeInfo -> c ScopeInfo
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ScopeInfo -> c ScopeInfo
$cp1Data :: Typeable ScopeInfo
Data, Int -> ScopeInfo -> ShowS
[ScopeInfo] -> ShowS
ScopeInfo -> String
(Int -> ScopeInfo -> ShowS)
-> (ScopeInfo -> String)
-> ([ScopeInfo] -> ShowS)
-> Show ScopeInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScopeInfo] -> ShowS
$cshowList :: [ScopeInfo] -> ShowS
show :: ScopeInfo -> String
$cshow :: ScopeInfo -> String
showsPrec :: Int -> ScopeInfo -> ShowS
$cshowsPrec :: Int -> ScopeInfo -> ShowS
Show)
type NameMap = Map A.QName (NonEmpty C.QName)
type ModuleMap = Map A.ModuleName [C.QName]
instance Eq ScopeInfo where
ScopeInfo ModuleName
c1 Map ModuleName Scope
m1 LocalVars
v1 LocalVars
l1 PrecedenceStack
p1 NameMap
_ ModuleMap
_ InScopeSet
_ Fixities
_ Polarities
_ == :: ScopeInfo -> ScopeInfo -> Bool
== ScopeInfo ModuleName
c2 Map ModuleName Scope
m2 LocalVars
v2 LocalVars
l2 PrecedenceStack
p2 NameMap
_ ModuleMap
_ InScopeSet
_ Fixities
_ Polarities
_ =
ModuleName
c1 ModuleName -> ModuleName -> Bool
forall a. Eq a => a -> a -> Bool
== ModuleName
c2 Bool -> Bool -> Bool
&& Map ModuleName Scope
m1 Map ModuleName Scope -> Map ModuleName Scope -> Bool
forall a. Eq a => a -> a -> Bool
== Map ModuleName Scope
m2 Bool -> Bool -> Bool
&& LocalVars
v1 LocalVars -> LocalVars -> Bool
forall a. Eq a => a -> a -> Bool
== LocalVars
v2 Bool -> Bool -> Bool
&& LocalVars
l1 LocalVars -> LocalVars -> Bool
forall a. Eq a => a -> a -> Bool
== LocalVars
l2 Bool -> Bool -> Bool
&& PrecedenceStack
p1 PrecedenceStack -> PrecedenceStack -> Bool
forall a. Eq a => a -> a -> Bool
== PrecedenceStack
p2
type LocalVars = AssocList C.Name LocalVar
data BindingSource
= LambdaBound
| PatternBound
| LetBound
deriving (Typeable BindingSource
DataType
Constr
Typeable BindingSource
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BindingSource -> c BindingSource)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BindingSource)
-> (BindingSource -> Constr)
-> (BindingSource -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BindingSource))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BindingSource))
-> ((forall b. Data b => b -> b) -> BindingSource -> BindingSource)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BindingSource -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BindingSource -> r)
-> (forall u. (forall d. Data d => d -> u) -> BindingSource -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> BindingSource -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BindingSource -> m BindingSource)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BindingSource -> m BindingSource)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BindingSource -> m BindingSource)
-> Data BindingSource
BindingSource -> DataType
BindingSource -> Constr
(forall b. Data b => b -> b) -> BindingSource -> BindingSource
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BindingSource -> c BindingSource
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BindingSource
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BindingSource -> u
forall u. (forall d. Data d => d -> u) -> BindingSource -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BindingSource -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BindingSource -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BindingSource -> m BindingSource
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BindingSource -> m BindingSource
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BindingSource
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BindingSource -> c BindingSource
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BindingSource)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BindingSource)
$cLetBound :: Constr
$cPatternBound :: Constr
$cLambdaBound :: Constr
$tBindingSource :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> BindingSource -> m BindingSource
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BindingSource -> m BindingSource
gmapMp :: (forall d. Data d => d -> m d) -> BindingSource -> m BindingSource
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BindingSource -> m BindingSource
gmapM :: (forall d. Data d => d -> m d) -> BindingSource -> m BindingSource
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BindingSource -> m BindingSource
gmapQi :: Int -> (forall d. Data d => d -> u) -> BindingSource -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BindingSource -> u
gmapQ :: (forall d. Data d => d -> u) -> BindingSource -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BindingSource -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BindingSource -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BindingSource -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BindingSource -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BindingSource -> r
gmapT :: (forall b. Data b => b -> b) -> BindingSource -> BindingSource
$cgmapT :: (forall b. Data b => b -> b) -> BindingSource -> BindingSource
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BindingSource)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BindingSource)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c BindingSource)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BindingSource)
dataTypeOf :: BindingSource -> DataType
$cdataTypeOf :: BindingSource -> DataType
toConstr :: BindingSource -> Constr
$ctoConstr :: BindingSource -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BindingSource
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BindingSource
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BindingSource -> c BindingSource
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BindingSource -> c BindingSource
$cp1Data :: Typeable BindingSource
Data, Int -> BindingSource -> ShowS
[BindingSource] -> ShowS
BindingSource -> String
(Int -> BindingSource -> ShowS)
-> (BindingSource -> String)
-> ([BindingSource] -> ShowS)
-> Show BindingSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BindingSource] -> ShowS
$cshowList :: [BindingSource] -> ShowS
show :: BindingSource -> String
$cshow :: BindingSource -> String
showsPrec :: Int -> BindingSource -> ShowS
$cshowsPrec :: Int -> BindingSource -> ShowS
Show, BindingSource -> BindingSource -> Bool
(BindingSource -> BindingSource -> Bool)
-> (BindingSource -> BindingSource -> Bool) -> Eq BindingSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BindingSource -> BindingSource -> Bool
$c/= :: BindingSource -> BindingSource -> Bool
== :: BindingSource -> BindingSource -> Bool
$c== :: BindingSource -> BindingSource -> Bool
Eq)
data LocalVar = LocalVar
{ LocalVar -> Name
localVar :: A.Name
, LocalVar -> BindingSource
localBindingSource :: BindingSource
, LocalVar -> [AbstractName]
localShadowedBy :: [AbstractName]
}
deriving (Typeable LocalVar
DataType
Constr
Typeable LocalVar
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LocalVar -> c LocalVar)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LocalVar)
-> (LocalVar -> Constr)
-> (LocalVar -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LocalVar))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LocalVar))
-> ((forall b. Data b => b -> b) -> LocalVar -> LocalVar)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LocalVar -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LocalVar -> r)
-> (forall u. (forall d. Data d => d -> u) -> LocalVar -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> LocalVar -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> LocalVar -> m LocalVar)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LocalVar -> m LocalVar)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LocalVar -> m LocalVar)
-> Data LocalVar
LocalVar -> DataType
LocalVar -> Constr
(forall b. Data b => b -> b) -> LocalVar -> LocalVar
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LocalVar -> c LocalVar
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LocalVar
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> LocalVar -> u
forall u. (forall d. Data d => d -> u) -> LocalVar -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LocalVar -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LocalVar -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> LocalVar -> m LocalVar
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LocalVar -> m LocalVar
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LocalVar
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LocalVar -> c LocalVar
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LocalVar)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LocalVar)
$cLocalVar :: Constr
$tLocalVar :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> LocalVar -> m LocalVar
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LocalVar -> m LocalVar
gmapMp :: (forall d. Data d => d -> m d) -> LocalVar -> m LocalVar
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LocalVar -> m LocalVar
gmapM :: (forall d. Data d => d -> m d) -> LocalVar -> m LocalVar
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> LocalVar -> m LocalVar
gmapQi :: Int -> (forall d. Data d => d -> u) -> LocalVar -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> LocalVar -> u
gmapQ :: (forall d. Data d => d -> u) -> LocalVar -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> LocalVar -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LocalVar -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LocalVar -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LocalVar -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LocalVar -> r
gmapT :: (forall b. Data b => b -> b) -> LocalVar -> LocalVar
$cgmapT :: (forall b. Data b => b -> b) -> LocalVar -> LocalVar
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LocalVar)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LocalVar)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c LocalVar)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LocalVar)
dataTypeOf :: LocalVar -> DataType
$cdataTypeOf :: LocalVar -> DataType
toConstr :: LocalVar -> Constr
$ctoConstr :: LocalVar -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LocalVar
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LocalVar
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LocalVar -> c LocalVar
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LocalVar -> c LocalVar
$cp1Data :: Typeable LocalVar
Data, Int -> LocalVar -> ShowS
[LocalVar] -> ShowS
LocalVar -> String
(Int -> LocalVar -> ShowS)
-> (LocalVar -> String) -> ([LocalVar] -> ShowS) -> Show LocalVar
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LocalVar] -> ShowS
$cshowList :: [LocalVar] -> ShowS
show :: LocalVar -> String
$cshow :: LocalVar -> String
showsPrec :: Int -> LocalVar -> ShowS
$cshowsPrec :: Int -> LocalVar -> ShowS
Show)
instance Eq LocalVar where
== :: LocalVar -> LocalVar -> Bool
(==) = Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Name -> Name -> Bool)
-> (LocalVar -> Name) -> LocalVar -> LocalVar -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` LocalVar -> Name
localVar
instance Ord LocalVar where
compare :: LocalVar -> LocalVar -> Ordering
compare = Name -> Name -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Name -> Name -> Ordering)
-> (LocalVar -> Name) -> LocalVar -> LocalVar -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` LocalVar -> Name
localVar
instance Pretty LocalVar where
pretty :: LocalVar -> Doc
pretty (LocalVar Name
x BindingSource
_ []) = Name -> Doc
forall a. Pretty a => a -> Doc
pretty Name
x
pretty (LocalVar Name
x BindingSource
_ [AbstractName]
xs) = Doc
"." Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Name -> Doc
forall a. Pretty a => a -> Doc
pretty Name
x
shadowLocal :: [AbstractName] -> LocalVar -> LocalVar
shadowLocal :: [AbstractName] -> LocalVar -> LocalVar
shadowLocal [] LocalVar
_ = LocalVar
forall a. HasCallStack => a
__IMPOSSIBLE__
shadowLocal [AbstractName]
ys (LocalVar Name
x BindingSource
b [AbstractName]
zs) = Name -> BindingSource -> [AbstractName] -> LocalVar
LocalVar Name
x BindingSource
b ([AbstractName]
ys [AbstractName] -> [AbstractName] -> [AbstractName]
forall a. [a] -> [a] -> [a]
++ [AbstractName]
zs)
patternToModuleBound :: LocalVar -> LocalVar
patternToModuleBound :: LocalVar -> LocalVar
patternToModuleBound LocalVar
x
| LocalVar -> BindingSource
localBindingSource LocalVar
x BindingSource -> BindingSource -> Bool
forall a. Eq a => a -> a -> Bool
== BindingSource
PatternBound =
LocalVar
x { localBindingSource :: BindingSource
localBindingSource = BindingSource
LambdaBound }
| Bool
otherwise = LocalVar
x
notShadowedLocal :: LocalVar -> Maybe A.Name
notShadowedLocal :: LocalVar -> Maybe Name
notShadowedLocal (LocalVar Name
x BindingSource
_ []) = Name -> Maybe Name
forall a. a -> Maybe a
Just Name
x
notShadowedLocal LocalVar
_ = Maybe Name
forall a. Maybe a
Nothing
notShadowedLocals :: LocalVars -> AssocList C.Name A.Name
notShadowedLocals :: LocalVars -> AssocList Name Name
notShadowedLocals = ((Name, LocalVar) -> Maybe (Name, Name))
-> LocalVars -> AssocList Name Name
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (((Name, LocalVar) -> Maybe (Name, Name))
-> LocalVars -> AssocList Name Name)
-> ((Name, LocalVar) -> Maybe (Name, Name))
-> LocalVars
-> AssocList Name Name
forall a b. (a -> b) -> a -> b
$ \ (Name
c,LocalVar
x) -> (Name
c,) (Name -> (Name, Name)) -> Maybe Name -> Maybe (Name, Name)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LocalVar -> Maybe Name
notShadowedLocal LocalVar
x
scopeCurrent :: Lens' A.ModuleName ScopeInfo
scopeCurrent :: (ModuleName -> f ModuleName) -> ScopeInfo -> f ScopeInfo
scopeCurrent ModuleName -> f ModuleName
f ScopeInfo
s =
ModuleName -> f ModuleName
f (ScopeInfo -> ModuleName
_scopeCurrent ScopeInfo
s) f ModuleName -> (ModuleName -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\ModuleName
x -> ScopeInfo
s { _scopeCurrent :: ModuleName
_scopeCurrent = ModuleName
x }
scopeModules :: Lens' (Map A.ModuleName Scope) ScopeInfo
scopeModules :: (Map ModuleName Scope -> f (Map ModuleName Scope))
-> ScopeInfo -> f ScopeInfo
scopeModules Map ModuleName Scope -> f (Map ModuleName Scope)
f ScopeInfo
s =
Map ModuleName Scope -> f (Map ModuleName Scope)
f (ScopeInfo -> Map ModuleName Scope
_scopeModules ScopeInfo
s) f (Map ModuleName Scope)
-> (Map ModuleName Scope -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\Map ModuleName Scope
x -> ScopeInfo
s { _scopeModules :: Map ModuleName Scope
_scopeModules = Map ModuleName Scope
x }
scopeVarsToBind :: Lens' LocalVars ScopeInfo
scopeVarsToBind :: (LocalVars -> f LocalVars) -> ScopeInfo -> f ScopeInfo
scopeVarsToBind LocalVars -> f LocalVars
f ScopeInfo
s =
LocalVars -> f LocalVars
f (ScopeInfo -> LocalVars
_scopeVarsToBind ScopeInfo
s) f LocalVars -> (LocalVars -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\LocalVars
x -> ScopeInfo
s { _scopeVarsToBind :: LocalVars
_scopeVarsToBind = LocalVars
x }
scopeLocals :: Lens' LocalVars ScopeInfo
scopeLocals :: (LocalVars -> f LocalVars) -> ScopeInfo -> f ScopeInfo
scopeLocals LocalVars -> f LocalVars
f ScopeInfo
s =
LocalVars -> f LocalVars
f (ScopeInfo -> LocalVars
_scopeLocals ScopeInfo
s) f LocalVars -> (LocalVars -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\LocalVars
x -> ScopeInfo
s { _scopeLocals :: LocalVars
_scopeLocals = LocalVars
x }
scopePrecedence :: Lens' PrecedenceStack ScopeInfo
scopePrecedence :: (PrecedenceStack -> f PrecedenceStack) -> ScopeInfo -> f ScopeInfo
scopePrecedence PrecedenceStack -> f PrecedenceStack
f ScopeInfo
s =
PrecedenceStack -> f PrecedenceStack
f (ScopeInfo -> PrecedenceStack
_scopePrecedence ScopeInfo
s) f PrecedenceStack -> (PrecedenceStack -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\PrecedenceStack
x -> ScopeInfo
s { _scopePrecedence :: PrecedenceStack
_scopePrecedence = PrecedenceStack
x }
scopeInverseName :: Lens' NameMap ScopeInfo
scopeInverseName :: (NameMap -> f NameMap) -> ScopeInfo -> f ScopeInfo
scopeInverseName NameMap -> f NameMap
f ScopeInfo
s =
NameMap -> f NameMap
f (ScopeInfo -> NameMap
_scopeInverseName ScopeInfo
s) f NameMap -> (NameMap -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\NameMap
x -> ScopeInfo
s { _scopeInverseName :: NameMap
_scopeInverseName = NameMap
x }
scopeInverseModule :: Lens' ModuleMap ScopeInfo
scopeInverseModule :: (ModuleMap -> f ModuleMap) -> ScopeInfo -> f ScopeInfo
scopeInverseModule ModuleMap -> f ModuleMap
f ScopeInfo
s =
ModuleMap -> f ModuleMap
f (ScopeInfo -> ModuleMap
_scopeInverseModule ScopeInfo
s) f ModuleMap -> (ModuleMap -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\ModuleMap
x -> ScopeInfo
s { _scopeInverseModule :: ModuleMap
_scopeInverseModule = ModuleMap
x }
scopeInScope :: Lens' InScopeSet ScopeInfo
scopeInScope :: (InScopeSet -> f InScopeSet) -> ScopeInfo -> f ScopeInfo
scopeInScope InScopeSet -> f InScopeSet
f ScopeInfo
s =
InScopeSet -> f InScopeSet
f (ScopeInfo -> InScopeSet
_scopeInScope ScopeInfo
s) f InScopeSet -> (InScopeSet -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\InScopeSet
x -> ScopeInfo
s { _scopeInScope :: InScopeSet
_scopeInScope = InScopeSet
x }
scopeFixities :: Lens' C.Fixities ScopeInfo
scopeFixities :: (Fixities -> f Fixities) -> ScopeInfo -> f ScopeInfo
scopeFixities Fixities -> f Fixities
f ScopeInfo
s =
Fixities -> f Fixities
f (ScopeInfo -> Fixities
_scopeFixities ScopeInfo
s) f Fixities -> (Fixities -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\Fixities
x -> ScopeInfo
s { _scopeFixities :: Fixities
_scopeFixities = Fixities
x }
scopePolarities :: Lens' C.Polarities ScopeInfo
scopePolarities :: (Polarities -> f Polarities) -> ScopeInfo -> f ScopeInfo
scopePolarities Polarities -> f Polarities
f ScopeInfo
s =
Polarities -> f Polarities
f (ScopeInfo -> Polarities
_scopePolarities ScopeInfo
s) f Polarities -> (Polarities -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\Polarities
x -> ScopeInfo
s { _scopePolarities :: Polarities
_scopePolarities = Polarities
x }
scopeFixitiesAndPolarities :: Lens' (C.Fixities, C.Polarities) ScopeInfo
scopeFixitiesAndPolarities :: ((Fixities, Polarities) -> f (Fixities, Polarities))
-> ScopeInfo -> f ScopeInfo
scopeFixitiesAndPolarities (Fixities, Polarities) -> f (Fixities, Polarities)
f ScopeInfo
s =
Fixities -> Polarities -> f (Fixities, Polarities)
f' (ScopeInfo -> Fixities
_scopeFixities ScopeInfo
s) (ScopeInfo -> Polarities
_scopePolarities ScopeInfo
s) f (Fixities, Polarities)
-> ((Fixities, Polarities) -> ScopeInfo) -> f ScopeInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
\ (Fixities
fixs, Polarities
pols) -> ScopeInfo
s { _scopeFixities :: Fixities
_scopeFixities = Fixities
fixs, _scopePolarities :: Polarities
_scopePolarities = Polarities
pols }
where
f' :: Fixities -> Polarities -> f (Fixities, Polarities)
f' !Fixities
fixs !Polarities
pols = (Fixities, Polarities) -> f (Fixities, Polarities)
f (Fixities
fixs, Polarities
pols)
updateVarsToBind :: (LocalVars -> LocalVars) -> ScopeInfo -> ScopeInfo
updateVarsToBind :: (LocalVars -> LocalVars) -> ScopeInfo -> ScopeInfo
updateVarsToBind = Lens' LocalVars ScopeInfo
-> (LocalVars -> LocalVars) -> ScopeInfo -> ScopeInfo
forall i o. Lens' i o -> LensMap i o
over Lens' LocalVars ScopeInfo
scopeVarsToBind
setVarsToBind :: LocalVars -> ScopeInfo -> ScopeInfo
setVarsToBind :: LocalVars -> ScopeInfo -> ScopeInfo
setVarsToBind = Lens' LocalVars ScopeInfo -> LocalVars -> ScopeInfo -> ScopeInfo
forall i o. Lens' i o -> LensSet i o
set Lens' LocalVars ScopeInfo
scopeVarsToBind
updateScopeLocals :: (LocalVars -> LocalVars) -> ScopeInfo -> ScopeInfo
updateScopeLocals :: (LocalVars -> LocalVars) -> ScopeInfo -> ScopeInfo
updateScopeLocals = Lens' LocalVars ScopeInfo
-> (LocalVars -> LocalVars) -> ScopeInfo -> ScopeInfo
forall i o. Lens' i o -> LensMap i o
over Lens' LocalVars ScopeInfo
scopeLocals
setScopeLocals :: LocalVars -> ScopeInfo -> ScopeInfo
setScopeLocals :: LocalVars -> ScopeInfo -> ScopeInfo
setScopeLocals = Lens' LocalVars ScopeInfo -> LocalVars -> ScopeInfo -> ScopeInfo
forall i o. Lens' i o -> LensSet i o
set Lens' LocalVars ScopeInfo
scopeLocals
data NameSpace = NameSpace
{ NameSpace -> NamesInScope
nsNames :: NamesInScope
, NameSpace -> ModulesInScope
nsModules :: ModulesInScope
, NameSpace -> InScopeSet
nsInScope :: InScopeSet
}
deriving (Typeable NameSpace
DataType
Constr
Typeable NameSpace
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpace -> c NameSpace)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpace)
-> (NameSpace -> Constr)
-> (NameSpace -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameSpace))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameSpace))
-> ((forall b. Data b => b -> b) -> NameSpace -> NameSpace)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpace -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpace -> r)
-> (forall u. (forall d. Data d => d -> u) -> NameSpace -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> NameSpace -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameSpace -> m NameSpace)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpace -> m NameSpace)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpace -> m NameSpace)
-> Data NameSpace
NameSpace -> DataType
NameSpace -> Constr
(forall b. Data b => b -> b) -> NameSpace -> NameSpace
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpace -> c NameSpace
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpace
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> NameSpace -> u
forall u. (forall d. Data d => d -> u) -> NameSpace -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpace -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpace -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameSpace -> m NameSpace
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpace -> m NameSpace
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpace
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpace -> c NameSpace
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameSpace)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameSpace)
$cNameSpace :: Constr
$tNameSpace :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> NameSpace -> m NameSpace
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpace -> m NameSpace
gmapMp :: (forall d. Data d => d -> m d) -> NameSpace -> m NameSpace
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameSpace -> m NameSpace
gmapM :: (forall d. Data d => d -> m d) -> NameSpace -> m NameSpace
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameSpace -> m NameSpace
gmapQi :: Int -> (forall d. Data d => d -> u) -> NameSpace -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NameSpace -> u
gmapQ :: (forall d. Data d => d -> u) -> NameSpace -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NameSpace -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpace -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpace -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpace -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameSpace -> r
gmapT :: (forall b. Data b => b -> b) -> NameSpace -> NameSpace
$cgmapT :: (forall b. Data b => b -> b) -> NameSpace -> NameSpace
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameSpace)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameSpace)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NameSpace)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameSpace)
dataTypeOf :: NameSpace -> DataType
$cdataTypeOf :: NameSpace -> DataType
toConstr :: NameSpace -> Constr
$ctoConstr :: NameSpace -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpace
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameSpace
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpace -> c NameSpace
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameSpace -> c NameSpace
$cp1Data :: Typeable NameSpace
Data, NameSpace -> NameSpace -> Bool
(NameSpace -> NameSpace -> Bool)
-> (NameSpace -> NameSpace -> Bool) -> Eq NameSpace
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NameSpace -> NameSpace -> Bool
$c/= :: NameSpace -> NameSpace -> Bool
== :: NameSpace -> NameSpace -> Bool
$c== :: NameSpace -> NameSpace -> Bool
Eq, Int -> NameSpace -> ShowS
[NameSpace] -> ShowS
NameSpace -> String
(Int -> NameSpace -> ShowS)
-> (NameSpace -> String)
-> ([NameSpace] -> ShowS)
-> Show NameSpace
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NameSpace] -> ShowS
$cshowList :: [NameSpace] -> ShowS
show :: NameSpace -> String
$cshow :: NameSpace -> String
showsPrec :: Int -> NameSpace -> ShowS
$cshowsPrec :: Int -> NameSpace -> ShowS
Show)
type ThingsInScope a = Map C.Name [a]
type NamesInScope = ThingsInScope AbstractName
type ModulesInScope = ThingsInScope AbstractModule
type InScopeSet = Set A.QName
data InScopeTag a where
NameTag :: InScopeTag AbstractName
ModuleTag :: InScopeTag AbstractModule
class Ord a => InScope a where
inScopeTag :: InScopeTag a
instance InScope AbstractName where
inScopeTag :: InScopeTag AbstractName
inScopeTag = InScopeTag AbstractName
NameTag
instance InScope AbstractModule where
inScopeTag :: InScopeTag AbstractModule
inScopeTag = InScopeTag AbstractModule
ModuleTag
inNameSpace :: forall a. InScope a => NameSpace -> ThingsInScope a
inNameSpace :: NameSpace -> ThingsInScope a
inNameSpace = case InScopeTag a
forall a. InScope a => InScopeTag a
inScopeTag :: InScopeTag a of
InScopeTag a
NameTag -> NameSpace -> ThingsInScope a
NameSpace -> NamesInScope
nsNames
InScopeTag a
ModuleTag -> NameSpace -> ThingsInScope a
NameSpace -> ModulesInScope
nsModules
data NameOrModule = NameNotModule | ModuleNotName
deriving (Typeable NameOrModule
DataType
Constr
Typeable NameOrModule
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameOrModule -> c NameOrModule)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameOrModule)
-> (NameOrModule -> Constr)
-> (NameOrModule -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameOrModule))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameOrModule))
-> ((forall b. Data b => b -> b) -> NameOrModule -> NameOrModule)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameOrModule -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameOrModule -> r)
-> (forall u. (forall d. Data d => d -> u) -> NameOrModule -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> NameOrModule -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule)
-> Data NameOrModule
NameOrModule -> DataType
NameOrModule -> Constr
(forall b. Data b => b -> b) -> NameOrModule -> NameOrModule
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameOrModule -> c NameOrModule
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameOrModule
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> NameOrModule -> u
forall u. (forall d. Data d => d -> u) -> NameOrModule -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameOrModule -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameOrModule -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameOrModule
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameOrModule -> c NameOrModule
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameOrModule)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameOrModule)
$cModuleNotName :: Constr
$cNameNotModule :: Constr
$tNameOrModule :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule
gmapMp :: (forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule
gmapM :: (forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameOrModule -> m NameOrModule
gmapQi :: Int -> (forall d. Data d => d -> u) -> NameOrModule -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NameOrModule -> u
gmapQ :: (forall d. Data d => d -> u) -> NameOrModule -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NameOrModule -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameOrModule -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameOrModule -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameOrModule -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameOrModule -> r
gmapT :: (forall b. Data b => b -> b) -> NameOrModule -> NameOrModule
$cgmapT :: (forall b. Data b => b -> b) -> NameOrModule -> NameOrModule
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameOrModule)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameOrModule)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NameOrModule)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameOrModule)
dataTypeOf :: NameOrModule -> DataType
$cdataTypeOf :: NameOrModule -> DataType
toConstr :: NameOrModule -> Constr
$ctoConstr :: NameOrModule -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameOrModule
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameOrModule
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameOrModule -> c NameOrModule
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameOrModule -> c NameOrModule
$cp1Data :: Typeable NameOrModule
Data, NameOrModule -> NameOrModule -> Bool
(NameOrModule -> NameOrModule -> Bool)
-> (NameOrModule -> NameOrModule -> Bool) -> Eq NameOrModule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NameOrModule -> NameOrModule -> Bool
$c/= :: NameOrModule -> NameOrModule -> Bool
== :: NameOrModule -> NameOrModule -> Bool
$c== :: NameOrModule -> NameOrModule -> Bool
Eq, Eq NameOrModule
Eq NameOrModule
-> (NameOrModule -> NameOrModule -> Ordering)
-> (NameOrModule -> NameOrModule -> Bool)
-> (NameOrModule -> NameOrModule -> Bool)
-> (NameOrModule -> NameOrModule -> Bool)
-> (NameOrModule -> NameOrModule -> Bool)
-> (NameOrModule -> NameOrModule -> NameOrModule)
-> (NameOrModule -> NameOrModule -> NameOrModule)
-> Ord NameOrModule
NameOrModule -> NameOrModule -> Bool
NameOrModule -> NameOrModule -> Ordering
NameOrModule -> NameOrModule -> NameOrModule
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: NameOrModule -> NameOrModule -> NameOrModule
$cmin :: NameOrModule -> NameOrModule -> NameOrModule
max :: NameOrModule -> NameOrModule -> NameOrModule
$cmax :: NameOrModule -> NameOrModule -> NameOrModule
>= :: NameOrModule -> NameOrModule -> Bool
$c>= :: NameOrModule -> NameOrModule -> Bool
> :: NameOrModule -> NameOrModule -> Bool
$c> :: NameOrModule -> NameOrModule -> Bool
<= :: NameOrModule -> NameOrModule -> Bool
$c<= :: NameOrModule -> NameOrModule -> Bool
< :: NameOrModule -> NameOrModule -> Bool
$c< :: NameOrModule -> NameOrModule -> Bool
compare :: NameOrModule -> NameOrModule -> Ordering
$ccompare :: NameOrModule -> NameOrModule -> Ordering
$cp1Ord :: Eq NameOrModule
Ord, Int -> NameOrModule -> ShowS
[NameOrModule] -> ShowS
NameOrModule -> String
(Int -> NameOrModule -> ShowS)
-> (NameOrModule -> String)
-> ([NameOrModule] -> ShowS)
-> Show NameOrModule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NameOrModule] -> ShowS
$cshowList :: [NameOrModule] -> ShowS
show :: NameOrModule -> String
$cshow :: NameOrModule -> String
showsPrec :: Int -> NameOrModule -> ShowS
$cshowsPrec :: Int -> NameOrModule -> ShowS
Show, Int -> NameOrModule
NameOrModule -> Int
NameOrModule -> [NameOrModule]
NameOrModule -> NameOrModule
NameOrModule -> NameOrModule -> [NameOrModule]
NameOrModule -> NameOrModule -> NameOrModule -> [NameOrModule]
(NameOrModule -> NameOrModule)
-> (NameOrModule -> NameOrModule)
-> (Int -> NameOrModule)
-> (NameOrModule -> Int)
-> (NameOrModule -> [NameOrModule])
-> (NameOrModule -> NameOrModule -> [NameOrModule])
-> (NameOrModule -> NameOrModule -> [NameOrModule])
-> (NameOrModule -> NameOrModule -> NameOrModule -> [NameOrModule])
-> Enum NameOrModule
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: NameOrModule -> NameOrModule -> NameOrModule -> [NameOrModule]
$cenumFromThenTo :: NameOrModule -> NameOrModule -> NameOrModule -> [NameOrModule]
enumFromTo :: NameOrModule -> NameOrModule -> [NameOrModule]
$cenumFromTo :: NameOrModule -> NameOrModule -> [NameOrModule]
enumFromThen :: NameOrModule -> NameOrModule -> [NameOrModule]
$cenumFromThen :: NameOrModule -> NameOrModule -> [NameOrModule]
enumFrom :: NameOrModule -> [NameOrModule]
$cenumFrom :: NameOrModule -> [NameOrModule]
fromEnum :: NameOrModule -> Int
$cfromEnum :: NameOrModule -> Int
toEnum :: Int -> NameOrModule
$ctoEnum :: Int -> NameOrModule
pred :: NameOrModule -> NameOrModule
$cpred :: NameOrModule -> NameOrModule
succ :: NameOrModule -> NameOrModule
$csucc :: NameOrModule -> NameOrModule
Enum, NameOrModule
NameOrModule -> NameOrModule -> Bounded NameOrModule
forall a. a -> a -> Bounded a
maxBound :: NameOrModule
$cmaxBound :: NameOrModule
minBound :: NameOrModule
$cminBound :: NameOrModule
Bounded)
data KindOfName
= ConName
| FldName
| PatternSynName
| GeneralizeName
| DisallowedGeneralizeName
| MacroName
| QuotableName
| DataName
| RecName
| FunName
| AxiomName
| PrimName
| OtherDefName
deriving (KindOfName -> KindOfName -> Bool
(KindOfName -> KindOfName -> Bool)
-> (KindOfName -> KindOfName -> Bool) -> Eq KindOfName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KindOfName -> KindOfName -> Bool
$c/= :: KindOfName -> KindOfName -> Bool
== :: KindOfName -> KindOfName -> Bool
$c== :: KindOfName -> KindOfName -> Bool
Eq, Eq KindOfName
Eq KindOfName
-> (KindOfName -> KindOfName -> Ordering)
-> (KindOfName -> KindOfName -> Bool)
-> (KindOfName -> KindOfName -> Bool)
-> (KindOfName -> KindOfName -> Bool)
-> (KindOfName -> KindOfName -> Bool)
-> (KindOfName -> KindOfName -> KindOfName)
-> (KindOfName -> KindOfName -> KindOfName)
-> Ord KindOfName
KindOfName -> KindOfName -> Bool
KindOfName -> KindOfName -> Ordering
KindOfName -> KindOfName -> KindOfName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: KindOfName -> KindOfName -> KindOfName
$cmin :: KindOfName -> KindOfName -> KindOfName
max :: KindOfName -> KindOfName -> KindOfName
$cmax :: KindOfName -> KindOfName -> KindOfName
>= :: KindOfName -> KindOfName -> Bool
$c>= :: KindOfName -> KindOfName -> Bool
> :: KindOfName -> KindOfName -> Bool
$c> :: KindOfName -> KindOfName -> Bool
<= :: KindOfName -> KindOfName -> Bool
$c<= :: KindOfName -> KindOfName -> Bool
< :: KindOfName -> KindOfName -> Bool
$c< :: KindOfName -> KindOfName -> Bool
compare :: KindOfName -> KindOfName -> Ordering
$ccompare :: KindOfName -> KindOfName -> Ordering
$cp1Ord :: Eq KindOfName
Ord, Int -> KindOfName -> ShowS
[KindOfName] -> ShowS
KindOfName -> String
(Int -> KindOfName -> ShowS)
-> (KindOfName -> String)
-> ([KindOfName] -> ShowS)
-> Show KindOfName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KindOfName] -> ShowS
$cshowList :: [KindOfName] -> ShowS
show :: KindOfName -> String
$cshow :: KindOfName -> String
showsPrec :: Int -> KindOfName -> ShowS
$cshowsPrec :: Int -> KindOfName -> ShowS
Show, Typeable KindOfName
DataType
Constr
Typeable KindOfName
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KindOfName -> c KindOfName)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KindOfName)
-> (KindOfName -> Constr)
-> (KindOfName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KindOfName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c KindOfName))
-> ((forall b. Data b => b -> b) -> KindOfName -> KindOfName)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KindOfName -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KindOfName -> r)
-> (forall u. (forall d. Data d => d -> u) -> KindOfName -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> KindOfName -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KindOfName -> m KindOfName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KindOfName -> m KindOfName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KindOfName -> m KindOfName)
-> Data KindOfName
KindOfName -> DataType
KindOfName -> Constr
(forall b. Data b => b -> b) -> KindOfName -> KindOfName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KindOfName -> c KindOfName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KindOfName
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> KindOfName -> u
forall u. (forall d. Data d => d -> u) -> KindOfName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KindOfName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KindOfName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KindOfName -> m KindOfName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KindOfName -> m KindOfName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KindOfName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KindOfName -> c KindOfName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KindOfName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KindOfName)
$cOtherDefName :: Constr
$cPrimName :: Constr
$cAxiomName :: Constr
$cFunName :: Constr
$cRecName :: Constr
$cDataName :: Constr
$cQuotableName :: Constr
$cMacroName :: Constr
$cDisallowedGeneralizeName :: Constr
$cGeneralizeName :: Constr
$cPatternSynName :: Constr
$cFldName :: Constr
$cConName :: Constr
$tKindOfName :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> KindOfName -> m KindOfName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KindOfName -> m KindOfName
gmapMp :: (forall d. Data d => d -> m d) -> KindOfName -> m KindOfName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KindOfName -> m KindOfName
gmapM :: (forall d. Data d => d -> m d) -> KindOfName -> m KindOfName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KindOfName -> m KindOfName
gmapQi :: Int -> (forall d. Data d => d -> u) -> KindOfName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KindOfName -> u
gmapQ :: (forall d. Data d => d -> u) -> KindOfName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> KindOfName -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KindOfName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KindOfName -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KindOfName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KindOfName -> r
gmapT :: (forall b. Data b => b -> b) -> KindOfName -> KindOfName
$cgmapT :: (forall b. Data b => b -> b) -> KindOfName -> KindOfName
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KindOfName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c KindOfName)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c KindOfName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KindOfName)
dataTypeOf :: KindOfName -> DataType
$cdataTypeOf :: KindOfName -> DataType
toConstr :: KindOfName -> Constr
$ctoConstr :: KindOfName -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KindOfName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KindOfName
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KindOfName -> c KindOfName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KindOfName -> c KindOfName
$cp1Data :: Typeable KindOfName
Data, Int -> KindOfName
KindOfName -> Int
KindOfName -> [KindOfName]
KindOfName -> KindOfName
KindOfName -> KindOfName -> [KindOfName]
KindOfName -> KindOfName -> KindOfName -> [KindOfName]
(KindOfName -> KindOfName)
-> (KindOfName -> KindOfName)
-> (Int -> KindOfName)
-> (KindOfName -> Int)
-> (KindOfName -> [KindOfName])
-> (KindOfName -> KindOfName -> [KindOfName])
-> (KindOfName -> KindOfName -> [KindOfName])
-> (KindOfName -> KindOfName -> KindOfName -> [KindOfName])
-> Enum KindOfName
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: KindOfName -> KindOfName -> KindOfName -> [KindOfName]
$cenumFromThenTo :: KindOfName -> KindOfName -> KindOfName -> [KindOfName]
enumFromTo :: KindOfName -> KindOfName -> [KindOfName]
$cenumFromTo :: KindOfName -> KindOfName -> [KindOfName]
enumFromThen :: KindOfName -> KindOfName -> [KindOfName]
$cenumFromThen :: KindOfName -> KindOfName -> [KindOfName]
enumFrom :: KindOfName -> [KindOfName]
$cenumFrom :: KindOfName -> [KindOfName]
fromEnum :: KindOfName -> Int
$cfromEnum :: KindOfName -> Int
toEnum :: Int -> KindOfName
$ctoEnum :: Int -> KindOfName
pred :: KindOfName -> KindOfName
$cpred :: KindOfName -> KindOfName
succ :: KindOfName -> KindOfName
$csucc :: KindOfName -> KindOfName
Enum, KindOfName
KindOfName -> KindOfName -> Bounded KindOfName
forall a. a -> a -> Bounded a
maxBound :: KindOfName
$cmaxBound :: KindOfName
minBound :: KindOfName
$cminBound :: KindOfName
Bounded)
isDefName :: KindOfName -> Bool
isDefName :: KindOfName -> Bool
isDefName = (KindOfName -> KindOfName -> Bool
forall a. Ord a => a -> a -> Bool
>= KindOfName
DataName)
data KindsOfNames
= AllKindsOfNames
| SomeKindsOfNames (Set KindOfName)
| ExceptKindsOfNames (Set KindOfName)
elemKindsOfNames :: KindOfName -> KindsOfNames -> Bool
elemKindsOfNames :: KindOfName -> KindsOfNames -> Bool
elemKindsOfNames KindOfName
k = \case
KindsOfNames
AllKindsOfNames -> Bool
True
SomeKindsOfNames Set KindOfName
ks -> KindOfName
k KindOfName -> Set KindOfName -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set KindOfName
ks
ExceptKindsOfNames Set KindOfName
ks -> KindOfName
k KindOfName -> Set KindOfName -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.notMember` Set KindOfName
ks
allKindsOfNames :: KindsOfNames
allKindsOfNames :: KindsOfNames
allKindsOfNames = KindsOfNames
AllKindsOfNames
someKindsOfNames :: [KindOfName] -> KindsOfNames
someKindsOfNames :: [KindOfName] -> KindsOfNames
someKindsOfNames = Set KindOfName -> KindsOfNames
SomeKindsOfNames (Set KindOfName -> KindsOfNames)
-> ([KindOfName] -> Set KindOfName) -> [KindOfName] -> KindsOfNames
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [KindOfName] -> Set KindOfName
forall a. Ord a => [a] -> Set a
Set.fromList
exceptKindsOfNames :: [KindOfName] -> KindsOfNames
exceptKindsOfNames :: [KindOfName] -> KindsOfNames
exceptKindsOfNames = Set KindOfName -> KindsOfNames
ExceptKindsOfNames (Set KindOfName -> KindsOfNames)
-> ([KindOfName] -> Set KindOfName) -> [KindOfName] -> KindsOfNames
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [KindOfName] -> Set KindOfName
forall a. Ord a => [a] -> Set a
Set.fromList
data WhyInScope
= Defined
| Opened C.QName WhyInScope
| Applied C.QName WhyInScope
deriving (Typeable WhyInScope
DataType
Constr
Typeable WhyInScope
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WhyInScope -> c WhyInScope)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WhyInScope)
-> (WhyInScope -> Constr)
-> (WhyInScope -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WhyInScope))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c WhyInScope))
-> ((forall b. Data b => b -> b) -> WhyInScope -> WhyInScope)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WhyInScope -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WhyInScope -> r)
-> (forall u. (forall d. Data d => d -> u) -> WhyInScope -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> WhyInScope -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope)
-> Data WhyInScope
WhyInScope -> DataType
WhyInScope -> Constr
(forall b. Data b => b -> b) -> WhyInScope -> WhyInScope
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WhyInScope -> c WhyInScope
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WhyInScope
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> WhyInScope -> u
forall u. (forall d. Data d => d -> u) -> WhyInScope -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WhyInScope -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WhyInScope -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WhyInScope
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WhyInScope -> c WhyInScope
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WhyInScope)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WhyInScope)
$cApplied :: Constr
$cOpened :: Constr
$cDefined :: Constr
$tWhyInScope :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope
gmapMp :: (forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope
gmapM :: (forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WhyInScope -> m WhyInScope
gmapQi :: Int -> (forall d. Data d => d -> u) -> WhyInScope -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> WhyInScope -> u
gmapQ :: (forall d. Data d => d -> u) -> WhyInScope -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> WhyInScope -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WhyInScope -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WhyInScope -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WhyInScope -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WhyInScope -> r
gmapT :: (forall b. Data b => b -> b) -> WhyInScope -> WhyInScope
$cgmapT :: (forall b. Data b => b -> b) -> WhyInScope -> WhyInScope
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WhyInScope)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WhyInScope)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c WhyInScope)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WhyInScope)
dataTypeOf :: WhyInScope -> DataType
$cdataTypeOf :: WhyInScope -> DataType
toConstr :: WhyInScope -> Constr
$ctoConstr :: WhyInScope -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WhyInScope
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WhyInScope
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WhyInScope -> c WhyInScope
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WhyInScope -> c WhyInScope
$cp1Data :: Typeable WhyInScope
Data, Int -> WhyInScope -> ShowS
[WhyInScope] -> ShowS
WhyInScope -> String
(Int -> WhyInScope -> ShowS)
-> (WhyInScope -> String)
-> ([WhyInScope] -> ShowS)
-> Show WhyInScope
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WhyInScope] -> ShowS
$cshowList :: [WhyInScope] -> ShowS
show :: WhyInScope -> String
$cshow :: WhyInScope -> String
showsPrec :: Int -> WhyInScope -> ShowS
$cshowsPrec :: Int -> WhyInScope -> ShowS
Show)
data AbstractName = AbsName
{ AbstractName -> QName
anameName :: A.QName
, AbstractName -> KindOfName
anameKind :: KindOfName
, AbstractName -> WhyInScope
anameLineage :: WhyInScope
, AbstractName -> NameMetadata
anameMetadata :: NameMetadata
}
deriving (Typeable AbstractName
DataType
Constr
Typeable AbstractName
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractName -> c AbstractName)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractName)
-> (AbstractName -> Constr)
-> (AbstractName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AbstractName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractName))
-> ((forall b. Data b => b -> b) -> AbstractName -> AbstractName)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractName -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractName -> r)
-> (forall u. (forall d. Data d => d -> u) -> AbstractName -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> AbstractName -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AbstractName -> m AbstractName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AbstractName -> m AbstractName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AbstractName -> m AbstractName)
-> Data AbstractName
AbstractName -> DataType
AbstractName -> Constr
(forall b. Data b => b -> b) -> AbstractName -> AbstractName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractName -> c AbstractName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractName
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AbstractName -> u
forall u. (forall d. Data d => d -> u) -> AbstractName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AbstractName -> m AbstractName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AbstractName -> m AbstractName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractName -> c AbstractName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AbstractName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractName)
$cAbsName :: Constr
$tAbstractName :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> AbstractName -> m AbstractName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AbstractName -> m AbstractName
gmapMp :: (forall d. Data d => d -> m d) -> AbstractName -> m AbstractName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AbstractName -> m AbstractName
gmapM :: (forall d. Data d => d -> m d) -> AbstractName -> m AbstractName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AbstractName -> m AbstractName
gmapQi :: Int -> (forall d. Data d => d -> u) -> AbstractName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AbstractName -> u
gmapQ :: (forall d. Data d => d -> u) -> AbstractName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AbstractName -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractName -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractName -> r
gmapT :: (forall b. Data b => b -> b) -> AbstractName -> AbstractName
$cgmapT :: (forall b. Data b => b -> b) -> AbstractName -> AbstractName
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractName)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c AbstractName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AbstractName)
dataTypeOf :: AbstractName -> DataType
$cdataTypeOf :: AbstractName -> DataType
toConstr :: AbstractName -> Constr
$ctoConstr :: AbstractName -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractName
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractName -> c AbstractName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractName -> c AbstractName
$cp1Data :: Typeable AbstractName
Data, Int -> AbstractName -> ShowS
[AbstractName] -> ShowS
AbstractName -> String
(Int -> AbstractName -> ShowS)
-> (AbstractName -> String)
-> ([AbstractName] -> ShowS)
-> Show AbstractName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbstractName] -> ShowS
$cshowList :: [AbstractName] -> ShowS
show :: AbstractName -> String
$cshow :: AbstractName -> String
showsPrec :: Int -> AbstractName -> ShowS
$cshowsPrec :: Int -> AbstractName -> ShowS
Show)
data NameMetadata = NoMetadata
| GeneralizedVarsMetadata (Map A.QName A.Name)
deriving (Typeable NameMetadata
DataType
Constr
Typeable NameMetadata
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameMetadata -> c NameMetadata)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameMetadata)
-> (NameMetadata -> Constr)
-> (NameMetadata -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameMetadata))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameMetadata))
-> ((forall b. Data b => b -> b) -> NameMetadata -> NameMetadata)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameMetadata -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameMetadata -> r)
-> (forall u. (forall d. Data d => d -> u) -> NameMetadata -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> NameMetadata -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata)
-> Data NameMetadata
NameMetadata -> DataType
NameMetadata -> Constr
(forall b. Data b => b -> b) -> NameMetadata -> NameMetadata
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameMetadata -> c NameMetadata
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameMetadata
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> NameMetadata -> u
forall u. (forall d. Data d => d -> u) -> NameMetadata -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameMetadata -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameMetadata -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameMetadata
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameMetadata -> c NameMetadata
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameMetadata)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameMetadata)
$cGeneralizedVarsMetadata :: Constr
$cNoMetadata :: Constr
$tNameMetadata :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata
gmapMp :: (forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata
gmapM :: (forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NameMetadata -> m NameMetadata
gmapQi :: Int -> (forall d. Data d => d -> u) -> NameMetadata -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NameMetadata -> u
gmapQ :: (forall d. Data d => d -> u) -> NameMetadata -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NameMetadata -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameMetadata -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NameMetadata -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameMetadata -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NameMetadata -> r
gmapT :: (forall b. Data b => b -> b) -> NameMetadata -> NameMetadata
$cgmapT :: (forall b. Data b => b -> b) -> NameMetadata -> NameMetadata
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameMetadata)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NameMetadata)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NameMetadata)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NameMetadata)
dataTypeOf :: NameMetadata -> DataType
$cdataTypeOf :: NameMetadata -> DataType
toConstr :: NameMetadata -> Constr
$ctoConstr :: NameMetadata -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameMetadata
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NameMetadata
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameMetadata -> c NameMetadata
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NameMetadata -> c NameMetadata
$cp1Data :: Typeable NameMetadata
Data, Int -> NameMetadata -> ShowS
[NameMetadata] -> ShowS
NameMetadata -> String
(Int -> NameMetadata -> ShowS)
-> (NameMetadata -> String)
-> ([NameMetadata] -> ShowS)
-> Show NameMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NameMetadata] -> ShowS
$cshowList :: [NameMetadata] -> ShowS
show :: NameMetadata -> String
$cshow :: NameMetadata -> String
showsPrec :: Int -> NameMetadata -> ShowS
$cshowsPrec :: Int -> NameMetadata -> ShowS
Show)
data AbstractModule = AbsModule
{ AbstractModule -> ModuleName
amodName :: A.ModuleName
, AbstractModule -> WhyInScope
amodLineage :: WhyInScope
}
deriving (Typeable AbstractModule
DataType
Constr
Typeable AbstractModule
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractModule -> c AbstractModule)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractModule)
-> (AbstractModule -> Constr)
-> (AbstractModule -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AbstractModule))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractModule))
-> ((forall b. Data b => b -> b)
-> AbstractModule -> AbstractModule)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractModule -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractModule -> r)
-> (forall u.
(forall d. Data d => d -> u) -> AbstractModule -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> AbstractModule -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule)
-> Data AbstractModule
AbstractModule -> DataType
AbstractModule -> Constr
(forall b. Data b => b -> b) -> AbstractModule -> AbstractModule
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractModule -> c AbstractModule
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractModule
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> AbstractModule -> u
forall u. (forall d. Data d => d -> u) -> AbstractModule -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractModule -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractModule -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractModule
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractModule -> c AbstractModule
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AbstractModule)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractModule)
$cAbsModule :: Constr
$tAbstractModule :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule
gmapMp :: (forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule
gmapM :: (forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AbstractModule -> m AbstractModule
gmapQi :: Int -> (forall d. Data d => d -> u) -> AbstractModule -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AbstractModule -> u
gmapQ :: (forall d. Data d => d -> u) -> AbstractModule -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AbstractModule -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractModule -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractModule -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractModule -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractModule -> r
gmapT :: (forall b. Data b => b -> b) -> AbstractModule -> AbstractModule
$cgmapT :: (forall b. Data b => b -> b) -> AbstractModule -> AbstractModule
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractModule)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractModule)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c AbstractModule)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AbstractModule)
dataTypeOf :: AbstractModule -> DataType
$cdataTypeOf :: AbstractModule -> DataType
toConstr :: AbstractModule -> Constr
$ctoConstr :: AbstractModule -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractModule
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractModule
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractModule -> c AbstractModule
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractModule -> c AbstractModule
$cp1Data :: Typeable AbstractModule
Data, Int -> AbstractModule -> ShowS
[AbstractModule] -> ShowS
AbstractModule -> String
(Int -> AbstractModule -> ShowS)
-> (AbstractModule -> String)
-> ([AbstractModule] -> ShowS)
-> Show AbstractModule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbstractModule] -> ShowS
$cshowList :: [AbstractModule] -> ShowS
show :: AbstractModule -> String
$cshow :: AbstractModule -> String
showsPrec :: Int -> AbstractModule -> ShowS
$cshowsPrec :: Int -> AbstractModule -> ShowS
Show)
instance Eq AbstractName where
== :: AbstractName -> AbstractName -> Bool
(==) = QName -> QName -> Bool
forall a. Eq a => a -> a -> Bool
(==) (QName -> QName -> Bool)
-> (AbstractName -> QName) -> AbstractName -> AbstractName -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` AbstractName -> QName
anameName
instance Ord AbstractName where
compare :: AbstractName -> AbstractName -> Ordering
compare = QName -> QName -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (QName -> QName -> Ordering)
-> (AbstractName -> QName)
-> AbstractName
-> AbstractName
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` AbstractName -> QName
anameName
instance LensFixity AbstractName where
lensFixity :: (Fixity -> f Fixity) -> AbstractName -> f AbstractName
lensFixity = (QName -> f QName) -> AbstractName -> f AbstractName
forall (m :: * -> *).
Functor m =>
(QName -> m QName) -> AbstractName -> m AbstractName
lensAnameName ((QName -> f QName) -> AbstractName -> f AbstractName)
-> ((Fixity -> f Fixity) -> QName -> f QName)
-> (Fixity -> f Fixity)
-> AbstractName
-> f AbstractName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Fixity -> f Fixity) -> QName -> f QName
forall a. LensFixity a => Lens' Fixity a
lensFixity
lensAnameName :: Functor m => (A.QName -> m A.QName) -> AbstractName -> m AbstractName
lensAnameName :: (QName -> m QName) -> AbstractName -> m AbstractName
lensAnameName QName -> m QName
f AbstractName
am = QName -> m QName
f (AbstractName -> QName
anameName AbstractName
am) m QName -> (QName -> AbstractName) -> m AbstractName
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ QName
m -> AbstractName
am { anameName :: QName
anameName = QName
m }
instance Eq AbstractModule where
== :: AbstractModule -> AbstractModule -> Bool
(==) = ModuleName -> ModuleName -> Bool
forall a. Eq a => a -> a -> Bool
(==) (ModuleName -> ModuleName -> Bool)
-> (AbstractModule -> ModuleName)
-> AbstractModule
-> AbstractModule
-> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` AbstractModule -> ModuleName
amodName
instance Ord AbstractModule where
compare :: AbstractModule -> AbstractModule -> Ordering
compare = ModuleName -> ModuleName -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (ModuleName -> ModuleName -> Ordering)
-> (AbstractModule -> ModuleName)
-> AbstractModule
-> AbstractModule
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` AbstractModule -> ModuleName
amodName
lensAmodName :: Functor m => (A.ModuleName -> m A.ModuleName) -> AbstractModule -> m AbstractModule
lensAmodName :: (ModuleName -> m ModuleName) -> AbstractModule -> m AbstractModule
lensAmodName ModuleName -> m ModuleName
f AbstractModule
am = ModuleName -> m ModuleName
f (AbstractModule -> ModuleName
amodName AbstractModule
am) m ModuleName -> (ModuleName -> AbstractModule) -> m AbstractModule
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ ModuleName
m -> AbstractModule
am { amodName :: ModuleName
amodName = ModuleName
m }
data ResolvedName
=
VarName
{ ResolvedName -> Name
resolvedVar :: A.Name
, ResolvedName -> BindingSource
resolvedBindingSource :: BindingSource
}
|
DefinedName Access AbstractName
|
FieldName (NonEmpty AbstractName)
|
ConstructorName (NonEmpty AbstractName)
|
PatternSynResName (NonEmpty AbstractName)
|
UnknownName
deriving (Typeable ResolvedName
DataType
Constr
Typeable ResolvedName
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ResolvedName -> c ResolvedName)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ResolvedName)
-> (ResolvedName -> Constr)
-> (ResolvedName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ResolvedName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ResolvedName))
-> ((forall b. Data b => b -> b) -> ResolvedName -> ResolvedName)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ResolvedName -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ResolvedName -> r)
-> (forall u. (forall d. Data d => d -> u) -> ResolvedName -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> ResolvedName -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName)
-> Data ResolvedName
ResolvedName -> DataType
ResolvedName -> Constr
(forall b. Data b => b -> b) -> ResolvedName -> ResolvedName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ResolvedName -> c ResolvedName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ResolvedName
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ResolvedName -> u
forall u. (forall d. Data d => d -> u) -> ResolvedName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ResolvedName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ResolvedName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ResolvedName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ResolvedName -> c ResolvedName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ResolvedName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ResolvedName)
$cUnknownName :: Constr
$cPatternSynResName :: Constr
$cConstructorName :: Constr
$cFieldName :: Constr
$cDefinedName :: Constr
$cVarName :: Constr
$tResolvedName :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName
gmapMp :: (forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName
gmapM :: (forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ResolvedName -> m ResolvedName
gmapQi :: Int -> (forall d. Data d => d -> u) -> ResolvedName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ResolvedName -> u
gmapQ :: (forall d. Data d => d -> u) -> ResolvedName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ResolvedName -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ResolvedName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ResolvedName -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ResolvedName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ResolvedName -> r
gmapT :: (forall b. Data b => b -> b) -> ResolvedName -> ResolvedName
$cgmapT :: (forall b. Data b => b -> b) -> ResolvedName -> ResolvedName
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ResolvedName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ResolvedName)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ResolvedName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ResolvedName)
dataTypeOf :: ResolvedName -> DataType
$cdataTypeOf :: ResolvedName -> DataType
toConstr :: ResolvedName -> Constr
$ctoConstr :: ResolvedName -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ResolvedName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ResolvedName
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ResolvedName -> c ResolvedName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ResolvedName -> c ResolvedName
$cp1Data :: Typeable ResolvedName
Data, Int -> ResolvedName -> ShowS
[ResolvedName] -> ShowS
ResolvedName -> String
(Int -> ResolvedName -> ShowS)
-> (ResolvedName -> String)
-> ([ResolvedName] -> ShowS)
-> Show ResolvedName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResolvedName] -> ShowS
$cshowList :: [ResolvedName] -> ShowS
show :: ResolvedName -> String
$cshow :: ResolvedName -> String
showsPrec :: Int -> ResolvedName -> ShowS
$cshowsPrec :: Int -> ResolvedName -> ShowS
Show, ResolvedName -> ResolvedName -> Bool
(ResolvedName -> ResolvedName -> Bool)
-> (ResolvedName -> ResolvedName -> Bool) -> Eq ResolvedName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResolvedName -> ResolvedName -> Bool
$c/= :: ResolvedName -> ResolvedName -> Bool
== :: ResolvedName -> ResolvedName -> Bool
$c== :: ResolvedName -> ResolvedName -> Bool
Eq)
instance Pretty ResolvedName where
pretty :: ResolvedName -> Doc
pretty = \case
VarName Name
x BindingSource
_ -> Doc
"variable" Doc -> Doc -> Doc
<+> Name -> Doc
forall a. Pretty a => a -> Doc
pretty Name
x
DefinedName Access
a AbstractName
x -> Access -> Doc
forall a. Pretty a => a -> Doc
pretty Access
a Doc -> Doc -> Doc
<+> AbstractName -> Doc
forall a. Pretty a => a -> Doc
pretty AbstractName
x
FieldName NonEmpty AbstractName
xs -> Doc
"field" Doc -> Doc -> Doc
<+> NonEmpty AbstractName -> Doc
forall a. Pretty a => a -> Doc
pretty NonEmpty AbstractName
xs
ConstructorName NonEmpty AbstractName
xs -> Doc
"constructor" Doc -> Doc -> Doc
<+> NonEmpty AbstractName -> Doc
forall a. Pretty a => a -> Doc
pretty NonEmpty AbstractName
xs
PatternSynResName NonEmpty AbstractName
x -> Doc
"pattern" Doc -> Doc -> Doc
<+> NonEmpty AbstractName -> Doc
forall a. Pretty a => a -> Doc
pretty NonEmpty AbstractName
x
ResolvedName
UnknownName -> Doc
"<unknown name>"
mergeNames :: Eq a => ThingsInScope a -> ThingsInScope a -> ThingsInScope a
mergeNames :: ThingsInScope a -> ThingsInScope a -> ThingsInScope a
mergeNames = ([a] -> [a] -> [a])
-> ThingsInScope a -> ThingsInScope a -> ThingsInScope a
forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Map.unionWith [a] -> [a] -> [a]
forall a. Eq a => [a] -> [a] -> [a]
List.union
mergeNamesMany :: Eq a => [ThingsInScope a] -> ThingsInScope a
mergeNamesMany :: [ThingsInScope a] -> ThingsInScope a
mergeNamesMany = ([a] -> [a] -> [a]) -> [ThingsInScope a] -> ThingsInScope a
forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
(a -> a -> a) -> f (Map k a) -> Map k a
Map.unionsWith [a] -> [a] -> [a]
forall a. Eq a => [a] -> [a] -> [a]
List.union
emptyNameSpace :: NameSpace
emptyNameSpace :: NameSpace
emptyNameSpace = NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace
NameSpace NamesInScope
forall k a. Map k a
Map.empty ModulesInScope
forall k a. Map k a
Map.empty InScopeSet
forall a. Set a
Set.empty
mapNameSpace :: (NamesInScope -> NamesInScope ) ->
(ModulesInScope -> ModulesInScope) ->
(InScopeSet -> InScopeSet ) ->
NameSpace -> NameSpace
mapNameSpace :: (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> NameSpace
-> NameSpace
mapNameSpace NamesInScope -> NamesInScope
fd ModulesInScope -> ModulesInScope
fm InScopeSet -> InScopeSet
fs NameSpace
ns =
NameSpace
ns { nsNames :: NamesInScope
nsNames = NamesInScope -> NamesInScope
fd (NamesInScope -> NamesInScope) -> NamesInScope -> NamesInScope
forall a b. (a -> b) -> a -> b
$ NameSpace -> NamesInScope
nsNames NameSpace
ns
, nsModules :: ModulesInScope
nsModules = ModulesInScope -> ModulesInScope
fm (ModulesInScope -> ModulesInScope)
-> ModulesInScope -> ModulesInScope
forall a b. (a -> b) -> a -> b
$ NameSpace -> ModulesInScope
nsModules NameSpace
ns
, nsInScope :: InScopeSet
nsInScope = InScopeSet -> InScopeSet
fs (InScopeSet -> InScopeSet) -> InScopeSet -> InScopeSet
forall a b. (a -> b) -> a -> b
$ NameSpace -> InScopeSet
nsInScope NameSpace
ns
}
zipNameSpace :: (NamesInScope -> NamesInScope -> NamesInScope ) ->
(ModulesInScope -> ModulesInScope -> ModulesInScope) ->
(InScopeSet -> InScopeSet -> InScopeSet ) ->
NameSpace -> NameSpace -> NameSpace
zipNameSpace :: (NamesInScope -> NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet -> InScopeSet)
-> NameSpace
-> NameSpace
-> NameSpace
zipNameSpace NamesInScope -> NamesInScope -> NamesInScope
fd ModulesInScope -> ModulesInScope -> ModulesInScope
fm InScopeSet -> InScopeSet -> InScopeSet
fs NameSpace
ns1 NameSpace
ns2 =
NameSpace
ns1 { nsNames :: NamesInScope
nsNames = NameSpace -> NamesInScope
nsNames NameSpace
ns1 NamesInScope -> NamesInScope -> NamesInScope
`fd` NameSpace -> NamesInScope
nsNames NameSpace
ns2
, nsModules :: ModulesInScope
nsModules = NameSpace -> ModulesInScope
nsModules NameSpace
ns1 ModulesInScope -> ModulesInScope -> ModulesInScope
`fm` NameSpace -> ModulesInScope
nsModules NameSpace
ns2
, nsInScope :: InScopeSet
nsInScope = NameSpace -> InScopeSet
nsInScope NameSpace
ns1 InScopeSet -> InScopeSet -> InScopeSet
`fs` NameSpace -> InScopeSet
nsInScope NameSpace
ns2
}
mapNameSpaceM :: Applicative m =>
(NamesInScope -> m NamesInScope ) ->
(ModulesInScope -> m ModulesInScope) ->
(InScopeSet -> m InScopeSet ) ->
NameSpace -> m NameSpace
mapNameSpaceM :: (NamesInScope -> m NamesInScope)
-> (ModulesInScope -> m ModulesInScope)
-> (InScopeSet -> m InScopeSet)
-> NameSpace
-> m NameSpace
mapNameSpaceM NamesInScope -> m NamesInScope
fd ModulesInScope -> m ModulesInScope
fm InScopeSet -> m InScopeSet
fs NameSpace
ns = NameSpace
-> NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace
update NameSpace
ns (NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace)
-> m NamesInScope -> m (ModulesInScope -> InScopeSet -> NameSpace)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NamesInScope -> m NamesInScope
fd (NameSpace -> NamesInScope
nsNames NameSpace
ns) m (ModulesInScope -> InScopeSet -> NameSpace)
-> m ModulesInScope -> m (InScopeSet -> NameSpace)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ModulesInScope -> m ModulesInScope
fm (NameSpace -> ModulesInScope
nsModules NameSpace
ns) m (InScopeSet -> NameSpace) -> m InScopeSet -> m NameSpace
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> InScopeSet -> m InScopeSet
fs (NameSpace -> InScopeSet
nsInScope NameSpace
ns)
where
update :: NameSpace
-> NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace
update NameSpace
ns NamesInScope
ds ModulesInScope
ms InScopeSet
is = NameSpace
ns { nsNames :: NamesInScope
nsNames = NamesInScope
ds, nsModules :: ModulesInScope
nsModules = ModulesInScope
ms, nsInScope :: InScopeSet
nsInScope = InScopeSet
is }
emptyScope :: Scope
emptyScope :: Scope
emptyScope = Scope :: ModuleName
-> [ModuleName]
-> ScopeNameSpaces
-> Map QName ModuleName
-> Maybe DataOrRecord
-> Scope
Scope
{ scopeName :: ModuleName
scopeName = ModuleName
noModuleName
, scopeParents :: [ModuleName]
scopeParents = []
, scopeNameSpaces :: ScopeNameSpaces
scopeNameSpaces = [ (NameSpaceId
nsid, NameSpace
emptyNameSpace) | NameSpaceId
nsid <- [NameSpaceId]
allNameSpaces ]
, scopeImports :: Map QName ModuleName
scopeImports = Map QName ModuleName
forall k a. Map k a
Map.empty
, scopeDatatypeModule :: Maybe DataOrRecord
scopeDatatypeModule = Maybe DataOrRecord
forall a. Maybe a
Nothing
}
emptyScopeInfo :: ScopeInfo
emptyScopeInfo :: ScopeInfo
emptyScopeInfo = ScopeInfo :: ModuleName
-> Map ModuleName Scope
-> LocalVars
-> LocalVars
-> PrecedenceStack
-> NameMap
-> ModuleMap
-> InScopeSet
-> Fixities
-> Polarities
-> ScopeInfo
ScopeInfo
{ _scopeCurrent :: ModuleName
_scopeCurrent = ModuleName
noModuleName
, _scopeModules :: Map ModuleName Scope
_scopeModules = ModuleName -> Scope -> Map ModuleName Scope
forall k a. k -> a -> Map k a
Map.singleton ModuleName
noModuleName Scope
emptyScope
, _scopeVarsToBind :: LocalVars
_scopeVarsToBind = []
, _scopeLocals :: LocalVars
_scopeLocals = []
, _scopePrecedence :: PrecedenceStack
_scopePrecedence = []
, _scopeInverseName :: NameMap
_scopeInverseName = NameMap
forall k a. Map k a
Map.empty
, _scopeInverseModule :: ModuleMap
_scopeInverseModule = ModuleMap
forall k a. Map k a
Map.empty
, _scopeInScope :: InScopeSet
_scopeInScope = InScopeSet
forall a. Set a
Set.empty
, _scopeFixities :: Fixities
_scopeFixities = Fixities
forall k a. Map k a
Map.empty
, _scopePolarities :: Polarities
_scopePolarities = Polarities
forall k a. Map k a
Map.empty
}
mapScope :: (NameSpaceId -> NamesInScope -> NamesInScope ) ->
(NameSpaceId -> ModulesInScope -> ModulesInScope) ->
(NameSpaceId -> InScopeSet -> InScopeSet ) ->
Scope -> Scope
mapScope :: (NameSpaceId -> NamesInScope -> NamesInScope)
-> (NameSpaceId -> ModulesInScope -> ModulesInScope)
-> (NameSpaceId -> InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScope NameSpaceId -> NamesInScope -> NamesInScope
fd NameSpaceId -> ModulesInScope -> ModulesInScope
fm NameSpaceId -> InScopeSet -> InScopeSet
fs = (ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope
updateScopeNameSpaces ((ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope)
-> (ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ (NameSpaceId -> NameSpace -> NameSpace)
-> ScopeNameSpaces -> ScopeNameSpaces
forall k v. (k -> v -> v) -> AssocList k v -> AssocList k v
AssocList.mapWithKey NameSpaceId -> NameSpace -> NameSpace
mapNS
where
mapNS :: NameSpaceId -> NameSpace -> NameSpace
mapNS NameSpaceId
acc = (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> NameSpace
-> NameSpace
mapNameSpace (NameSpaceId -> NamesInScope -> NamesInScope
fd NameSpaceId
acc) (NameSpaceId -> ModulesInScope -> ModulesInScope
fm NameSpaceId
acc) (NameSpaceId -> InScopeSet -> InScopeSet
fs NameSpaceId
acc)
mapScope_ :: (NamesInScope -> NamesInScope ) ->
(ModulesInScope -> ModulesInScope) ->
(InScopeSet -> InScopeSet ) ->
Scope -> Scope
mapScope_ :: (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScope_ NamesInScope -> NamesInScope
fd ModulesInScope -> ModulesInScope
fm InScopeSet -> InScopeSet
fs = (NameSpaceId -> NamesInScope -> NamesInScope)
-> (NameSpaceId -> ModulesInScope -> ModulesInScope)
-> (NameSpaceId -> InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScope ((NamesInScope -> NamesInScope)
-> NameSpaceId -> NamesInScope -> NamesInScope
forall a b. a -> b -> a
const NamesInScope -> NamesInScope
fd) ((ModulesInScope -> ModulesInScope)
-> NameSpaceId -> ModulesInScope -> ModulesInScope
forall a b. a -> b -> a
const ModulesInScope -> ModulesInScope
fm) ((InScopeSet -> InScopeSet)
-> NameSpaceId -> InScopeSet -> InScopeSet
forall a b. a -> b -> a
const InScopeSet -> InScopeSet
fs)
mapScopeNS :: NameSpaceId
-> (NamesInScope -> NamesInScope )
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet )
-> Scope -> Scope
mapScopeNS :: NameSpaceId
-> (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScopeNS NameSpaceId
nsid NamesInScope -> NamesInScope
fd ModulesInScope -> ModulesInScope
fm InScopeSet -> InScopeSet
fs = NameSpaceId -> (NameSpace -> NameSpace) -> Scope -> Scope
modifyNameSpace NameSpaceId
nsid ((NameSpace -> NameSpace) -> Scope -> Scope)
-> (NameSpace -> NameSpace) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> NameSpace
-> NameSpace
mapNameSpace NamesInScope -> NamesInScope
fd ModulesInScope -> ModulesInScope
fm InScopeSet -> InScopeSet
fs
mapScopeM :: Applicative m =>
(NameSpaceId -> NamesInScope -> m NamesInScope ) ->
(NameSpaceId -> ModulesInScope -> m ModulesInScope) ->
(NameSpaceId -> InScopeSet -> m InScopeSet ) ->
Scope -> m Scope
mapScopeM :: (NameSpaceId -> NamesInScope -> m NamesInScope)
-> (NameSpaceId -> ModulesInScope -> m ModulesInScope)
-> (NameSpaceId -> InScopeSet -> m InScopeSet)
-> Scope
-> m Scope
mapScopeM NameSpaceId -> NamesInScope -> m NamesInScope
fd NameSpaceId -> ModulesInScope -> m ModulesInScope
fm NameSpaceId -> InScopeSet -> m InScopeSet
fs = (ScopeNameSpaces -> m ScopeNameSpaces) -> Scope -> m Scope
forall (m :: * -> *).
Functor m =>
(ScopeNameSpaces -> m ScopeNameSpaces) -> Scope -> m Scope
updateScopeNameSpacesM ((ScopeNameSpaces -> m ScopeNameSpaces) -> Scope -> m Scope)
-> (ScopeNameSpaces -> m ScopeNameSpaces) -> Scope -> m Scope
forall a b. (a -> b) -> a -> b
$ (NameSpaceId -> NameSpace -> m NameSpace)
-> ScopeNameSpaces -> m ScopeNameSpaces
forall (m :: * -> *) k v.
Applicative m =>
(k -> v -> m v) -> AssocList k v -> m (AssocList k v)
AssocList.mapWithKeyM NameSpaceId -> NameSpace -> m NameSpace
mapNS
where
mapNS :: NameSpaceId -> NameSpace -> m NameSpace
mapNS NameSpaceId
acc = (NamesInScope -> m NamesInScope)
-> (ModulesInScope -> m ModulesInScope)
-> (InScopeSet -> m InScopeSet)
-> NameSpace
-> m NameSpace
forall (m :: * -> *).
Applicative m =>
(NamesInScope -> m NamesInScope)
-> (ModulesInScope -> m ModulesInScope)
-> (InScopeSet -> m InScopeSet)
-> NameSpace
-> m NameSpace
mapNameSpaceM (NameSpaceId -> NamesInScope -> m NamesInScope
fd NameSpaceId
acc) (NameSpaceId -> ModulesInScope -> m ModulesInScope
fm NameSpaceId
acc) (NameSpaceId -> InScopeSet -> m InScopeSet
fs NameSpaceId
acc)
mapScopeM_ :: Applicative m =>
(NamesInScope -> m NamesInScope ) ->
(ModulesInScope -> m ModulesInScope) ->
(InScopeSet -> m InScopeSet ) ->
Scope -> m Scope
mapScopeM_ :: (NamesInScope -> m NamesInScope)
-> (ModulesInScope -> m ModulesInScope)
-> (InScopeSet -> m InScopeSet)
-> Scope
-> m Scope
mapScopeM_ NamesInScope -> m NamesInScope
fd ModulesInScope -> m ModulesInScope
fm InScopeSet -> m InScopeSet
fs = (NameSpaceId -> NamesInScope -> m NamesInScope)
-> (NameSpaceId -> ModulesInScope -> m ModulesInScope)
-> (NameSpaceId -> InScopeSet -> m InScopeSet)
-> Scope
-> m Scope
forall (m :: * -> *).
Applicative m =>
(NameSpaceId -> NamesInScope -> m NamesInScope)
-> (NameSpaceId -> ModulesInScope -> m ModulesInScope)
-> (NameSpaceId -> InScopeSet -> m InScopeSet)
-> Scope
-> m Scope
mapScopeM ((NamesInScope -> m NamesInScope)
-> NameSpaceId -> NamesInScope -> m NamesInScope
forall a b. a -> b -> a
const NamesInScope -> m NamesInScope
fd) ((ModulesInScope -> m ModulesInScope)
-> NameSpaceId -> ModulesInScope -> m ModulesInScope
forall a b. a -> b -> a
const ModulesInScope -> m ModulesInScope
fm) ((InScopeSet -> m InScopeSet)
-> NameSpaceId -> InScopeSet -> m InScopeSet
forall a b. a -> b -> a
const InScopeSet -> m InScopeSet
fs)
zipScope :: (NameSpaceId -> NamesInScope -> NamesInScope -> NamesInScope ) ->
(NameSpaceId -> ModulesInScope -> ModulesInScope -> ModulesInScope) ->
(NameSpaceId -> InScopeSet -> InScopeSet -> InScopeSet ) ->
Scope -> Scope -> Scope
zipScope :: (NameSpaceId -> NamesInScope -> NamesInScope -> NamesInScope)
-> (NameSpaceId
-> ModulesInScope -> ModulesInScope -> ModulesInScope)
-> (NameSpaceId -> InScopeSet -> InScopeSet -> InScopeSet)
-> Scope
-> Scope
-> Scope
zipScope NameSpaceId -> NamesInScope -> NamesInScope -> NamesInScope
fd NameSpaceId -> ModulesInScope -> ModulesInScope -> ModulesInScope
fm NameSpaceId -> InScopeSet -> InScopeSet -> InScopeSet
fs Scope
s1 Scope
s2 =
Scope
s1 { scopeNameSpaces :: ScopeNameSpaces
scopeNameSpaces =
[ (NameSpaceId
nsid, NameSpaceId -> NameSpace -> NameSpace -> NameSpace
zipNS NameSpaceId
nsid NameSpace
ns1 NameSpace
ns2)
| ((NameSpaceId
nsid, NameSpace
ns1), (NameSpaceId
nsid', NameSpace
ns2)) <-
[((NameSpaceId, NameSpace), (NameSpaceId, NameSpace))]
-> Maybe [((NameSpaceId, NameSpace), (NameSpaceId, NameSpace))]
-> [((NameSpaceId, NameSpace), (NameSpaceId, NameSpace))]
forall a. a -> Maybe a -> a
fromMaybe [((NameSpaceId, NameSpace), (NameSpaceId, NameSpace))]
forall a. HasCallStack => a
__IMPOSSIBLE__ (Maybe [((NameSpaceId, NameSpace), (NameSpaceId, NameSpace))]
-> [((NameSpaceId, NameSpace), (NameSpaceId, NameSpace))])
-> Maybe [((NameSpaceId, NameSpace), (NameSpaceId, NameSpace))]
-> [((NameSpaceId, NameSpace), (NameSpaceId, NameSpace))]
forall a b. (a -> b) -> a -> b
$
((NameSpaceId, NameSpace)
-> (NameSpaceId, NameSpace)
-> ((NameSpaceId, NameSpace), (NameSpaceId, NameSpace)))
-> ScopeNameSpaces
-> ScopeNameSpaces
-> Maybe [((NameSpaceId, NameSpace), (NameSpaceId, NameSpace))]
forall a b c. (a -> b -> c) -> [a] -> [b] -> Maybe [c]
zipWith' (,) (Scope -> ScopeNameSpaces
scopeNameSpaces Scope
s1) (Scope -> ScopeNameSpaces
scopeNameSpaces Scope
s2)
, Bool -> Bool
assert (NameSpaceId
nsid NameSpaceId -> NameSpaceId -> Bool
forall a. Eq a => a -> a -> Bool
== NameSpaceId
nsid')
]
, scopeImports :: Map QName ModuleName
scopeImports = (Map QName ModuleName
-> Map QName ModuleName -> Map QName ModuleName
forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union (Map QName ModuleName
-> Map QName ModuleName -> Map QName ModuleName)
-> (Scope -> Map QName ModuleName)
-> Scope
-> Scope
-> Map QName ModuleName
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Scope -> Map QName ModuleName
scopeImports) Scope
s1 Scope
s2
}
where
assert :: Bool -> Bool
assert Bool
True = Bool
True
assert Bool
False = Bool
forall a. HasCallStack => a
__IMPOSSIBLE__
zipNS :: NameSpaceId -> NameSpace -> NameSpace -> NameSpace
zipNS NameSpaceId
acc = (NamesInScope -> NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet -> InScopeSet)
-> NameSpace
-> NameSpace
-> NameSpace
zipNameSpace (NameSpaceId -> NamesInScope -> NamesInScope -> NamesInScope
fd NameSpaceId
acc) (NameSpaceId -> ModulesInScope -> ModulesInScope -> ModulesInScope
fm NameSpaceId
acc) (NameSpaceId -> InScopeSet -> InScopeSet -> InScopeSet
fs NameSpaceId
acc)
zipScope_ :: (NamesInScope -> NamesInScope -> NamesInScope ) ->
(ModulesInScope -> ModulesInScope -> ModulesInScope) ->
(InScopeSet -> InScopeSet -> InScopeSet ) ->
Scope -> Scope -> Scope
zipScope_ :: (NamesInScope -> NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet -> InScopeSet)
-> Scope
-> Scope
-> Scope
zipScope_ NamesInScope -> NamesInScope -> NamesInScope
fd ModulesInScope -> ModulesInScope -> ModulesInScope
fm InScopeSet -> InScopeSet -> InScopeSet
fs = (NameSpaceId -> NamesInScope -> NamesInScope -> NamesInScope)
-> (NameSpaceId
-> ModulesInScope -> ModulesInScope -> ModulesInScope)
-> (NameSpaceId -> InScopeSet -> InScopeSet -> InScopeSet)
-> Scope
-> Scope
-> Scope
zipScope ((NamesInScope -> NamesInScope -> NamesInScope)
-> NameSpaceId -> NamesInScope -> NamesInScope -> NamesInScope
forall a b. a -> b -> a
const NamesInScope -> NamesInScope -> NamesInScope
fd) ((ModulesInScope -> ModulesInScope -> ModulesInScope)
-> NameSpaceId
-> ModulesInScope
-> ModulesInScope
-> ModulesInScope
forall a b. a -> b -> a
const ModulesInScope -> ModulesInScope -> ModulesInScope
fm) ((InScopeSet -> InScopeSet -> InScopeSet)
-> NameSpaceId -> InScopeSet -> InScopeSet -> InScopeSet
forall a b. a -> b -> a
const InScopeSet -> InScopeSet -> InScopeSet
fs)
recomputeInScopeSets :: Scope -> Scope
recomputeInScopeSets :: Scope -> Scope
recomputeInScopeSets = (ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope
updateScopeNameSpaces (((NameSpaceId, NameSpace) -> (NameSpaceId, NameSpace))
-> ScopeNameSpaces -> ScopeNameSpaces
forall a b. (a -> b) -> [a] -> [b]
map (((NameSpaceId, NameSpace) -> (NameSpaceId, NameSpace))
-> ScopeNameSpaces -> ScopeNameSpaces)
-> ((NameSpaceId, NameSpace) -> (NameSpaceId, NameSpace))
-> ScopeNameSpaces
-> ScopeNameSpaces
forall a b. (a -> b) -> a -> b
$ (NameSpace -> NameSpace)
-> (NameSpaceId, NameSpace) -> (NameSpaceId, NameSpace)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second NameSpace -> NameSpace
recomputeInScope)
where
recomputeInScope :: NameSpace -> NameSpace
recomputeInScope NameSpace
ns = NameSpace
ns { nsInScope :: InScopeSet
nsInScope = NamesInScope -> InScopeSet
allANames (NamesInScope -> InScopeSet) -> NamesInScope -> InScopeSet
forall a b. (a -> b) -> a -> b
$ NameSpace -> NamesInScope
nsNames NameSpace
ns }
allANames :: NamesInScope -> InScopeSet
allANames :: NamesInScope -> InScopeSet
allANames = [QName] -> InScopeSet
forall a. Ord a => [a] -> Set a
Set.fromList ([QName] -> InScopeSet)
-> (NamesInScope -> [QName]) -> NamesInScope -> InScopeSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AbstractName -> QName) -> [AbstractName] -> [QName]
forall a b. (a -> b) -> [a] -> [b]
map AbstractName -> QName
anameName ([AbstractName] -> [QName])
-> (NamesInScope -> [AbstractName]) -> NamesInScope -> [QName]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[AbstractName]] -> [AbstractName]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[AbstractName]] -> [AbstractName])
-> (NamesInScope -> [[AbstractName]])
-> NamesInScope
-> [AbstractName]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NamesInScope -> [[AbstractName]]
forall k a. Map k a -> [a]
Map.elems
filterScope :: (C.Name -> Bool) -> (C.Name -> Bool) -> Scope -> Scope
filterScope :: (Name -> Bool) -> (Name -> Bool) -> Scope -> Scope
filterScope Name -> Bool
pd Name -> Bool
pm = Scope -> Scope
recomputeInScopeSets (Scope -> Scope) -> (Scope -> Scope) -> Scope -> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScope_ ((Name -> Bool) -> NamesInScope -> NamesInScope
forall k a. (k -> Bool) -> Map k a -> Map k a
Map.filterKeys Name -> Bool
pd) ((Name -> Bool) -> ModulesInScope -> ModulesInScope
forall k a. (k -> Bool) -> Map k a -> Map k a
Map.filterKeys Name -> Bool
pm) InScopeSet -> InScopeSet
forall a. a -> a
id
allNamesInScope :: InScope a => Scope -> ThingsInScope a
allNamesInScope :: Scope -> ThingsInScope a
allNamesInScope = [ThingsInScope a] -> ThingsInScope a
forall a. Eq a => [ThingsInScope a] -> ThingsInScope a
mergeNamesMany ([ThingsInScope a] -> ThingsInScope a)
-> (Scope -> [ThingsInScope a]) -> Scope -> ThingsInScope a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((NameSpaceId, NameSpace) -> ThingsInScope a)
-> ScopeNameSpaces -> [ThingsInScope a]
forall a b. (a -> b) -> [a] -> [b]
map (NameSpace -> ThingsInScope a
forall a. InScope a => NameSpace -> ThingsInScope a
inNameSpace (NameSpace -> ThingsInScope a)
-> ((NameSpaceId, NameSpace) -> NameSpace)
-> (NameSpaceId, NameSpace)
-> ThingsInScope a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NameSpaceId, NameSpace) -> NameSpace
forall a b. (a, b) -> b
snd) (ScopeNameSpaces -> [ThingsInScope a])
-> (Scope -> ScopeNameSpaces) -> Scope -> [ThingsInScope a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Scope -> ScopeNameSpaces
scopeNameSpaces
allNamesInScope' :: InScope a => Scope -> ThingsInScope (a, Access)
allNamesInScope' :: Scope -> ThingsInScope (a, Access)
allNamesInScope' Scope
s =
[ThingsInScope (a, Access)] -> ThingsInScope (a, Access)
forall a. Eq a => [ThingsInScope a] -> ThingsInScope a
mergeNamesMany [ (a -> (a, Access)) -> [a] -> [(a, Access)]
forall a b. (a -> b) -> [a] -> [b]
map (, NameSpaceId -> Access
nameSpaceAccess NameSpaceId
nsId) ([a] -> [(a, Access)]) -> Map Name [a] -> ThingsInScope (a, Access)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameSpace -> Map Name [a]
forall a. InScope a => NameSpace -> ThingsInScope a
inNameSpace NameSpace
ns
| (NameSpaceId
nsId, NameSpace
ns) <- Scope -> ScopeNameSpaces
scopeNameSpaces Scope
s ]
exportedNamesInScope :: InScope a => Scope -> ThingsInScope a
exportedNamesInScope :: Scope -> ThingsInScope a
exportedNamesInScope = [NameSpaceId] -> Scope -> ThingsInScope a
forall a. InScope a => [NameSpaceId] -> Scope -> ThingsInScope a
namesInScope [NameSpaceId
PublicNS, NameSpaceId
ImportedNS]
namesInScope :: InScope a => [NameSpaceId] -> Scope -> ThingsInScope a
namesInScope :: [NameSpaceId] -> Scope -> ThingsInScope a
namesInScope [NameSpaceId]
ids Scope
s =
[ThingsInScope a] -> ThingsInScope a
forall a. Eq a => [ThingsInScope a] -> ThingsInScope a
mergeNamesMany [ NameSpace -> ThingsInScope a
forall a. InScope a => NameSpace -> ThingsInScope a
inNameSpace (NameSpaceId -> Scope -> NameSpace
scopeNameSpace NameSpaceId
nsid Scope
s) | NameSpaceId
nsid <- [NameSpaceId]
ids ]
allThingsInScope :: Scope -> NameSpace
allThingsInScope :: Scope -> NameSpace
allThingsInScope Scope
s =
NameSpace :: NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace
NameSpace { nsNames :: NamesInScope
nsNames = Scope -> NamesInScope
forall a. InScope a => Scope -> ThingsInScope a
allNamesInScope Scope
s
, nsModules :: ModulesInScope
nsModules = Scope -> ModulesInScope
forall a. InScope a => Scope -> ThingsInScope a
allNamesInScope Scope
s
, nsInScope :: InScopeSet
nsInScope = [InScopeSet] -> InScopeSet
forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions ([InScopeSet] -> InScopeSet) -> [InScopeSet] -> InScopeSet
forall a b. (a -> b) -> a -> b
$ ((NameSpaceId, NameSpace) -> InScopeSet)
-> ScopeNameSpaces -> [InScopeSet]
forall a b. (a -> b) -> [a] -> [b]
map (NameSpace -> InScopeSet
nsInScope (NameSpace -> InScopeSet)
-> ((NameSpaceId, NameSpace) -> NameSpace)
-> (NameSpaceId, NameSpace)
-> InScopeSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NameSpaceId, NameSpace) -> NameSpace
forall a b. (a, b) -> b
snd) (ScopeNameSpaces -> [InScopeSet])
-> ScopeNameSpaces -> [InScopeSet]
forall a b. (a -> b) -> a -> b
$ Scope -> ScopeNameSpaces
scopeNameSpaces Scope
s
}
thingsInScope :: [NameSpaceId] -> Scope -> NameSpace
thingsInScope :: [NameSpaceId] -> Scope -> NameSpace
thingsInScope [NameSpaceId]
fs Scope
s =
NameSpace :: NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace
NameSpace { nsNames :: NamesInScope
nsNames = [NameSpaceId] -> Scope -> NamesInScope
forall a. InScope a => [NameSpaceId] -> Scope -> ThingsInScope a
namesInScope [NameSpaceId]
fs Scope
s
, nsModules :: ModulesInScope
nsModules = [NameSpaceId] -> Scope -> ModulesInScope
forall a. InScope a => [NameSpaceId] -> Scope -> ThingsInScope a
namesInScope [NameSpaceId]
fs Scope
s
, nsInScope :: InScopeSet
nsInScope = [InScopeSet] -> InScopeSet
forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions [ NameSpace -> InScopeSet
nsInScope (NameSpace -> InScopeSet) -> NameSpace -> InScopeSet
forall a b. (a -> b) -> a -> b
$ NameSpaceId -> Scope -> NameSpace
scopeNameSpace NameSpaceId
nsid Scope
s | NameSpaceId
nsid <- [NameSpaceId]
fs ]
}
mergeScope :: Scope -> Scope -> Scope
mergeScope :: Scope -> Scope -> Scope
mergeScope = (NamesInScope -> NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet -> InScopeSet)
-> Scope
-> Scope
-> Scope
zipScope_ NamesInScope -> NamesInScope -> NamesInScope
forall a.
Eq a =>
ThingsInScope a -> ThingsInScope a -> ThingsInScope a
mergeNames ModulesInScope -> ModulesInScope -> ModulesInScope
forall a.
Eq a =>
ThingsInScope a -> ThingsInScope a -> ThingsInScope a
mergeNames InScopeSet -> InScopeSet -> InScopeSet
forall a. Ord a => Set a -> Set a -> Set a
Set.union
mergeScopes :: [Scope] -> Scope
mergeScopes :: [Scope] -> Scope
mergeScopes [] = Scope
forall a. HasCallStack => a
__IMPOSSIBLE__
mergeScopes [Scope]
ss = (Scope -> Scope -> Scope) -> [Scope] -> Scope
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 Scope -> Scope -> Scope
mergeScope [Scope]
ss
setScopeAccess :: NameSpaceId -> Scope -> Scope
setScopeAccess :: NameSpaceId -> Scope -> Scope
setScopeAccess NameSpaceId
a Scope
s = ((ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope
`updateScopeNameSpaces` Scope
s) ((ScopeNameSpaces -> ScopeNameSpaces) -> Scope)
-> (ScopeNameSpaces -> ScopeNameSpaces) -> Scope
forall a b. (a -> b) -> a -> b
$ (NameSpaceId -> NameSpace -> NameSpace)
-> ScopeNameSpaces -> ScopeNameSpaces
forall k v. (k -> v -> v) -> AssocList k v -> AssocList k v
AssocList.mapWithKey ((NameSpaceId -> NameSpace -> NameSpace)
-> ScopeNameSpaces -> ScopeNameSpaces)
-> (NameSpaceId -> NameSpace -> NameSpace)
-> ScopeNameSpaces
-> ScopeNameSpaces
forall a b. (a -> b) -> a -> b
$ NameSpace -> NameSpace -> NameSpace
forall a b. a -> b -> a
const (NameSpace -> NameSpace -> NameSpace)
-> (NameSpaceId -> NameSpace)
-> NameSpaceId
-> NameSpace
-> NameSpace
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpaceId -> NameSpace
ns
where
zero :: NameSpace
zero = NameSpace
emptyNameSpace
one :: NameSpace
one = Scope -> NameSpace
allThingsInScope Scope
s
imp :: NameSpace
imp = [NameSpaceId] -> Scope -> NameSpace
thingsInScope [NameSpaceId
ImportedNS] Scope
s
noimp :: NameSpace
noimp = [NameSpaceId] -> Scope -> NameSpace
thingsInScope [NameSpaceId
PublicNS, NameSpaceId
PrivateNS] Scope
s
ns :: NameSpaceId -> NameSpace
ns NameSpaceId
b = case (NameSpaceId
a, NameSpaceId
b) of
(NameSpaceId
PublicNS, NameSpaceId
PublicNS) -> NameSpace
noimp
(NameSpaceId
PublicNS, NameSpaceId
ImportedNS) -> NameSpace
imp
(NameSpaceId, NameSpaceId)
_ | NameSpaceId
a NameSpaceId -> NameSpaceId -> Bool
forall a. Eq a => a -> a -> Bool
== NameSpaceId
b -> NameSpace
one
| Bool
otherwise -> NameSpace
zero
setNameSpace :: NameSpaceId -> NameSpace -> Scope -> Scope
setNameSpace :: NameSpaceId -> NameSpace -> Scope -> Scope
setNameSpace NameSpaceId
nsid NameSpace
ns = NameSpaceId -> (NameSpace -> NameSpace) -> Scope -> Scope
modifyNameSpace NameSpaceId
nsid ((NameSpace -> NameSpace) -> Scope -> Scope)
-> (NameSpace -> NameSpace) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ NameSpace -> NameSpace -> NameSpace
forall a b. a -> b -> a
const NameSpace
ns
modifyNameSpace :: NameSpaceId -> (NameSpace -> NameSpace) -> Scope -> Scope
modifyNameSpace :: NameSpaceId -> (NameSpace -> NameSpace) -> Scope -> Scope
modifyNameSpace NameSpaceId
nsid NameSpace -> NameSpace
f = (ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope
updateScopeNameSpaces ((ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope)
-> (ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ NameSpaceId
-> (NameSpace -> NameSpace) -> ScopeNameSpaces -> ScopeNameSpaces
forall k v. Eq k => k -> (v -> v) -> AssocList k v -> AssocList k v
AssocList.updateAt NameSpaceId
nsid NameSpace -> NameSpace
f
addNameToScope :: NameSpaceId -> C.Name -> AbstractName -> Scope -> Scope
addNameToScope :: NameSpaceId -> Name -> AbstractName -> Scope -> Scope
addNameToScope NameSpaceId
nsid Name
x AbstractName
y =
NameSpaceId
-> (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScopeNS NameSpaceId
nsid
(([AbstractName] -> [AbstractName] -> [AbstractName])
-> Name -> [AbstractName] -> NamesInScope -> NamesInScope
forall k a. Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
Map.insertWith (([AbstractName] -> [AbstractName] -> [AbstractName])
-> [AbstractName] -> [AbstractName] -> [AbstractName]
forall a b c. (a -> b -> c) -> b -> a -> c
flip [AbstractName] -> [AbstractName] -> [AbstractName]
forall a. Eq a => [a] -> [a] -> [a]
List.union) Name
x [AbstractName
y])
ModulesInScope -> ModulesInScope
forall a. a -> a
id
(QName -> InScopeSet -> InScopeSet
forall a. Ord a => a -> Set a -> Set a
Set.insert (QName -> InScopeSet -> InScopeSet)
-> QName -> InScopeSet -> InScopeSet
forall a b. (a -> b) -> a -> b
$ AbstractName -> QName
anameName AbstractName
y)
removeNameFromScope :: NameSpaceId -> C.Name -> Scope -> Scope
removeNameFromScope :: NameSpaceId -> Name -> Scope -> Scope
removeNameFromScope NameSpaceId
nsid Name
x = NameSpaceId
-> (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScopeNS NameSpaceId
nsid (Name -> NamesInScope -> NamesInScope
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete Name
x) ModulesInScope -> ModulesInScope
forall a. a -> a
id InScopeSet -> InScopeSet
forall a. a -> a
id
addModuleToScope :: NameSpaceId -> C.Name -> AbstractModule -> Scope -> Scope
addModuleToScope :: NameSpaceId -> Name -> AbstractModule -> Scope -> Scope
addModuleToScope NameSpaceId
nsid Name
x AbstractModule
m = NameSpaceId
-> (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScopeNS NameSpaceId
nsid NamesInScope -> NamesInScope
forall a. a -> a
id ModulesInScope -> ModulesInScope
addM InScopeSet -> InScopeSet
forall a. a -> a
id
where addM :: ModulesInScope -> ModulesInScope
addM = ([AbstractModule] -> [AbstractModule] -> [AbstractModule])
-> Name -> [AbstractModule] -> ModulesInScope -> ModulesInScope
forall k a. Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
Map.insertWith (([AbstractModule] -> [AbstractModule] -> [AbstractModule])
-> [AbstractModule] -> [AbstractModule] -> [AbstractModule]
forall a b c. (a -> b -> c) -> b -> a -> c
flip [AbstractModule] -> [AbstractModule] -> [AbstractModule]
forall a. Eq a => [a] -> [a] -> [a]
List.union) Name
x [AbstractModule
m]
data UsingOrHiding
= UsingOnly [C.ImportedName]
| HidingOnly [C.ImportedName]
usingOrHiding :: C.ImportDirective -> UsingOrHiding
usingOrHiding :: ImportDirective -> UsingOrHiding
usingOrHiding ImportDirective
i =
case (ImportDirective -> Using' Name Name
forall n m. ImportDirective' n m -> Using' n m
using ImportDirective
i, ImportDirective -> [ImportedName' Name Name]
forall n m. ImportDirective' n m -> [ImportedName' n m]
hiding ImportDirective
i) of
(Using' Name Name
UseEverything, [ImportedName' Name Name]
ys) -> [ImportedName' Name Name] -> UsingOrHiding
HidingOnly [ImportedName' Name Name]
ys
(Using [ImportedName' Name Name]
xs , []) -> [ImportedName' Name Name] -> UsingOrHiding
UsingOnly [ImportedName' Name Name]
xs
(Using' Name Name, [ImportedName' Name Name])
_ -> UsingOrHiding
forall a. HasCallStack => a
__IMPOSSIBLE__
applyImportDirective :: C.ImportDirective -> Scope -> Scope
applyImportDirective :: ImportDirective -> Scope -> Scope
applyImportDirective ImportDirective
dir = (Scope, (Set Name, Set Name)) -> Scope
forall a b. (a, b) -> a
fst ((Scope, (Set Name, Set Name)) -> Scope)
-> (Scope -> (Scope, (Set Name, Set Name))) -> Scope -> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ImportDirective -> Scope -> (Scope, (Set Name, Set Name))
applyImportDirective_ ImportDirective
dir
applyImportDirective_
:: C.ImportDirective
-> Scope
-> (Scope, (Set C.Name, Set C.Name))
applyImportDirective_ :: ImportDirective -> Scope -> (Scope, (Set Name, Set Name))
applyImportDirective_ dir :: ImportDirective
dir@(ImportDirective{ [Renaming' Name Name]
impRenaming :: forall n m. ImportDirective' n m -> [Renaming' n m]
impRenaming :: [Renaming' Name Name]
impRenaming }) Scope
s
| ImportDirective -> Bool
forall a. Null a => a -> Bool
null ImportDirective
dir = (Scope
s, (Set Name
forall a. Null a => a
empty, Set Name
forall a. Null a => a
empty))
| Bool
otherwise = (Scope -> Scope
recomputeInScopeSets (Scope -> Scope) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ Scope -> Scope -> Scope
mergeScope Scope
sUse Scope
sRen, (Set Name
nameClashes, Set Name
moduleClashes))
where
sUse :: Scope
sUse :: Scope
sUse = UsingOrHiding -> Scope -> Scope
useOrHide (ImportDirective -> UsingOrHiding
usingOrHiding ImportDirective
dir) Scope
s
sRen :: Scope
sRen :: Scope
sRen = [Renaming' Name Name] -> Scope -> Scope
rename [Renaming' Name Name]
impRenaming Scope
s
exportedNSs :: [NameSpaceId]
exportedNSs = [NameSpaceId
PublicNS, NameSpaceId
ImportedNS]
nameClashes :: Set C.Name
nameClashes :: Set Name
nameClashes = NamesInScope -> Set Name
forall k a. Map k a -> Set k
Map.keysSet NamesInScope
rNames Set Name -> Set Name -> Set Name
forall a. Ord a => Set a -> Set a -> Set a
`Set.intersection` NamesInScope -> Set Name
forall k a. Map k a -> Set k
Map.keysSet NamesInScope
uNames
where
uNames, rNames :: NamesInScope
uNames :: NamesInScope
uNames = [NameSpaceId] -> Scope -> NamesInScope
forall a. InScope a => [NameSpaceId] -> Scope -> ThingsInScope a
namesInScope [NameSpaceId]
exportedNSs Scope
sUse
rNames :: NamesInScope
rNames = [NameSpaceId] -> Scope -> NamesInScope
forall a. InScope a => [NameSpaceId] -> Scope -> ThingsInScope a
namesInScope [NameSpaceId]
exportedNSs Scope
sRen
moduleClashes :: Set C.Name
moduleClashes :: Set Name
moduleClashes = ModulesInScope -> Set Name
forall k a. Map k a -> Set k
Map.keysSet ModulesInScope
uModules Set Name -> Set Name -> Set Name
forall a. Ord a => Set a -> Set a -> Set a
`Set.intersection` ModulesInScope -> Set Name
forall k a. Map k a -> Set k
Map.keysSet ModulesInScope
rModules
where
uModules, rModules :: ModulesInScope
uModules :: ModulesInScope
uModules = [NameSpaceId] -> Scope -> ModulesInScope
forall a. InScope a => [NameSpaceId] -> Scope -> ThingsInScope a
namesInScope [NameSpaceId]
exportedNSs Scope
sUse
rModules :: ModulesInScope
rModules = [NameSpaceId] -> Scope -> ModulesInScope
forall a. InScope a => [NameSpaceId] -> Scope -> ThingsInScope a
namesInScope [NameSpaceId]
exportedNSs Scope
sRen
useOrHide :: UsingOrHiding -> Scope -> Scope
useOrHide :: UsingOrHiding -> Scope -> Scope
useOrHide (UsingOnly [ImportedName' Name Name]
xs) = (Name -> Set Name -> Bool)
-> [ImportedName' Name Name] -> Scope -> Scope
filterNames Name -> Set Name -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member [ImportedName' Name Name]
xs
useOrHide (HidingOnly [ImportedName' Name Name]
xs) = (Name -> Set Name -> Bool)
-> [ImportedName' Name Name] -> Scope -> Scope
filterNames Name -> Set Name -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.notMember ([ImportedName' Name Name] -> Scope -> Scope)
-> [ImportedName' Name Name] -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ (Renaming' Name Name -> ImportedName' Name Name)
-> [Renaming' Name Name] -> [ImportedName' Name Name]
forall a b. (a -> b) -> [a] -> [b]
map Renaming' Name Name -> ImportedName' Name Name
forall n m. Renaming' n m -> ImportedName' n m
renFrom [Renaming' Name Name]
impRenaming [ImportedName' Name Name]
-> [ImportedName' Name Name] -> [ImportedName' Name Name]
forall a. [a] -> [a] -> [a]
++ [ImportedName' Name Name]
xs
filterNames :: (C.Name -> Set C.Name -> Bool) -> [C.ImportedName] ->
Scope -> Scope
filterNames :: (Name -> Set Name -> Bool)
-> [ImportedName' Name Name] -> Scope -> Scope
filterNames Name -> Set Name -> Bool
rel [ImportedName' Name Name]
xs = (Name -> Bool) -> (Name -> Bool) -> Scope -> Scope
filterScope (Name -> Set Name -> Bool
`rel` [Name] -> Set Name
forall a. Ord a => [a] -> Set a
Set.fromList [Name]
ds) (Name -> Set Name -> Bool
`rel` [Name] -> Set Name
forall a. Ord a => [a] -> Set a
Set.fromList [Name]
ms)
where
([Name]
ds, [Name]
ms) = [Either Name Name] -> ([Name], [Name])
forall a b. [Either a b] -> ([a], [b])
partitionEithers ([Either Name Name] -> ([Name], [Name]))
-> [Either Name Name] -> ([Name], [Name])
forall a b. (a -> b) -> a -> b
$ [ImportedName' Name Name]
-> (ImportedName' Name Name -> Either Name Name)
-> [Either Name Name]
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
for [ImportedName' Name Name]
xs ((ImportedName' Name Name -> Either Name Name)
-> [Either Name Name])
-> (ImportedName' Name Name -> Either Name Name)
-> [Either Name Name]
forall a b. (a -> b) -> a -> b
$ \case
ImportedName Name
x -> Name -> Either Name Name
forall a b. a -> Either a b
Left Name
x
ImportedModule Name
m -> Name -> Either Name Name
forall a b. b -> Either a b
Right Name
m
rename :: [C.Renaming] -> Scope -> Scope
rename :: [Renaming' Name Name] -> Scope -> Scope
rename [Renaming' Name Name]
rho = (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScope_ (NamesInScope -> NamesInScope
updateFxs (NamesInScope -> NamesInScope)
-> (NamesInScope -> NamesInScope) -> NamesInScope -> NamesInScope
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
(Name -> Maybe Name) -> NamesInScope -> NamesInScope
forall a.
SetBindingSite a =>
(Name -> Maybe Name) -> ThingsInScope a -> ThingsInScope a
updateThingsInScope (AssocList Name Name -> Name -> Maybe Name
forall k v. Ord k => AssocList k v -> k -> Maybe v
AssocList.apply AssocList Name Name
drho))
((Name -> Maybe Name) -> ModulesInScope -> ModulesInScope
forall a.
SetBindingSite a =>
(Name -> Maybe Name) -> ThingsInScope a -> ThingsInScope a
updateThingsInScope (AssocList Name Name -> Name -> Maybe Name
forall k v. Ord k => AssocList k v -> k -> Maybe v
AssocList.apply AssocList Name Name
mrho))
InScopeSet -> InScopeSet
forall a. a -> a
id
where
(AssocList Name Name
drho, AssocList Name Name
mrho) = [Either (Name, Name) (Name, Name)]
-> (AssocList Name Name, AssocList Name Name)
forall a b. [Either a b] -> ([a], [b])
partitionEithers ([Either (Name, Name) (Name, Name)]
-> (AssocList Name Name, AssocList Name Name))
-> [Either (Name, Name) (Name, Name)]
-> (AssocList Name Name, AssocList Name Name)
forall a b. (a -> b) -> a -> b
$ [Renaming' Name Name]
-> (Renaming' Name Name -> Either (Name, Name) (Name, Name))
-> [Either (Name, Name) (Name, Name)]
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
for [Renaming' Name Name]
rho ((Renaming' Name Name -> Either (Name, Name) (Name, Name))
-> [Either (Name, Name) (Name, Name)])
-> (Renaming' Name Name -> Either (Name, Name) (Name, Name))
-> [Either (Name, Name) (Name, Name)]
forall a b. (a -> b) -> a -> b
$ \case
Renaming (ImportedName Name
x) (ImportedName Name
y) Maybe Fixity
_fx Range
_ -> (Name, Name) -> Either (Name, Name) (Name, Name)
forall a b. a -> Either a b
Left (Name
x, Name
y)
Renaming (ImportedModule Name
x) (ImportedModule Name
y) Maybe Fixity
_fx Range
_ -> (Name, Name) -> Either (Name, Name) (Name, Name)
forall a b. b -> Either a b
Right (Name
x, Name
y)
Renaming' Name Name
_ -> Either (Name, Name) (Name, Name)
forall a. HasCallStack => a
__IMPOSSIBLE__
fixities :: AssocList C.Name Fixity
fixities :: AssocList Name Fixity
fixities = ((Renaming' Name Name -> Maybe (Name, Fixity))
-> [Renaming' Name Name] -> AssocList Name Fixity
forall a b. (a -> Maybe b) -> [a] -> [b]
`mapMaybe` [Renaming' Name Name]
rho) ((Renaming' Name Name -> Maybe (Name, Fixity))
-> AssocList Name Fixity)
-> (Renaming' Name Name -> Maybe (Name, Fixity))
-> AssocList Name Fixity
forall a b. (a -> b) -> a -> b
$ \case
Renaming ImportedName' Name Name
_ (ImportedName Name
y) (Just Fixity
fx) Range
_ -> (Name, Fixity) -> Maybe (Name, Fixity)
forall a. a -> Maybe a
Just (Name
y, Fixity
fx)
Renaming' Name Name
_ -> Maybe (Name, Fixity)
forall a. Maybe a
Nothing
updateFxs :: NamesInScope -> NamesInScope
updateFxs :: NamesInScope -> NamesInScope
updateFxs NamesInScope
m = (NamesInScope -> (Name, Fixity) -> NamesInScope)
-> NamesInScope -> AssocList Name Fixity -> NamesInScope
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl NamesInScope -> (Name, Fixity) -> NamesInScope
forall k b.
(Ord k, LensFixity b) =>
Map k [b] -> (k, Fixity) -> Map k [b]
upd NamesInScope
m AssocList Name Fixity
fixities
where
upd :: Map k [b] -> (k, Fixity) -> Map k [b]
upd Map k [b]
m (k
y, Fixity
fx) = ([b] -> [b]) -> k -> Map k [b] -> Map k [b]
forall k a. Ord k => (a -> a) -> k -> Map k a -> Map k a
Map.adjust ((b -> b) -> [b] -> [b]
forall a b. (a -> b) -> [a] -> [b]
map ((b -> b) -> [b] -> [b]) -> (b -> b) -> [b] -> [b]
forall a b. (a -> b) -> a -> b
$ Lens' Fixity b -> LensSet Fixity b
forall i o. Lens' i o -> LensSet i o
set forall a. LensFixity a => Lens' Fixity a
Lens' Fixity b
lensFixity Fixity
fx) k
y Map k [b]
m
updateThingsInScope
:: forall a. SetBindingSite a
=> (C.Name -> Maybe C.Name)
-> ThingsInScope a -> ThingsInScope a
updateThingsInScope :: (Name -> Maybe Name) -> ThingsInScope a -> ThingsInScope a
updateThingsInScope Name -> Maybe Name
f = [(Name, [a])] -> ThingsInScope a
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(Name, [a])] -> ThingsInScope a)
-> (ThingsInScope a -> [(Name, [a])])
-> ThingsInScope a
-> ThingsInScope a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Name, [a]) -> Maybe (Name, [a]))
-> [(Name, [a])] -> [(Name, [a])]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Name, [a]) -> Maybe (Name, [a])
upd ([(Name, [a])] -> [(Name, [a])])
-> (ThingsInScope a -> [(Name, [a])])
-> ThingsInScope a
-> [(Name, [a])]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ThingsInScope a -> [(Name, [a])]
forall k a. Map k a -> [(k, a)]
Map.toAscList
where
upd :: (C.Name, [a]) -> Maybe (C.Name, [a])
upd :: (Name, [a]) -> Maybe (Name, [a])
upd (Name
x, [a]
ys) = Name -> Maybe Name
f Name
x Maybe Name -> (Name -> (Name, [a])) -> Maybe (Name, [a])
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Name
x' -> (Name
x', Range -> [a] -> [a]
forall a. SetBindingSite a => Range -> a -> a
setBindingSite (Name -> Range
forall t. HasRange t => t -> Range
getRange Name
x') [a]
ys)
renameCanonicalNames :: Map A.QName A.QName -> Map A.ModuleName A.ModuleName ->
Scope -> Scope
renameCanonicalNames :: Map QName QName -> Map ModuleName ModuleName -> Scope -> Scope
renameCanonicalNames Map QName QName
renD Map ModuleName ModuleName
renM = (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScope_ NamesInScope -> NamesInScope
renameD ModulesInScope -> ModulesInScope
renameM ((QName -> QName) -> InScopeSet -> InScopeSet
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map QName -> QName
newName)
where
newName :: QName -> QName
newName QName
x = QName -> QName -> Map QName QName -> QName
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault QName
x QName
x Map QName QName
renD
newMod :: ModuleName -> ModuleName
newMod ModuleName
x = ModuleName -> ModuleName -> Map ModuleName ModuleName -> ModuleName
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault ModuleName
x ModuleName
x Map ModuleName ModuleName
renM
renameD :: NamesInScope -> NamesInScope
renameD = ([AbstractName] -> [AbstractName]) -> NamesInScope -> NamesInScope
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map (([AbstractName] -> [AbstractName])
-> NamesInScope -> NamesInScope)
-> ([AbstractName] -> [AbstractName])
-> NamesInScope
-> NamesInScope
forall a b. (a -> b) -> a -> b
$ (AbstractName -> AbstractName) -> [AbstractName] -> [AbstractName]
forall a b. (a -> b) -> [a] -> [b]
map ((AbstractName -> AbstractName)
-> [AbstractName] -> [AbstractName])
-> (AbstractName -> AbstractName)
-> [AbstractName]
-> [AbstractName]
forall a b. (a -> b) -> a -> b
$ (forall (m :: * -> *).
Functor m =>
(QName -> m QName) -> AbstractName -> m AbstractName)
-> LensMap QName AbstractName
forall i o. Lens' i o -> LensMap i o
over forall (m :: * -> *).
Functor m =>
(QName -> m QName) -> AbstractName -> m AbstractName
lensAnameName QName -> QName
newName
renameM :: ModulesInScope -> ModulesInScope
renameM = ([AbstractModule] -> [AbstractModule])
-> ModulesInScope -> ModulesInScope
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map (([AbstractModule] -> [AbstractModule])
-> ModulesInScope -> ModulesInScope)
-> ([AbstractModule] -> [AbstractModule])
-> ModulesInScope
-> ModulesInScope
forall a b. (a -> b) -> a -> b
$ (AbstractModule -> AbstractModule)
-> [AbstractModule] -> [AbstractModule]
forall a b. (a -> b) -> [a] -> [b]
map ((AbstractModule -> AbstractModule)
-> [AbstractModule] -> [AbstractModule])
-> (AbstractModule -> AbstractModule)
-> [AbstractModule]
-> [AbstractModule]
forall a b. (a -> b) -> a -> b
$ Lens' ModuleName AbstractModule
-> LensMap ModuleName AbstractModule
forall i o. Lens' i o -> LensMap i o
over Lens' ModuleName AbstractModule
lensAmodName ModuleName -> ModuleName
newMod
restrictPrivate :: Scope -> Scope
restrictPrivate :: Scope -> Scope
restrictPrivate Scope
s = NameSpaceId -> NameSpace -> Scope -> Scope
setNameSpace NameSpaceId
PrivateNS NameSpace
emptyNameSpace
(Scope -> Scope) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ Scope
s { scopeImports :: Map QName ModuleName
scopeImports = Map QName ModuleName
forall k a. Map k a
Map.empty }
restrictLocalPrivate :: ModuleName -> Scope -> Scope
restrictLocalPrivate :: ModuleName -> Scope -> Scope
restrictLocalPrivate ModuleName
m =
NameSpaceId
-> (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScopeNS NameSpaceId
PrivateNS
(([AbstractName] -> Maybe [AbstractName])
-> NamesInScope -> NamesInScope
forall a b k. (a -> Maybe b) -> Map k a -> Map k b
Map.mapMaybe [AbstractName] -> Maybe [AbstractName]
rName)
(([AbstractModule] -> Maybe [AbstractModule])
-> ModulesInScope -> ModulesInScope
forall a b k. (a -> Maybe b) -> Map k a -> Map k b
Map.mapMaybe [AbstractModule] -> Maybe [AbstractModule]
rMod)
((QName -> Bool) -> InScopeSet -> InScopeSet
forall a. (a -> Bool) -> Set a -> Set a
Set.filter (Bool -> Bool
not (Bool -> Bool) -> (QName -> Bool) -> QName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QName -> ModuleName -> Bool
`isInModule` ModuleName
m)))
where
rName :: [AbstractName] -> Maybe [AbstractName]
rName [AbstractName]
as = ([AbstractName] -> Bool) -> [AbstractName] -> Maybe [AbstractName]
forall a. (a -> Bool) -> a -> Maybe a
filterMaybe (Bool -> Bool
not (Bool -> Bool)
-> ([AbstractName] -> Bool) -> [AbstractName] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [AbstractName] -> Bool
forall a. Null a => a -> Bool
null) ([AbstractName] -> Maybe [AbstractName])
-> [AbstractName] -> Maybe [AbstractName]
forall a b. (a -> b) -> a -> b
$ (AbstractName -> Bool) -> [AbstractName] -> [AbstractName]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (AbstractName -> Bool) -> AbstractName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QName -> ModuleName -> Bool
`isInModule` ModuleName
m) (QName -> Bool) -> (AbstractName -> QName) -> AbstractName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractName -> QName
anameName) [AbstractName]
as
rMod :: [AbstractModule] -> Maybe [AbstractModule]
rMod [AbstractModule]
as = ([AbstractModule] -> Bool)
-> [AbstractModule] -> Maybe [AbstractModule]
forall a. (a -> Bool) -> a -> Maybe a
filterMaybe (Bool -> Bool
not (Bool -> Bool)
-> ([AbstractModule] -> Bool) -> [AbstractModule] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [AbstractModule] -> Bool
forall a. Null a => a -> Bool
null) ([AbstractModule] -> Maybe [AbstractModule])
-> [AbstractModule] -> Maybe [AbstractModule]
forall a b. (a -> b) -> a -> b
$ (AbstractModule -> Bool) -> [AbstractModule] -> [AbstractModule]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (AbstractModule -> Bool) -> AbstractModule -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ModuleName -> ModuleName -> Bool
`isLtChildModuleOf` ModuleName
m) (ModuleName -> Bool)
-> (AbstractModule -> ModuleName) -> AbstractModule -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractModule -> ModuleName
amodName) [AbstractModule]
as
disallowGeneralizedVars :: Scope -> Scope
disallowGeneralizedVars :: Scope -> Scope
disallowGeneralizedVars = (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScope_ ((([AbstractName] -> [AbstractName]) -> NamesInScope -> NamesInScope
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (([AbstractName] -> [AbstractName])
-> NamesInScope -> NamesInScope)
-> ((AbstractName -> AbstractName)
-> [AbstractName] -> [AbstractName])
-> (AbstractName -> AbstractName)
-> NamesInScope
-> NamesInScope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AbstractName -> AbstractName) -> [AbstractName] -> [AbstractName]
forall a b. (a -> b) -> [a] -> [b]
map) AbstractName -> AbstractName
disallow) ModulesInScope -> ModulesInScope
forall a. a -> a
id InScopeSet -> InScopeSet
forall a. a -> a
id
where
disallow :: AbstractName -> AbstractName
disallow AbstractName
a = AbstractName
a { anameKind :: KindOfName
anameKind = KindOfName -> KindOfName
disallowGen (AbstractName -> KindOfName
anameKind AbstractName
a) }
disallowGen :: KindOfName -> KindOfName
disallowGen KindOfName
GeneralizeName = KindOfName
DisallowedGeneralizeName
disallowGen KindOfName
k = KindOfName
k
inScopeBecause :: (WhyInScope -> WhyInScope) -> Scope -> Scope
inScopeBecause :: (WhyInScope -> WhyInScope) -> Scope -> Scope
inScopeBecause WhyInScope -> WhyInScope
f = (NamesInScope -> NamesInScope)
-> (ModulesInScope -> ModulesInScope)
-> (InScopeSet -> InScopeSet)
-> Scope
-> Scope
mapScope_ NamesInScope -> NamesInScope
mapName ModulesInScope -> ModulesInScope
mapMod InScopeSet -> InScopeSet
forall a. a -> a
id
where
mapName :: NamesInScope -> NamesInScope
mapName = ([AbstractName] -> [AbstractName]) -> NamesInScope -> NamesInScope
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (([AbstractName] -> [AbstractName])
-> NamesInScope -> NamesInScope)
-> ((AbstractName -> AbstractName)
-> [AbstractName] -> [AbstractName])
-> (AbstractName -> AbstractName)
-> NamesInScope
-> NamesInScope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AbstractName -> AbstractName) -> [AbstractName] -> [AbstractName]
forall a b. (a -> b) -> [a] -> [b]
map ((AbstractName -> AbstractName) -> NamesInScope -> NamesInScope)
-> (AbstractName -> AbstractName) -> NamesInScope -> NamesInScope
forall a b. (a -> b) -> a -> b
$ \AbstractName
a -> AbstractName
a { anameLineage :: WhyInScope
anameLineage = WhyInScope -> WhyInScope
f (WhyInScope -> WhyInScope) -> WhyInScope -> WhyInScope
forall a b. (a -> b) -> a -> b
$ AbstractName -> WhyInScope
anameLineage AbstractName
a }
mapMod :: ModulesInScope -> ModulesInScope
mapMod = ([AbstractModule] -> [AbstractModule])
-> ModulesInScope -> ModulesInScope
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (([AbstractModule] -> [AbstractModule])
-> ModulesInScope -> ModulesInScope)
-> ((AbstractModule -> AbstractModule)
-> [AbstractModule] -> [AbstractModule])
-> (AbstractModule -> AbstractModule)
-> ModulesInScope
-> ModulesInScope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AbstractModule -> AbstractModule)
-> [AbstractModule] -> [AbstractModule]
forall a b. (a -> b) -> [a] -> [b]
map ((AbstractModule -> AbstractModule)
-> ModulesInScope -> ModulesInScope)
-> (AbstractModule -> AbstractModule)
-> ModulesInScope
-> ModulesInScope
forall a b. (a -> b) -> a -> b
$ \AbstractModule
a -> AbstractModule
a { amodLineage :: WhyInScope
amodLineage = WhyInScope -> WhyInScope
f (WhyInScope -> WhyInScope) -> WhyInScope -> WhyInScope
forall a b. (a -> b) -> a -> b
$ AbstractModule -> WhyInScope
amodLineage AbstractModule
a }
publicModules :: ScopeInfo -> Map A.ModuleName Scope
publicModules :: ScopeInfo -> Map ModuleName Scope
publicModules ScopeInfo
scope = (ModuleName -> Scope -> Bool)
-> Map ModuleName Scope -> Map ModuleName Scope
forall k a. (k -> a -> Bool) -> Map k a -> Map k a
Map.filterWithKey (\ ModuleName
m Scope
_ -> ModuleName -> Bool
reachable ModuleName
m) Map ModuleName Scope
allMods
where
allMods :: Map ModuleName Scope
allMods = (Scope -> Scope) -> Map ModuleName Scope -> Map ModuleName Scope
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map Scope -> Scope
restrictPrivate (Map ModuleName Scope -> Map ModuleName Scope)
-> Map ModuleName Scope -> Map ModuleName Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo
-> Lens' (Map ModuleName Scope) ScopeInfo -> Map ModuleName Scope
forall o i. o -> Lens' i o -> i
^. Lens' (Map ModuleName Scope) ScopeInfo
scopeModules
root :: ModuleName
root = ScopeInfo
scope ScopeInfo -> Lens' ModuleName ScopeInfo -> ModuleName
forall o i. o -> Lens' i o -> i
^. Lens' ModuleName ScopeInfo
scopeCurrent
modules :: Scope -> [ModuleName]
modules Scope
s = (AbstractModule -> ModuleName) -> [AbstractModule] -> [ModuleName]
forall a b. (a -> b) -> [a] -> [b]
map AbstractModule -> ModuleName
amodName ([AbstractModule] -> [ModuleName])
-> [AbstractModule] -> [ModuleName]
forall a b. (a -> b) -> a -> b
$ [[AbstractModule]] -> [AbstractModule]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[AbstractModule]] -> [AbstractModule])
-> [[AbstractModule]] -> [AbstractModule]
forall a b. (a -> b) -> a -> b
$ ModulesInScope -> [[AbstractModule]]
forall k a. Map k a -> [a]
Map.elems (ModulesInScope -> [[AbstractModule]])
-> ModulesInScope -> [[AbstractModule]]
forall a b. (a -> b) -> a -> b
$ Scope -> ModulesInScope
forall a. InScope a => Scope -> ThingsInScope a
allNamesInScope Scope
s
chase :: ModuleName -> [ModuleName]
chase ModuleName
m = ModuleName
m ModuleName -> [ModuleName] -> [ModuleName]
forall a. a -> [a] -> [a]
: (ModuleName -> [ModuleName]) -> [ModuleName] -> [ModuleName]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ModuleName -> [ModuleName]
chase [ModuleName]
ms
where ms :: [ModuleName]
ms = [ModuleName]
-> (Scope -> [ModuleName]) -> Maybe Scope -> [ModuleName]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [ModuleName]
forall a. HasCallStack => a
__IMPOSSIBLE__ Scope -> [ModuleName]
modules (Maybe Scope -> [ModuleName]) -> Maybe Scope -> [ModuleName]
forall a b. (a -> b) -> a -> b
$ ModuleName -> Map ModuleName Scope -> Maybe Scope
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
m Map ModuleName Scope
allMods
reachable :: ModuleName -> Bool
reachable = (ModuleName -> [ModuleName] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` ModuleName -> [ModuleName]
chase ModuleName
root)
publicNames :: ScopeInfo -> Set AbstractName
publicNames :: ScopeInfo -> Set AbstractName
publicNames ScopeInfo
scope =
[AbstractName] -> Set AbstractName
forall a. Ord a => [a] -> Set a
Set.fromList ([AbstractName] -> Set AbstractName)
-> [AbstractName] -> Set AbstractName
forall a b. (a -> b) -> a -> b
$ [[AbstractName]] -> [AbstractName]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[AbstractName]] -> [AbstractName])
-> [[AbstractName]] -> [AbstractName]
forall a b. (a -> b) -> a -> b
$ NamesInScope -> [[AbstractName]]
forall k a. Map k a -> [a]
Map.elems (NamesInScope -> [[AbstractName]])
-> NamesInScope -> [[AbstractName]]
forall a b. (a -> b) -> a -> b
$
Scope -> NamesInScope
forall a. InScope a => Scope -> ThingsInScope a
exportedNamesInScope (Scope -> NamesInScope) -> Scope -> NamesInScope
forall a b. (a -> b) -> a -> b
$ [Scope] -> Scope
mergeScopes ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$ Map ModuleName Scope -> [Scope]
forall k a. Map k a -> [a]
Map.elems (Map ModuleName Scope -> [Scope])
-> Map ModuleName Scope -> [Scope]
forall a b. (a -> b) -> a -> b
$ ScopeInfo -> Map ModuleName Scope
publicModules ScopeInfo
scope
everythingInScope :: ScopeInfo -> NameSpace
everythingInScope :: ScopeInfo -> NameSpace
everythingInScope ScopeInfo
scope = Scope -> NameSpace
allThingsInScope (Scope -> NameSpace) -> Scope -> NameSpace
forall a b. (a -> b) -> a -> b
$ [Scope] -> Scope
mergeScopes ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$
(Scope
s0 Scope -> [Scope] -> [Scope]
forall a. a -> [a] -> [a]
:) ([Scope] -> [Scope]) -> [Scope] -> [Scope]
forall a b. (a -> b) -> a -> b
$ (ModuleName -> Scope) -> [ModuleName] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map ModuleName -> Scope
look ([ModuleName] -> [Scope]) -> [ModuleName] -> [Scope]
forall a b. (a -> b) -> a -> b
$ Scope -> [ModuleName]
scopeParents Scope
s0
where
look :: ModuleName -> Scope
look ModuleName
m = Scope -> Maybe Scope -> Scope
forall a. a -> Maybe a -> a
fromMaybe Scope
forall a. HasCallStack => a
__IMPOSSIBLE__ (Maybe Scope -> Scope) -> Maybe Scope -> Scope
forall a b. (a -> b) -> a -> b
$ ModuleName -> Map ModuleName Scope -> Maybe Scope
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
m (Map ModuleName Scope -> Maybe Scope)
-> Map ModuleName Scope -> Maybe Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo
-> Lens' (Map ModuleName Scope) ScopeInfo -> Map ModuleName Scope
forall o i. o -> Lens' i o -> i
^. Lens' (Map ModuleName Scope) ScopeInfo
scopeModules
s0 :: Scope
s0 = ModuleName -> Scope
look (ModuleName -> Scope) -> ModuleName -> Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo -> Lens' ModuleName ScopeInfo -> ModuleName
forall o i. o -> Lens' i o -> i
^. Lens' ModuleName ScopeInfo
scopeCurrent
everythingInScopeQualified :: ScopeInfo -> NameSpace
everythingInScopeQualified :: ScopeInfo -> NameSpace
everythingInScopeQualified ScopeInfo
scope =
Scope -> NameSpace
allThingsInScope (Scope -> NameSpace) -> Scope -> NameSpace
forall a b. (a -> b) -> a -> b
$ [Scope] -> Scope
mergeScopes ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$
Set ModuleName -> [Scope] -> [Scope]
chase Set ModuleName
forall a. Set a
Set.empty [Scope]
scopes
where
s0 :: Scope
s0 = ModuleName -> Scope
look (ModuleName -> Scope) -> ModuleName -> Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo -> Lens' ModuleName ScopeInfo -> ModuleName
forall o i. o -> Lens' i o -> i
^. Lens' ModuleName ScopeInfo
scopeCurrent
scopes :: [Scope]
scopes = Scope
s0 Scope -> [Scope] -> [Scope]
forall a. a -> [a] -> [a]
: (ModuleName -> Scope) -> [ModuleName] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map ModuleName -> Scope
look (Scope -> [ModuleName]
scopeParents Scope
s0)
look :: ModuleName -> Scope
look ModuleName
m = Scope -> Maybe Scope -> Scope
forall a. a -> Maybe a -> a
fromMaybe Scope
forall a. HasCallStack => a
__IMPOSSIBLE__ (Maybe Scope -> Scope) -> Maybe Scope -> Scope
forall a b. (a -> b) -> a -> b
$ ModuleName -> Map ModuleName Scope -> Maybe Scope
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
m (Map ModuleName Scope -> Maybe Scope)
-> Map ModuleName Scope -> Maybe Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo
-> Lens' (Map ModuleName Scope) ScopeInfo -> Map ModuleName Scope
forall o i. o -> Lens' i o -> i
^. Lens' (Map ModuleName Scope) ScopeInfo
scopeModules
lookP :: ModuleName -> Scope
lookP = Scope -> Scope
restrictPrivate (Scope -> Scope) -> (ModuleName -> Scope) -> ModuleName -> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> Scope
look
chase :: Set ModuleName -> [Scope] -> [Scope]
chase Set ModuleName
seen [] = []
chase Set ModuleName
seen (Scope
s : [Scope]
ss)
| ModuleName -> Set ModuleName -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member ModuleName
name Set ModuleName
seen = Set ModuleName -> [Scope] -> [Scope]
chase Set ModuleName
seen [Scope]
ss
| Bool
otherwise = Scope
s Scope -> [Scope] -> [Scope]
forall a. a -> [a] -> [a]
: Set ModuleName -> [Scope] -> [Scope]
chase (ModuleName -> Set ModuleName -> Set ModuleName
forall a. Ord a => a -> Set a -> Set a
Set.insert ModuleName
name Set ModuleName
seen) ([Scope]
imports [Scope] -> [Scope] -> [Scope]
forall a. [a] -> [a] -> [a]
++ [Scope]
submods [Scope] -> [Scope] -> [Scope]
forall a. [a] -> [a] -> [a]
++ [Scope]
ss)
where
name :: ModuleName
name = Scope -> ModuleName
scopeName Scope
s
imports :: [Scope]
imports = (ModuleName -> Scope) -> [ModuleName] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map ModuleName -> Scope
lookP ([ModuleName] -> [Scope]) -> [ModuleName] -> [Scope]
forall a b. (a -> b) -> a -> b
$ Map QName ModuleName -> [ModuleName]
forall k a. Map k a -> [a]
Map.elems (Map QName ModuleName -> [ModuleName])
-> Map QName ModuleName -> [ModuleName]
forall a b. (a -> b) -> a -> b
$ Scope -> Map QName ModuleName
scopeImports Scope
s
submods :: [Scope]
submods = (AbstractModule -> Scope) -> [AbstractModule] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map (ModuleName -> Scope
lookP (ModuleName -> Scope)
-> (AbstractModule -> ModuleName) -> AbstractModule -> Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractModule -> ModuleName
amodName) ([AbstractModule] -> [Scope]) -> [AbstractModule] -> [Scope]
forall a b. (a -> b) -> a -> b
$ [[AbstractModule]] -> [AbstractModule]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[AbstractModule]] -> [AbstractModule])
-> [[AbstractModule]] -> [AbstractModule]
forall a b. (a -> b) -> a -> b
$ ModulesInScope -> [[AbstractModule]]
forall k a. Map k a -> [a]
Map.elems (ModulesInScope -> [[AbstractModule]])
-> ModulesInScope -> [[AbstractModule]]
forall a b. (a -> b) -> a -> b
$ Scope -> ModulesInScope
forall a. InScope a => Scope -> ThingsInScope a
allNamesInScope Scope
s
flattenScope :: [[C.Name]] -> ScopeInfo -> Map C.QName [AbstractName]
flattenScope :: [[Name]] -> ScopeInfo -> Map QName [AbstractName]
flattenScope [[Name]]
ms ScopeInfo
scope =
([AbstractName] -> [AbstractName] -> [AbstractName])
-> Map QName [AbstractName]
-> Map QName [AbstractName]
-> Map QName [AbstractName]
forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Map.unionWith [AbstractName] -> [AbstractName] -> [AbstractName]
forall a. [a] -> [a] -> [a]
(++)
([[Name]]
-> (forall a. InScope a => Scope -> ThingsInScope a)
-> Scope
-> Map QName [AbstractName]
build [[Name]]
ms forall a. InScope a => Scope -> ThingsInScope a
allNamesInScope Scope
root)
Map QName [AbstractName]
imported
where
current :: Scope
current = ModuleName -> Scope
moduleScope (ModuleName -> Scope) -> ModuleName -> Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo -> Lens' ModuleName ScopeInfo -> ModuleName
forall o i. o -> Lens' i o -> i
^. Lens' ModuleName ScopeInfo
scopeCurrent
root :: Scope
root = [Scope] -> Scope
mergeScopes ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$ Scope
current Scope -> [Scope] -> [Scope]
forall a. a -> [a] -> [a]
: (ModuleName -> Scope) -> [ModuleName] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map ModuleName -> Scope
moduleScope (Scope -> [ModuleName]
scopeParents Scope
current)
imported :: Map QName [AbstractName]
imported = ([AbstractName] -> [AbstractName] -> [AbstractName])
-> [Map QName [AbstractName]] -> Map QName [AbstractName]
forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
(a -> a -> a) -> f (Map k a) -> Map k a
Map.unionsWith [AbstractName] -> [AbstractName] -> [AbstractName]
forall a. [a] -> [a] -> [a]
(++)
[ QName -> Map QName [AbstractName] -> Map QName [AbstractName]
forall a. QName -> Map QName a -> Map QName a
qual QName
c ([[Name]]
-> (forall a. InScope a => Scope -> ThingsInScope a)
-> Scope
-> Map QName [AbstractName]
build [[Name]]
ms' forall a. InScope a => Scope -> ThingsInScope a
exportedNamesInScope (Scope -> Map QName [AbstractName])
-> Scope -> Map QName [AbstractName]
forall a b. (a -> b) -> a -> b
$ ModuleName -> Scope
moduleScope ModuleName
a)
| (QName
c, ModuleName
a) <- Map QName ModuleName -> [(QName, ModuleName)]
forall k a. Map k a -> [(k, a)]
Map.toList (Map QName ModuleName -> [(QName, ModuleName)])
-> Map QName ModuleName -> [(QName, ModuleName)]
forall a b. (a -> b) -> a -> b
$ Scope -> Map QName ModuleName
scopeImports Scope
root
, let
ms' :: [[Name]]
ms' = ([Name] -> Maybe [Name]) -> [[Name]] -> [[Name]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe ([Name] -> [Name] -> Maybe [Name]
forall a. Eq a => [a] -> [a] -> Maybe [a]
List.stripPrefix ([Name] -> [Name] -> Maybe [Name])
-> [Name] -> [Name] -> Maybe [Name]
forall a b. (a -> b) -> a -> b
$ QName -> [Name]
C.qnameParts QName
c) [[Name]]
ms
, Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [[Name]] -> Bool
forall a. Null a => a -> Bool
null [[Name]]
ms' ]
qual :: QName -> Map QName a -> Map QName a
qual QName
c = (QName -> QName) -> Map QName a -> Map QName a
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys (QName -> QName -> QName
q QName
c)
where
q :: QName -> QName -> QName
q (C.QName Name
x) = Name -> QName -> QName
C.Qual Name
x
q (C.Qual Name
m QName
x) = Name -> QName -> QName
C.Qual Name
m (QName -> QName) -> (QName -> QName) -> QName -> QName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> QName -> QName
q QName
x
build :: [[C.Name]] -> (forall a. InScope a => Scope -> ThingsInScope a) -> Scope -> Map C.QName [AbstractName]
build :: [[Name]]
-> (forall a. InScope a => Scope -> ThingsInScope a)
-> Scope
-> Map QName [AbstractName]
build [[Name]]
ms forall a. InScope a => Scope -> ThingsInScope a
getNames Scope
s = ([AbstractName] -> [AbstractName] -> [AbstractName])
-> [Map QName [AbstractName]] -> Map QName [AbstractName]
forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
(a -> a -> a) -> f (Map k a) -> Map k a
Map.unionsWith [AbstractName] -> [AbstractName] -> [AbstractName]
forall a. [a] -> [a] -> [a]
(++) ([Map QName [AbstractName]] -> Map QName [AbstractName])
-> [Map QName [AbstractName]] -> Map QName [AbstractName]
forall a b. (a -> b) -> a -> b
$
((Name -> QName) -> NamesInScope -> Map QName [AbstractName]
forall k1 k2 a. (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeysMonotonic Name -> QName
C.QName (NamesInScope -> Map QName [AbstractName])
-> NamesInScope -> Map QName [AbstractName]
forall a b. (a -> b) -> a -> b
$ Scope -> NamesInScope
forall a. InScope a => Scope -> ThingsInScope a
getNames Scope
s) Map QName [AbstractName]
-> [Map QName [AbstractName]] -> [Map QName [AbstractName]]
forall a. a -> [a] -> [a]
:
[ (QName -> QName)
-> Map QName [AbstractName] -> Map QName [AbstractName]
forall k1 k2 a. (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeysMonotonic (\ QName
y -> Name -> QName -> QName
C.Qual Name
x QName
y) (Map QName [AbstractName] -> Map QName [AbstractName])
-> Map QName [AbstractName] -> Map QName [AbstractName]
forall a b. (a -> b) -> a -> b
$
[[Name]]
-> (forall a. InScope a => Scope -> ThingsInScope a)
-> Scope
-> Map QName [AbstractName]
build [[Name]]
ms' forall a. InScope a => Scope -> ThingsInScope a
exportedNamesInScope (Scope -> Map QName [AbstractName])
-> Scope -> Map QName [AbstractName]
forall a b. (a -> b) -> a -> b
$ ModuleName -> Scope
moduleScope ModuleName
m
| (Name
x, [AbstractModule]
mods) <- ModulesInScope -> [(Name, [AbstractModule])]
forall k a. Map k a -> [(k, a)]
Map.toList (Scope -> ModulesInScope
forall a. InScope a => Scope -> ThingsInScope a
getNames Scope
s)
, let ms' :: [[Name]]
ms' = [ [Name]
tl | Name
hd:[Name]
tl <- [[Name]]
ms, Name
hd Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
== Name
x ]
, Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [[Name]] -> Bool
forall a. Null a => a -> Bool
null [[Name]]
ms'
, AbsModule ModuleName
m WhyInScope
_ <- [AbstractModule]
mods ]
moduleScope :: A.ModuleName -> Scope
moduleScope :: ModuleName -> Scope
moduleScope ModuleName
m = Scope -> Maybe Scope -> Scope
forall a. a -> Maybe a -> a
fromMaybe Scope
forall a. HasCallStack => a
__IMPOSSIBLE__ (Maybe Scope -> Scope) -> Maybe Scope -> Scope
forall a b. (a -> b) -> a -> b
$ ModuleName -> Map ModuleName Scope -> Maybe Scope
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
m (Map ModuleName Scope -> Maybe Scope)
-> Map ModuleName Scope -> Maybe Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo
-> Lens' (Map ModuleName Scope) ScopeInfo -> Map ModuleName Scope
forall o i. o -> Lens' i o -> i
^. Lens' (Map ModuleName Scope) ScopeInfo
scopeModules
concreteNamesInScope :: ScopeInfo -> Set C.QName
concreteNamesInScope :: ScopeInfo -> Set QName
concreteNamesInScope ScopeInfo
scope =
[Set QName] -> Set QName
forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions [ (forall a. InScope a => Scope -> ThingsInScope a)
-> Scope -> Set QName
build forall a. InScope a => Scope -> ThingsInScope a
allNamesInScope Scope
root, Set QName
imported, Set QName
locals ]
where
current :: Scope
current = ModuleName -> Scope
moduleScope (ModuleName -> Scope) -> ModuleName -> Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo -> Lens' ModuleName ScopeInfo -> ModuleName
forall o i. o -> Lens' i o -> i
^. Lens' ModuleName ScopeInfo
scopeCurrent
root :: Scope
root = [Scope] -> Scope
mergeScopes ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$ Scope
current Scope -> [Scope] -> [Scope]
forall a. a -> [a] -> [a]
: (ModuleName -> Scope) -> [ModuleName] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map ModuleName -> Scope
moduleScope (Scope -> [ModuleName]
scopeParents Scope
current)
locals :: Set QName
locals = [QName] -> Set QName
forall a. Ord a => [a] -> Set a
Set.fromList [ Name -> QName
C.QName Name
x | (Name
x, LocalVar
_) <- ScopeInfo
scope ScopeInfo -> Lens' LocalVars ScopeInfo -> LocalVars
forall o i. o -> Lens' i o -> i
^. Lens' LocalVars ScopeInfo
scopeLocals ]
imported :: Set QName
imported = [Set QName] -> Set QName
forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions
[ QName -> Set QName -> Set QName
qual QName
c ((forall a. InScope a => Scope -> ThingsInScope a)
-> Scope -> Set QName
build forall a. InScope a => Scope -> ThingsInScope a
exportedNamesInScope (Scope -> Set QName) -> Scope -> Set QName
forall a b. (a -> b) -> a -> b
$ ModuleName -> Scope
moduleScope ModuleName
a)
| (QName
c, ModuleName
a) <- Map QName ModuleName -> [(QName, ModuleName)]
forall k a. Map k a -> [(k, a)]
Map.toList (Map QName ModuleName -> [(QName, ModuleName)])
-> Map QName ModuleName -> [(QName, ModuleName)]
forall a b. (a -> b) -> a -> b
$ Scope -> Map QName ModuleName
scopeImports Scope
root ]
qual :: QName -> Set QName -> Set QName
qual QName
c = (QName -> QName) -> Set QName -> Set QName
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map (QName -> QName -> QName
q QName
c)
where
q :: QName -> QName -> QName
q (C.QName Name
x) = Name -> QName -> QName
C.Qual Name
x
q (C.Qual Name
m QName
x) = Name -> QName -> QName
C.Qual Name
m (QName -> QName) -> (QName -> QName) -> QName -> QName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> QName -> QName
q QName
x
build :: (forall a. InScope a => Scope -> ThingsInScope a) -> Scope -> Set C.QName
build :: (forall a. InScope a => Scope -> ThingsInScope a)
-> Scope -> Set QName
build forall a. InScope a => Scope -> ThingsInScope a
getNames Scope
s = [Set QName] -> Set QName
forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions ([Set QName] -> Set QName) -> [Set QName] -> Set QName
forall a b. (a -> b) -> a -> b
$
([QName] -> Set QName
forall a. Ord a => [a] -> Set a
Set.fromList ([QName] -> Set QName) -> [QName] -> Set QName
forall a b. (a -> b) -> a -> b
$ (Name -> QName) -> [Name] -> [QName]
forall a b. (a -> b) -> [a] -> [b]
map Name -> QName
C.QName ([Name] -> [QName]) -> [Name] -> [QName]
forall a b. (a -> b) -> a -> b
$ NamesInScope -> [Name]
forall k a. Map k a -> [k]
Map.keys (Scope -> NamesInScope
forall a. InScope a => Scope -> ThingsInScope a
getNames Scope
s :: ThingsInScope AbstractName)) Set QName -> [Set QName] -> [Set QName]
forall a. a -> [a] -> [a]
:
[ (QName -> QName) -> Set QName -> Set QName
forall a b. (a -> b) -> Set a -> Set b
Set.mapMonotonic (\ QName
y -> Name -> QName -> QName
C.Qual Name
x QName
y) (Set QName -> Set QName) -> Set QName -> Set QName
forall a b. (a -> b) -> a -> b
$
(forall a. InScope a => Scope -> ThingsInScope a)
-> Scope -> Set QName
build forall a. InScope a => Scope -> ThingsInScope a
exportedNamesInScope (Scope -> Set QName) -> Scope -> Set QName
forall a b. (a -> b) -> a -> b
$ ModuleName -> Scope
moduleScope ModuleName
m
| (Name
x, [AbstractModule]
mods) <- ModulesInScope -> [(Name, [AbstractModule])]
forall k a. Map k a -> [(k, a)]
Map.toList (Scope -> ModulesInScope
forall a. InScope a => Scope -> ThingsInScope a
getNames Scope
s)
, Name -> String
forall a. Pretty a => a -> String
prettyShow Name
x String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= String
"_"
, AbsModule ModuleName
m WhyInScope
_ <- [AbstractModule]
mods ]
moduleScope :: A.ModuleName -> Scope
moduleScope :: ModuleName -> Scope
moduleScope ModuleName
m = Scope -> Maybe Scope -> Scope
forall a. a -> Maybe a -> a
fromMaybe Scope
forall a. HasCallStack => a
__IMPOSSIBLE__ (Maybe Scope -> Scope) -> Maybe Scope -> Scope
forall a b. (a -> b) -> a -> b
$ ModuleName -> Map ModuleName Scope -> Maybe Scope
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
m (Map ModuleName Scope -> Maybe Scope)
-> Map ModuleName Scope -> Maybe Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo
-> Lens' (Map ModuleName Scope) ScopeInfo -> Map ModuleName Scope
forall o i. o -> Lens' i o -> i
^. Lens' (Map ModuleName Scope) ScopeInfo
scopeModules
scopeLookup :: InScope a => C.QName -> ScopeInfo -> [a]
scopeLookup :: QName -> ScopeInfo -> [a]
scopeLookup QName
q ScopeInfo
scope = ((a, Access) -> a) -> [(a, Access)] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map (a, Access) -> a
forall a b. (a, b) -> a
fst ([(a, Access)] -> [a]) -> [(a, Access)] -> [a]
forall a b. (a -> b) -> a -> b
$ QName -> ScopeInfo -> [(a, Access)]
forall a. InScope a => QName -> ScopeInfo -> [(a, Access)]
scopeLookup' QName
q ScopeInfo
scope
scopeLookup' :: forall a. InScope a => C.QName -> ScopeInfo -> [(a, Access)]
scopeLookup' :: QName -> ScopeInfo -> [(a, Access)]
scopeLookup' QName
q ScopeInfo
scope =
((a, Access) -> a) -> [(a, Access)] -> [(a, Access)]
forall b a. Ord b => (a -> b) -> [a] -> [a]
nubOn (a, Access) -> a
forall a b. (a, b) -> a
fst ([(a, Access)] -> [(a, Access)]) -> [(a, Access)] -> [(a, Access)]
forall a b. (a -> b) -> a -> b
$
QName -> Scope -> [(a, Access)]
forall a. InScope a => QName -> Scope -> [(a, Access)]
findName QName
q Scope
root [(a, Access)] -> [(a, Access)] -> [(a, Access)]
forall a. [a] -> [a] -> [a]
++ Maybe (a, Access) -> [(a, Access)]
forall a. Maybe a -> [a]
maybeToList Maybe (a, Access)
topImports [(a, Access)] -> [(a, Access)] -> [(a, Access)]
forall a. [a] -> [a] -> [a]
++ [(a, Access)]
imports
where
moduleScope :: A.ModuleName -> Scope
moduleScope :: ModuleName -> Scope
moduleScope ModuleName
m = Scope -> Maybe Scope -> Scope
forall a. a -> Maybe a -> a
fromMaybe Scope
forall a. HasCallStack => a
__IMPOSSIBLE__ (Maybe Scope -> Scope) -> Maybe Scope -> Scope
forall a b. (a -> b) -> a -> b
$ ModuleName -> Map ModuleName Scope -> Maybe Scope
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
m (Map ModuleName Scope -> Maybe Scope)
-> Map ModuleName Scope -> Maybe Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo
-> Lens' (Map ModuleName Scope) ScopeInfo -> Map ModuleName Scope
forall o i. o -> Lens' i o -> i
^. Lens' (Map ModuleName Scope) ScopeInfo
scopeModules
current :: Scope
current :: Scope
current = ModuleName -> Scope
moduleScope (ModuleName -> Scope) -> ModuleName -> Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo -> Lens' ModuleName ScopeInfo -> ModuleName
forall o i. o -> Lens' i o -> i
^. Lens' ModuleName ScopeInfo
scopeCurrent
root :: Scope
root :: Scope
root = [Scope] -> Scope
mergeScopes ([Scope] -> Scope) -> [Scope] -> Scope
forall a b. (a -> b) -> a -> b
$ Scope
current Scope -> [Scope] -> [Scope]
forall a. a -> [a] -> [a]
: (ModuleName -> Scope) -> [ModuleName] -> [Scope]
forall a b. (a -> b) -> [a] -> [b]
map ModuleName -> Scope
moduleScope (Scope -> [ModuleName]
scopeParents Scope
current)
findName :: forall a. InScope a => C.QName -> Scope -> [(a, Access)]
findName :: QName -> Scope -> [(a, Access)]
findName QName
q0 Scope
s = case QName
q0 of
C.QName Name
x -> Name -> Scope -> [(a, Access)]
forall a. InScope a => Name -> Scope -> [(a, Access)]
lookupName Name
x Scope
s
C.Qual Name
x QName
q -> do
let
mods :: [A.ModuleName]
mods :: [ModuleName]
mods = AbstractModule -> ModuleName
amodName (AbstractModule -> ModuleName)
-> ((AbstractModule, Access) -> AbstractModule)
-> (AbstractModule, Access)
-> ModuleName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AbstractModule, Access) -> AbstractModule
forall a b. (a, b) -> a
fst ((AbstractModule, Access) -> ModuleName)
-> [(AbstractModule, Access)] -> [ModuleName]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Scope -> [(AbstractModule, Access)]
forall a. InScope a => Name -> Scope -> [(a, Access)]
lookupName Name
x Scope
s
defs :: [A.ModuleName]
defs :: [ModuleName]
defs = [Name] -> ModuleName
mnameFromList ([Name] -> ModuleName)
-> ((AbstractName, Access) -> [Name])
-> (AbstractName, Access)
-> ModuleName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> [Name]
qnameToList (QName -> [Name])
-> ((AbstractName, Access) -> QName)
-> (AbstractName, Access)
-> [Name]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractName -> QName
anameName (AbstractName -> QName)
-> ((AbstractName, Access) -> AbstractName)
-> (AbstractName, Access)
-> QName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AbstractName, Access) -> AbstractName
forall a b. (a, b) -> a
fst ((AbstractName, Access) -> ModuleName)
-> [(AbstractName, Access)] -> [ModuleName]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Scope -> [(AbstractName, Access)]
forall a. InScope a => Name -> Scope -> [(a, Access)]
lookupName Name
x Scope
s
ModuleName
m <- [ModuleName]
mods
let ss :: Maybe Scope
ss = ModuleName -> Map ModuleName Scope -> Maybe Scope
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
m (Map ModuleName Scope -> Maybe Scope)
-> Map ModuleName Scope -> Maybe Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo
-> Lens' (Map ModuleName Scope) ScopeInfo -> Map ModuleName Scope
forall o i. o -> Lens' i o -> i
^. Lens' (Map ModuleName Scope) ScopeInfo
scopeModules
ss' :: Maybe Scope
ss' = Scope -> Scope
restrictPrivate (Scope -> Scope) -> Maybe Scope -> Maybe Scope
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Scope
ss
Scope
s' <- Maybe Scope -> [Scope]
forall a. Maybe a -> [a]
maybeToList Maybe Scope
ss'
QName -> Scope -> [(a, Access)]
forall a. InScope a => QName -> Scope -> [(a, Access)]
findName QName
q Scope
s'
where
lookupName :: forall a. InScope a => C.Name -> Scope -> [(a, Access)]
lookupName :: Name -> Scope -> [(a, Access)]
lookupName Name
x Scope
s = [(a, Access)] -> Maybe [(a, Access)] -> [(a, Access)]
forall a. a -> Maybe a -> a
fromMaybe [] (Maybe [(a, Access)] -> [(a, Access)])
-> Maybe [(a, Access)] -> [(a, Access)]
forall a b. (a -> b) -> a -> b
$ Name -> Map Name [(a, Access)] -> Maybe [(a, Access)]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Name
x (Map Name [(a, Access)] -> Maybe [(a, Access)])
-> Map Name [(a, Access)] -> Maybe [(a, Access)]
forall a b. (a -> b) -> a -> b
$ Scope -> Map Name [(a, Access)]
forall a. InScope a => Scope -> ThingsInScope (a, Access)
allNamesInScope' Scope
s
topImports :: Maybe (a, Access)
topImports :: Maybe (a, Access)
topImports = case (InScopeTag a
forall a. InScope a => InScopeTag a
inScopeTag :: InScopeTag a) of
InScopeTag a
NameTag -> Maybe (a, Access)
forall a. Maybe a
Nothing
InScopeTag a
ModuleTag -> (ModuleName -> AbstractModule)
-> (ModuleName, Access) -> (AbstractModule, Access)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first (ModuleName -> WhyInScope -> AbstractModule
`AbsModule` WhyInScope
Defined) ((ModuleName, Access) -> (a, Access))
-> Maybe (ModuleName, Access) -> Maybe (a, Access)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> QName -> Maybe (ModuleName, Access)
imported QName
q
imported :: C.QName -> Maybe (A.ModuleName, Access)
imported :: QName -> Maybe (ModuleName, Access)
imported QName
q = (ModuleName -> (ModuleName, Access))
-> Maybe ModuleName -> Maybe (ModuleName, Access)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (,Access
PublicAccess) (Maybe ModuleName -> Maybe (ModuleName, Access))
-> Maybe ModuleName -> Maybe (ModuleName, Access)
forall a b. (a -> b) -> a -> b
$ QName -> Map QName ModuleName -> Maybe ModuleName
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup QName
q (Map QName ModuleName -> Maybe ModuleName)
-> Map QName ModuleName -> Maybe ModuleName
forall a b. (a -> b) -> a -> b
$ Scope -> Map QName ModuleName
scopeImports Scope
root
imports :: [(a, Access)]
imports :: [(a, Access)]
imports = do
(QName
m, QName
x) <- QName -> [(QName, QName)]
splitName QName
q
ModuleName
m <- Maybe ModuleName -> [ModuleName]
forall a. Maybe a -> [a]
maybeToList (Maybe ModuleName -> [ModuleName])
-> Maybe ModuleName -> [ModuleName]
forall a b. (a -> b) -> a -> b
$ (ModuleName, Access) -> ModuleName
forall a b. (a, b) -> a
fst ((ModuleName, Access) -> ModuleName)
-> Maybe (ModuleName, Access) -> Maybe ModuleName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> QName -> Maybe (ModuleName, Access)
imported QName
m
QName -> Scope -> [(a, Access)]
forall a. InScope a => QName -> Scope -> [(a, Access)]
findName QName
x (Scope -> [(a, Access)]) -> Scope -> [(a, Access)]
forall a b. (a -> b) -> a -> b
$ Scope -> Scope
restrictPrivate (Scope -> Scope) -> Scope -> Scope
forall a b. (a -> b) -> a -> b
$ ModuleName -> Scope
moduleScope ModuleName
m
splitName :: C.QName -> [(C.QName, C.QName)]
splitName :: QName -> [(QName, QName)]
splitName (C.QName Name
x) = []
splitName (C.Qual Name
x QName
q) =
(Name -> QName
C.QName Name
x, QName
q) (QName, QName) -> [(QName, QName)] -> [(QName, QName)]
forall a. a -> [a] -> [a]
: [ (Name -> QName -> QName
C.Qual Name
x QName
m, QName
r) | (QName
m, QName
r) <- QName -> [(QName, QName)]
splitName QName
q ]
data AllowAmbiguousNames
= AmbiguousAnything
| AmbiguousConProjs
| AmbiguousNothing
deriving (AllowAmbiguousNames -> AllowAmbiguousNames -> Bool
(AllowAmbiguousNames -> AllowAmbiguousNames -> Bool)
-> (AllowAmbiguousNames -> AllowAmbiguousNames -> Bool)
-> Eq AllowAmbiguousNames
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllowAmbiguousNames -> AllowAmbiguousNames -> Bool
$c/= :: AllowAmbiguousNames -> AllowAmbiguousNames -> Bool
== :: AllowAmbiguousNames -> AllowAmbiguousNames -> Bool
$c== :: AllowAmbiguousNames -> AllowAmbiguousNames -> Bool
Eq)
isNameInScope :: A.QName -> ScopeInfo -> Bool
isNameInScope :: QName -> ScopeInfo -> Bool
isNameInScope QName
q ScopeInfo
scope =
Account -> Bool -> Bool
forall a. Account -> a -> a
billToPure [ Phase
Scoping, Phase
InverseScopeLookup ] (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$
QName -> InScopeSet -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member QName
q (ScopeInfo
scope ScopeInfo -> Lens' InScopeSet ScopeInfo -> InScopeSet
forall o i. o -> Lens' i o -> i
^. Lens' InScopeSet ScopeInfo
scopeInScope)
inverseScopeLookup :: Either A.ModuleName A.QName -> ScopeInfo -> [C.QName]
inverseScopeLookup :: Either ModuleName QName -> ScopeInfo -> [QName]
inverseScopeLookup = AllowAmbiguousNames
-> Either ModuleName QName -> ScopeInfo -> [QName]
inverseScopeLookup' AllowAmbiguousNames
AmbiguousConProjs
inverseScopeLookup' :: AllowAmbiguousNames -> Either A.ModuleName A.QName -> ScopeInfo -> [C.QName]
inverseScopeLookup' :: AllowAmbiguousNames
-> Either ModuleName QName -> ScopeInfo -> [QName]
inverseScopeLookup' AllowAmbiguousNames
amb Either ModuleName QName
name ScopeInfo
scope = Account -> [QName] -> [QName]
forall a. Account -> a -> a
billToPure [ Phase
Scoping , Phase
InverseScopeLookup ] ([QName] -> [QName]) -> [QName] -> [QName]
forall a b. (a -> b) -> a -> b
$
case Either ModuleName QName
name of
Left ModuleName
m -> [QName] -> [QName]
best ([QName] -> [QName]) -> [QName] -> [QName]
forall a b. (a -> b) -> a -> b
$ (QName -> Bool) -> [QName] -> [QName]
forall a. (a -> Bool) -> [a] -> [a]
filter QName -> Bool
unambiguousModule ([QName] -> [QName]) -> [QName] -> [QName]
forall a b. (a -> b) -> a -> b
$ ModuleName -> [QName]
findModule ModuleName
m
Right QName
q -> [QName] -> [QName]
best ([QName] -> [QName]) -> [QName] -> [QName]
forall a b. (a -> b) -> a -> b
$ (QName -> Bool) -> [QName] -> [QName]
forall a. (a -> Bool) -> [a] -> [a]
filter QName -> Bool
unambiguousName ([QName] -> [QName]) -> [QName] -> [QName]
forall a b. (a -> b) -> a -> b
$ QName -> [QName]
findName QName
q
where
findName :: QName -> [QName]
findName QName
x = [QName]
-> (NonEmpty QName -> [QName]) -> Maybe (NonEmpty QName) -> [QName]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] NonEmpty QName -> [QName]
forall a. NonEmpty a -> [a]
NonEmpty.toList (Maybe (NonEmpty QName) -> [QName])
-> Maybe (NonEmpty QName) -> [QName]
forall a b. (a -> b) -> a -> b
$ QName -> NameMap -> Maybe (NonEmpty QName)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup QName
x (ScopeInfo
scope ScopeInfo -> Lens' NameMap ScopeInfo -> NameMap
forall o i. o -> Lens' i o -> i
^. Lens' NameMap ScopeInfo
scopeInverseName)
findModule :: ModuleName -> [QName]
findModule ModuleName
x = [QName] -> Maybe [QName] -> [QName]
forall a. a -> Maybe a -> a
fromMaybe [] (Maybe [QName] -> [QName]) -> Maybe [QName] -> [QName]
forall a b. (a -> b) -> a -> b
$ ModuleName -> ModuleMap -> Maybe [QName]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
x (ScopeInfo
scope ScopeInfo -> Lens' ModuleMap ScopeInfo -> ModuleMap
forall o i. o -> Lens' i o -> i
^. Lens' ModuleMap ScopeInfo
scopeInverseModule)
len :: C.QName -> Int
len :: QName -> Int
len (C.QName Name
_) = Int
1
len (C.Qual Name
_ QName
x) = Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ QName -> Int
len QName
x
best :: [C.QName] -> [C.QName]
best :: [QName] -> [QName]
best = (QName -> QName -> Ordering) -> [QName] -> [QName]
forall a. (a -> a -> Ordering) -> [a] -> [a]
List.sortBy (Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Int -> Int -> Ordering)
-> (QName -> Int) -> QName -> QName -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` QName -> Int
len)
unique :: forall a . [a] -> Bool
unique :: [a] -> Bool
unique [] = Bool
forall a. HasCallStack => a
__IMPOSSIBLE__
unique [a
_] = Bool
True
unique (a
_:a
_:[a]
_) = Bool
False
unambiguousModule :: QName -> Bool
unambiguousModule QName
q = AllowAmbiguousNames
amb AllowAmbiguousNames -> AllowAmbiguousNames -> Bool
forall a. Eq a => a -> a -> Bool
== AllowAmbiguousNames
AmbiguousAnything Bool -> Bool -> Bool
|| [AbstractModule] -> Bool
forall a. [a] -> Bool
unique (QName -> ScopeInfo -> [AbstractModule]
forall a. InScope a => QName -> ScopeInfo -> [a]
scopeLookup QName
q ScopeInfo
scope :: [AbstractModule])
unambiguousName :: QName -> Bool
unambiguousName QName
q = AllowAmbiguousNames
amb AllowAmbiguousNames -> AllowAmbiguousNames -> Bool
forall a. Eq a => a -> a -> Bool
== AllowAmbiguousNames
AmbiguousAnything
Bool -> Bool -> Bool
|| [AbstractName] -> Bool
forall a. [a] -> Bool
unique [AbstractName]
xs
Bool -> Bool -> Bool
|| AllowAmbiguousNames
amb AllowAmbiguousNames -> AllowAmbiguousNames -> Bool
forall a. Eq a => a -> a -> Bool
== AllowAmbiguousNames
AmbiguousConProjs
Bool -> Bool -> Bool
&& [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
or [ (AbstractName -> Bool) -> [AbstractName] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all ((KindOfName
kind KindOfName -> KindOfName -> Bool
forall a. Eq a => a -> a -> Bool
==) (KindOfName -> Bool)
-> (AbstractName -> KindOfName) -> AbstractName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractName -> KindOfName
anameKind) [AbstractName]
xs | KindOfName
kind <- [KindOfName
ConName, KindOfName
FldName, KindOfName
PatternSynName] ]
where xs :: [AbstractName]
xs = QName -> ScopeInfo -> [AbstractName]
forall a. InScope a => QName -> ScopeInfo -> [a]
scopeLookup QName
q ScopeInfo
scope
recomputeInverseScopeMaps :: ScopeInfo -> ScopeInfo
recomputeInverseScopeMaps :: ScopeInfo -> ScopeInfo
recomputeInverseScopeMaps ScopeInfo
scope = Account -> ScopeInfo -> ScopeInfo
forall a. Account -> a -> a
billToPure [ Phase
Scoping , Phase
InverseScopeLookup ] (ScopeInfo -> ScopeInfo) -> ScopeInfo -> ScopeInfo
forall a b. (a -> b) -> a -> b
$
ScopeInfo
scope { _scopeInverseName :: NameMap
_scopeInverseName = NameMap
nameMap
, _scopeInverseModule :: ModuleMap
_scopeInverseModule = [(ModuleName, [QName])] -> ModuleMap
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [ (ModuleName
x, ModuleName -> [QName]
findModule ModuleName
x) | ModuleName
x <- Map ModuleName [(ModuleName, Name)] -> [ModuleName]
forall k a. Map k a -> [k]
Map.keys Map ModuleName [(ModuleName, Name)]
moduleMap [ModuleName] -> [ModuleName] -> [ModuleName]
forall a. [a] -> [a] -> [a]
++ ModuleMap -> [ModuleName]
forall k a. Map k a -> [k]
Map.keys ModuleMap
importMap ]
, _scopeInScope :: InScopeSet
_scopeInScope = NameSpace -> InScopeSet
nsInScope (NameSpace -> InScopeSet) -> NameSpace -> InScopeSet
forall a b. (a -> b) -> a -> b
$ ScopeInfo -> NameSpace
everythingInScopeQualified ScopeInfo
scope
}
where
this :: ModuleName
this = ScopeInfo
scope ScopeInfo -> Lens' ModuleName ScopeInfo -> ModuleName
forall o i. o -> Lens' i o -> i
^. Lens' ModuleName ScopeInfo
scopeCurrent
current :: [ModuleName]
current = ModuleName
this ModuleName -> [ModuleName] -> [ModuleName]
forall a. a -> [a] -> [a]
: Scope -> [ModuleName]
scopeParents (ModuleName -> Scope
moduleScope ModuleName
this)
scopes :: [(ModuleName, Scope)]
scopes = [ (ModuleName
m, ModuleName -> Scope -> Scope
restrict ModuleName
m Scope
s) | (ModuleName
m, Scope
s) <- Map ModuleName Scope -> [(ModuleName, Scope)]
forall k a. Map k a -> [(k, a)]
Map.toList (ScopeInfo
scope ScopeInfo
-> Lens' (Map ModuleName Scope) ScopeInfo -> Map ModuleName Scope
forall o i. o -> Lens' i o -> i
^. Lens' (Map ModuleName Scope) ScopeInfo
scopeModules) ]
moduleScope :: A.ModuleName -> Scope
moduleScope :: ModuleName -> Scope
moduleScope ModuleName
m = Scope -> Maybe Scope -> Scope
forall a. a -> Maybe a -> a
fromMaybe Scope
forall a. HasCallStack => a
__IMPOSSIBLE__ (Maybe Scope -> Scope) -> Maybe Scope -> Scope
forall a b. (a -> b) -> a -> b
$ ModuleName -> Map ModuleName Scope -> Maybe Scope
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
m (Map ModuleName Scope -> Maybe Scope)
-> Map ModuleName Scope -> Maybe Scope
forall a b. (a -> b) -> a -> b
$ ScopeInfo
scope ScopeInfo
-> Lens' (Map ModuleName Scope) ScopeInfo -> Map ModuleName Scope
forall o i. o -> Lens' i o -> i
^. Lens' (Map ModuleName Scope) ScopeInfo
scopeModules
restrict :: ModuleName -> Scope -> Scope
restrict ModuleName
m Scope
s | ModuleName
m ModuleName -> [ModuleName] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [ModuleName]
current = Scope
s
| Bool
otherwise = Scope -> Scope
restrictPrivate Scope
s
internalName :: C.QName -> Bool
internalName :: QName -> Bool
internalName C.QName{} = Bool
False
internalName (C.Qual Name
m QName
n) = Name -> Bool
intern Name
m Bool -> Bool -> Bool
|| QName -> Bool
internalName QName
n
where
intern :: Name -> Bool
intern (C.Name Range
_ NameInScope
_ [ C.Id (Char
'.' : Char
'#' : String
_) ]) = Bool
True
intern Name
_ = Bool
False
findName :: Ord a => Map a [(A.ModuleName, C.Name)] -> a -> [C.QName]
findName :: Map a [(ModuleName, Name)] -> a -> [QName]
findName Map a [(ModuleName, Name)]
table a
q = do
(ModuleName
m, Name
x) <- [(ModuleName, Name)]
-> Maybe [(ModuleName, Name)] -> [(ModuleName, Name)]
forall a. a -> Maybe a -> a
fromMaybe [] (Maybe [(ModuleName, Name)] -> [(ModuleName, Name)])
-> Maybe [(ModuleName, Name)] -> [(ModuleName, Name)]
forall a b. (a -> b) -> a -> b
$ a -> Map a [(ModuleName, Name)] -> Maybe [(ModuleName, Name)]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup a
q Map a [(ModuleName, Name)]
table
if ModuleName
m ModuleName -> [ModuleName] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [ModuleName]
current
then QName -> [QName]
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> QName
C.QName Name
x)
else do
QName
y <- ModuleName -> [QName]
findModule ModuleName
m
let z :: QName
z = QName -> Name -> QName
C.qualify QName
y Name
x
Bool -> [()]
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> [()]) -> Bool -> [()]
forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ QName -> Bool
internalName QName
z
QName -> [QName]
forall (m :: * -> *) a. Monad m => a -> m a
return QName
z
findModule :: A.ModuleName -> [C.QName]
findModule :: ModuleName -> [QName]
findModule ModuleName
q = Map ModuleName [(ModuleName, Name)] -> ModuleName -> [QName]
forall a. Ord a => Map a [(ModuleName, Name)] -> a -> [QName]
findName Map ModuleName [(ModuleName, Name)]
moduleMap ModuleName
q [QName] -> [QName] -> [QName]
forall a. [a] -> [a] -> [a]
++
[QName] -> Maybe [QName] -> [QName]
forall a. a -> Maybe a -> a
fromMaybe [] (ModuleName -> ModuleMap -> Maybe [QName]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ModuleName
q ModuleMap
importMap)
importMap :: ModuleMap
importMap = ([QName] -> [QName] -> [QName])
-> [(ModuleName, [QName])] -> ModuleMap
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith [QName] -> [QName] -> [QName]
forall a. [a] -> [a] -> [a]
(++) ([(ModuleName, [QName])] -> ModuleMap)
-> [(ModuleName, [QName])] -> ModuleMap
forall a b. (a -> b) -> a -> b
$ do
(ModuleName
m, Scope
s) <- [(ModuleName, Scope)]
scopes
(QName
x, ModuleName
y) <- Map QName ModuleName -> [(QName, ModuleName)]
forall k a. Map k a -> [(k, a)]
Map.toList (Map QName ModuleName -> [(QName, ModuleName)])
-> Map QName ModuleName -> [(QName, ModuleName)]
forall a b. (a -> b) -> a -> b
$ Scope -> Map QName ModuleName
scopeImports Scope
s
(ModuleName, [QName]) -> [(ModuleName, [QName])]
forall (m :: * -> *) a. Monad m => a -> m a
return (ModuleName
y, QName -> [QName]
forall el coll. Singleton el coll => el -> coll
singleton QName
x)
moduleMap :: Map ModuleName [(ModuleName, Name)]
moduleMap = ([(ModuleName, Name)]
-> [(ModuleName, Name)] -> [(ModuleName, Name)])
-> [(ModuleName, [(ModuleName, Name)])]
-> Map ModuleName [(ModuleName, Name)]
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith [(ModuleName, Name)]
-> [(ModuleName, Name)] -> [(ModuleName, Name)]
forall a. [a] -> [a] -> [a]
(++) ([(ModuleName, [(ModuleName, Name)])]
-> Map ModuleName [(ModuleName, Name)])
-> [(ModuleName, [(ModuleName, Name)])]
-> Map ModuleName [(ModuleName, Name)]
forall a b. (a -> b) -> a -> b
$ do
(ModuleName
m, Scope
s) <- [(ModuleName, Scope)]
scopes
(Name
x, [AbstractModule]
ms) <- ModulesInScope -> [(Name, [AbstractModule])]
forall k a. Map k a -> [(k, a)]
Map.toList (Scope -> ModulesInScope
forall a. InScope a => Scope -> ThingsInScope a
allNamesInScope Scope
s)
ModuleName
q <- AbstractModule -> ModuleName
amodName (AbstractModule -> ModuleName) -> [AbstractModule] -> [ModuleName]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [AbstractModule]
ms
(ModuleName, [(ModuleName, Name)])
-> [(ModuleName, [(ModuleName, Name)])]
forall (m :: * -> *) a. Monad m => a -> m a
return (ModuleName
q, (ModuleName, Name) -> [(ModuleName, Name)]
forall el coll. Singleton el coll => el -> coll
singleton (ModuleName
m, Name
x))
nameMap :: NameMap
nameMap :: NameMap
nameMap = (NonEmpty QName -> NonEmpty QName -> NonEmpty QName)
-> [(QName, NonEmpty QName)] -> NameMap
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith NonEmpty QName -> NonEmpty QName -> NonEmpty QName
forall a. Semigroup a => a -> a -> a
(Sgrp.<>) ([(QName, NonEmpty QName)] -> NameMap)
-> [(QName, NonEmpty QName)] -> NameMap
forall a b. (a -> b) -> a -> b
$ do
(ModuleName
m, Scope
s) <- [(ModuleName, Scope)]
scopes
(Name
x, [AbstractName]
ms) <- NamesInScope -> [(Name, [AbstractName])]
forall k a. Map k a -> [(k, a)]
Map.toList (Scope -> NamesInScope
forall a. InScope a => Scope -> ThingsInScope a
allNamesInScope Scope
s)
QName
q <- AbstractName -> QName
anameName (AbstractName -> QName) -> [AbstractName] -> [QName]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [AbstractName]
ms
if ModuleName
m ModuleName -> [ModuleName] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [ModuleName]
current
then (QName, NonEmpty QName) -> [(QName, NonEmpty QName)]
forall (m :: * -> *) a. Monad m => a -> m a
return (QName
q, QName -> NonEmpty QName
forall el coll. Singleton el coll => el -> coll
singleton (Name -> QName
C.QName Name
x))
else do
QName
y <- ModuleName -> [QName]
findModule ModuleName
m
let z :: QName
z = QName -> Name -> QName
C.qualify QName
y Name
x
Bool -> [()]
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> [()]) -> Bool -> [()]
forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ QName -> Bool
internalName QName
z
(QName, NonEmpty QName) -> [(QName, NonEmpty QName)]
forall (m :: * -> *) a. Monad m => a -> m a
return (QName
q, QName -> NonEmpty QName
forall el coll. Singleton el coll => el -> coll
singleton QName
z)
inverseScopeLookupName :: A.QName -> ScopeInfo -> [C.QName]
inverseScopeLookupName :: QName -> ScopeInfo -> [QName]
inverseScopeLookupName QName
x = Either ModuleName QName -> ScopeInfo -> [QName]
inverseScopeLookup (QName -> Either ModuleName QName
forall a b. b -> Either a b
Right QName
x)
inverseScopeLookupName' :: AllowAmbiguousNames -> A.QName -> ScopeInfo -> [C.QName]
inverseScopeLookupName' :: AllowAmbiguousNames -> QName -> ScopeInfo -> [QName]
inverseScopeLookupName' AllowAmbiguousNames
ambCon QName
x = AllowAmbiguousNames
-> Either ModuleName QName -> ScopeInfo -> [QName]
inverseScopeLookup' AllowAmbiguousNames
ambCon (QName -> Either ModuleName QName
forall a b. b -> Either a b
Right QName
x)
inverseScopeLookupModule :: A.ModuleName -> ScopeInfo -> [C.QName]
inverseScopeLookupModule :: ModuleName -> ScopeInfo -> [QName]
inverseScopeLookupModule ModuleName
x = Either ModuleName QName -> ScopeInfo -> [QName]
inverseScopeLookup (ModuleName -> Either ModuleName QName
forall a b. a -> Either a b
Left ModuleName
x)
class SetBindingSite a where
setBindingSite :: Range -> a -> a
default setBindingSite
:: (SetBindingSite b, Functor t, t b ~ a)
=> Range -> a -> a
setBindingSite = (b -> b) -> t b -> t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((b -> b) -> t b -> t b)
-> (Range -> b -> b) -> Range -> t b -> t b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Range -> b -> b
forall a. SetBindingSite a => Range -> a -> a
setBindingSite
instance SetBindingSite a => SetBindingSite [a]
instance SetBindingSite A.Name where
setBindingSite :: Range -> Name -> Name
setBindingSite Range
r Name
x = Name
x { nameBindingSite :: Range
nameBindingSite = Range
r }
instance SetBindingSite A.QName where
setBindingSite :: Range -> QName -> QName
setBindingSite Range
r QName
x = QName
x { qnameName :: Name
qnameName = Range -> Name -> Name
forall a. SetBindingSite a => Range -> a -> a
setBindingSite Range
r (Name -> Name) -> Name -> Name
forall a b. (a -> b) -> a -> b
$ QName -> Name
qnameName QName
x }
instance SetBindingSite A.ModuleName where
setBindingSite :: Range -> ModuleName -> ModuleName
setBindingSite Range
r (MName [Name]
x) = [Name] -> ModuleName
MName ([Name] -> ModuleName) -> [Name] -> ModuleName
forall a b. (a -> b) -> a -> b
$ Range -> [Name] -> [Name]
forall a. SetBindingSite a => Range -> a -> a
setBindingSite Range
r [Name]
x
instance SetBindingSite AbstractName where
setBindingSite :: Range -> AbstractName -> AbstractName
setBindingSite Range
r AbstractName
x = AbstractName
x { anameName :: QName
anameName = Range -> QName -> QName
forall a. SetBindingSite a => Range -> a -> a
setBindingSite Range
r (QName -> QName) -> QName -> QName
forall a b. (a -> b) -> a -> b
$ AbstractName -> QName
anameName AbstractName
x }
instance SetBindingSite AbstractModule where
setBindingSite :: Range -> AbstractModule -> AbstractModule
setBindingSite Range
r AbstractModule
x = AbstractModule
x { amodName :: ModuleName
amodName = Range -> ModuleName -> ModuleName
forall a. SetBindingSite a => Range -> a -> a
setBindingSite Range
r (ModuleName -> ModuleName) -> ModuleName -> ModuleName
forall a b. (a -> b) -> a -> b
$ AbstractModule -> ModuleName
amodName AbstractModule
x }
instance Pretty AbstractName where
pretty :: AbstractName -> Doc
pretty = QName -> Doc
forall a. Pretty a => a -> Doc
pretty (QName -> Doc) -> (AbstractName -> QName) -> AbstractName -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractName -> QName
anameName
instance Pretty AbstractModule where
pretty :: AbstractModule -> Doc
pretty = ModuleName -> Doc
forall a. Pretty a => a -> Doc
pretty (ModuleName -> Doc)
-> (AbstractModule -> ModuleName) -> AbstractModule -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractModule -> ModuleName
amodName
instance Pretty NameSpaceId where
pretty :: NameSpaceId -> Doc
pretty = String -> Doc
text (String -> Doc) -> (NameSpaceId -> String) -> NameSpaceId -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
NameSpaceId
PublicNS -> String
"public"
NameSpaceId
PrivateNS -> String
"private"
NameSpaceId
ImportedNS -> String
"imported"
instance Pretty NameSpace where
pretty :: NameSpace -> Doc
pretty = [Doc] -> Doc
vcat ([Doc] -> Doc) -> (NameSpace -> [Doc]) -> NameSpace -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> [Doc]
prettyNameSpace
prettyNameSpace :: NameSpace -> [Doc]
prettyNameSpace :: NameSpace -> [Doc]
prettyNameSpace (NameSpace NamesInScope
names ModulesInScope
mods InScopeSet
_) =
Doc -> [Doc] -> [Doc]
blockOfLines Doc
"names" (((Name, [AbstractName]) -> Doc)
-> [(Name, [AbstractName])] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (Name, [AbstractName]) -> Doc
forall a b. (Pretty a, Pretty b) => (a, b) -> Doc
pr ([(Name, [AbstractName])] -> [Doc])
-> [(Name, [AbstractName])] -> [Doc]
forall a b. (a -> b) -> a -> b
$ NamesInScope -> [(Name, [AbstractName])]
forall k a. Map k a -> [(k, a)]
Map.toList NamesInScope
names) [Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++
Doc -> [Doc] -> [Doc]
blockOfLines Doc
"modules" (((Name, [AbstractModule]) -> Doc)
-> [(Name, [AbstractModule])] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (Name, [AbstractModule]) -> Doc
forall a b. (Pretty a, Pretty b) => (a, b) -> Doc
pr ([(Name, [AbstractModule])] -> [Doc])
-> [(Name, [AbstractModule])] -> [Doc]
forall a b. (a -> b) -> a -> b
$ ModulesInScope -> [(Name, [AbstractModule])]
forall k a. Map k a -> [(k, a)]
Map.toList ModulesInScope
mods)
where
pr :: (Pretty a, Pretty b) => (a,b) -> Doc
pr :: (a, b) -> Doc
pr (a
x, b
y) = a -> Doc
forall a. Pretty a => a -> Doc
pretty a
x Doc -> Doc -> Doc
<+> Doc
"-->" Doc -> Doc -> Doc
<+> b -> Doc
forall a. Pretty a => a -> Doc
pretty b
y
instance Pretty Scope where
pretty :: Scope -> Doc
pretty (scope :: Scope
scope@Scope{ scopeName :: Scope -> ModuleName
scopeName = ModuleName
name, scopeParents :: Scope -> [ModuleName]
scopeParents = [ModuleName]
parents, scopeImports :: Scope -> Map QName ModuleName
scopeImports = Map QName ModuleName
imps }) =
[Doc] -> Doc
vcat ([Doc] -> Doc) -> [Doc] -> Doc
forall a b. (a -> b) -> a -> b
$
[ Doc
"scope" Doc -> Doc -> Doc
<+> ModuleName -> Doc
forall a. Pretty a => a -> Doc
pretty ModuleName
name ] [Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++ [Doc] -> [Doc]
ind (
[[Doc]] -> [Doc]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [ Doc -> [Doc] -> [Doc]
blockOfLines (NameSpaceId -> Doc
forall a. Pretty a => a -> Doc
pretty NameSpaceId
nsid) ([Doc] -> [Doc]) -> [Doc] -> [Doc]
forall a b. (a -> b) -> a -> b
$ NameSpace -> [Doc]
prettyNameSpace NameSpace
ns
| (NameSpaceId
nsid, NameSpace
ns) <- Scope -> ScopeNameSpaces
scopeNameSpaces Scope
scope ]
[Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++ Doc -> [Doc] -> [Doc]
blockOfLines Doc
"imports"
(case Map QName ModuleName -> [QName]
forall k a. Map k a -> [k]
Map.keys Map QName ModuleName
imps of [] -> []; [QName]
ks -> [ [QName] -> Doc
forall a. Pretty a => [a] -> Doc
prettyList [QName]
ks ])
)
where ind :: [Doc] -> [Doc]
ind = (Doc -> Doc) -> [Doc] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map ((Doc -> Doc) -> [Doc] -> [Doc]) -> (Doc -> Doc) -> [Doc] -> [Doc]
forall a b. (a -> b) -> a -> b
$ Int -> Doc -> Doc
nest Int
2
blockOfLines :: Doc -> [Doc] -> [Doc]
blockOfLines :: Doc -> [Doc] -> [Doc]
blockOfLines Doc
_ [] = []
blockOfLines Doc
hd [Doc]
ss = Doc
hd Doc -> [Doc] -> [Doc]
forall a. a -> [a] -> [a]
: (Doc -> Doc) -> [Doc] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Doc -> Doc
nest Int
2) [Doc]
ss
instance Pretty ScopeInfo where
pretty :: ScopeInfo -> Doc
pretty (ScopeInfo ModuleName
this Map ModuleName Scope
mods LocalVars
toBind LocalVars
locals PrecedenceStack
ctx NameMap
_ ModuleMap
_ InScopeSet
_ Fixities
_ Polarities
_) = [Doc] -> Doc
vcat ([Doc] -> Doc) -> [Doc] -> Doc
forall a b. (a -> b) -> a -> b
$
[ Doc
"ScopeInfo"
, Doc
" current = " Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> ModuleName -> Doc
forall a. Pretty a => a -> Doc
pretty ModuleName
this
] [Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++
(if LocalVars -> Bool
forall a. Null a => a -> Bool
null LocalVars
toBind then [] else [ Doc
" toBind = " Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> LocalVars -> Doc
forall a. Pretty a => a -> Doc
pretty LocalVars
locals ]) [Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++
(if LocalVars -> Bool
forall a. Null a => a -> Bool
null LocalVars
locals then [] else [ Doc
" locals = " Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> LocalVars -> Doc
forall a. Pretty a => a -> Doc
pretty LocalVars
locals ]) [Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++
[ Doc
" context = " Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> PrecedenceStack -> Doc
forall a. Pretty a => a -> Doc
pretty PrecedenceStack
ctx
, Doc
" modules"
] [Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++
(Doc -> Doc) -> [Doc] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Doc -> Doc
nest Int
4) ((Doc -> Bool) -> [Doc] -> [Doc]
forall a. (a -> Bool) -> [a] -> [a]
List.filter (Bool -> Bool
not (Bool -> Bool) -> (Doc -> Bool) -> Doc -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> Bool
forall a. Null a => a -> Bool
null) ([Doc] -> [Doc]) -> [Doc] -> [Doc]
forall a b. (a -> b) -> a -> b
$ (Scope -> Doc) -> [Scope] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map Scope -> Doc
forall a. Pretty a => a -> Doc
pretty ([Scope] -> [Doc]) -> [Scope] -> [Doc]
forall a b. (a -> b) -> a -> b
$ Map ModuleName Scope -> [Scope]
forall k a. Map k a -> [a]
Map.elems Map ModuleName Scope
mods)
instance KillRange ScopeInfo where
killRange :: ScopeInfo -> ScopeInfo
killRange ScopeInfo
m = ScopeInfo
m
instance HasRange AbstractName where
getRange :: AbstractName -> Range
getRange = QName -> Range
forall t. HasRange t => t -> Range
getRange (QName -> Range)
-> (AbstractName -> QName) -> AbstractName -> Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractName -> QName
anameName
instance SetRange AbstractName where
setRange :: Range -> AbstractName -> AbstractName
setRange Range
r AbstractName
x = AbstractName
x { anameName :: QName
anameName = Range -> QName -> QName
forall t. SetRange t => Range -> t -> t
setRange Range
r (QName -> QName) -> QName -> QName
forall a b. (a -> b) -> a -> b
$ AbstractName -> QName
anameName AbstractName
x }