{-# LANGUAGE DeriveDataTypeable #-}
module Agda.Syntax.Abstract.Name
( module Agda.Syntax.Abstract.Name
, IsNoName(..)
) where
import Control.DeepSeq
import Data.Data (Data)
import Data.Foldable (Foldable)
import Data.Function
import Data.Hashable (Hashable(..))
import Data.List
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NonEmpty
import Data.Maybe
import Data.Traversable (Traversable)
import Data.Void
import Agda.Syntax.Position
import Agda.Syntax.Common
import Agda.Syntax.Concrete.Name (IsNoName(..), NumHoles(..), NameInScope(..), LensInScope(..))
import qualified Agda.Syntax.Concrete.Name as C
import Agda.Utils.Functor
import Agda.Utils.Lens
import Agda.Utils.List
import Agda.Utils.Pretty
import Agda.Utils.Size
import Agda.Utils.Impossible
data Name = Name
{ Name -> NameId
nameId :: !NameId
, Name -> Name
nameConcrete :: C.Name
, Name -> Range
nameBindingSite :: Range
, Name -> Fixity'
nameFixity :: Fixity'
, Name -> Bool
nameIsRecordName :: Bool
} deriving Typeable Name
DataType
Constr
Typeable Name
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name -> c Name)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Name)
-> (Name -> Constr)
-> (Name -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Name))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name))
-> ((forall b. Data b => b -> b) -> Name -> Name)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r)
-> (forall u. (forall d. Data d => d -> u) -> Name -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Name -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Name -> m Name)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name -> m Name)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name -> m Name)
-> Data Name
Name -> DataType
Name -> Constr
(forall b. Data b => b -> b) -> Name -> Name
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name -> c Name
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Name
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) -> Name -> u
forall u. (forall d. Data d => d -> u) -> Name -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Name -> m Name
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name -> m Name
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Name
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name -> c Name
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Name)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name)
$cName :: Constr
$tName :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Name -> m Name
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name -> m Name
gmapMp :: (forall d. Data d => d -> m d) -> Name -> m Name
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name -> m Name
gmapM :: (forall d. Data d => d -> m d) -> Name -> m Name
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Name -> m Name
gmapQi :: Int -> (forall d. Data d => d -> u) -> Name -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Name -> u
gmapQ :: (forall d. Data d => d -> u) -> Name -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Name -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
gmapT :: (forall b. Data b => b -> b) -> Name -> Name
$cgmapT :: (forall b. Data b => b -> b) -> Name -> Name
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Name)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Name)
dataTypeOf :: Name -> DataType
$cdataTypeOf :: Name -> DataType
toConstr :: Name -> Constr
$ctoConstr :: Name -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Name
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Name
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name -> c Name
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name -> c Name
$cp1Data :: Typeable Name
Data
uglyShowName :: Name -> String
uglyShowName :: Name -> String
uglyShowName (Name NameId
i Name
c Range
_ Fixity'
_ Bool
_) = (NameId, Name) -> String
forall a. Show a => a -> String
show (NameId
i,Name
c)
data QName = QName { QName -> ModuleName
qnameModule :: ModuleName
, QName -> Name
qnameName :: Name
}
deriving Typeable QName
DataType
Constr
Typeable QName
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QName -> c QName)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QName)
-> (QName -> Constr)
-> (QName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c QName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c QName))
-> ((forall b. Data b => b -> b) -> QName -> QName)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r)
-> (forall u. (forall d. Data d => d -> u) -> QName -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> QName -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> QName -> m QName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QName -> m QName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QName -> m QName)
-> Data QName
QName -> DataType
QName -> Constr
(forall b. Data b => b -> b) -> QName -> QName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QName -> c QName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QName
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) -> QName -> u
forall u. (forall d. Data d => d -> u) -> QName -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> QName -> m QName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QName -> m QName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QName -> c QName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c QName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c QName)
$cQName :: Constr
$tQName :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> QName -> m QName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QName -> m QName
gmapMp :: (forall d. Data d => d -> m d) -> QName -> m QName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QName -> m QName
gmapM :: (forall d. Data d => d -> m d) -> QName -> m QName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> QName -> m QName
gmapQi :: Int -> (forall d. Data d => d -> u) -> QName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> QName -> u
gmapQ :: (forall d. Data d => d -> u) -> QName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> QName -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r
gmapT :: (forall b. Data b => b -> b) -> QName -> QName
$cgmapT :: (forall b. Data b => b -> b) -> QName -> QName
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c QName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c QName)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c QName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c QName)
dataTypeOf :: QName -> DataType
$cdataTypeOf :: QName -> DataType
toConstr :: QName -> Constr
$ctoConstr :: QName -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QName
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QName -> c QName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QName -> c QName
$cp1Data :: Typeable QName
Data
data QNamed a = QNamed
{ QNamed a -> QName
qname :: QName
, QNamed a -> a
qnamed :: a
}
deriving (a -> QNamed b -> QNamed a
(a -> b) -> QNamed a -> QNamed b
(forall a b. (a -> b) -> QNamed a -> QNamed b)
-> (forall a b. a -> QNamed b -> QNamed a) -> Functor QNamed
forall a b. a -> QNamed b -> QNamed a
forall a b. (a -> b) -> QNamed a -> QNamed b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> QNamed b -> QNamed a
$c<$ :: forall a b. a -> QNamed b -> QNamed a
fmap :: (a -> b) -> QNamed a -> QNamed b
$cfmap :: forall a b. (a -> b) -> QNamed a -> QNamed b
Functor, QNamed a -> Bool
(a -> m) -> QNamed a -> m
(a -> b -> b) -> b -> QNamed a -> b
(forall m. Monoid m => QNamed m -> m)
-> (forall m a. Monoid m => (a -> m) -> QNamed a -> m)
-> (forall m a. Monoid m => (a -> m) -> QNamed a -> m)
-> (forall a b. (a -> b -> b) -> b -> QNamed a -> b)
-> (forall a b. (a -> b -> b) -> b -> QNamed a -> b)
-> (forall b a. (b -> a -> b) -> b -> QNamed a -> b)
-> (forall b a. (b -> a -> b) -> b -> QNamed a -> b)
-> (forall a. (a -> a -> a) -> QNamed a -> a)
-> (forall a. (a -> a -> a) -> QNamed a -> a)
-> (forall a. QNamed a -> [a])
-> (forall a. QNamed a -> Bool)
-> (forall a. QNamed a -> Int)
-> (forall a. Eq a => a -> QNamed a -> Bool)
-> (forall a. Ord a => QNamed a -> a)
-> (forall a. Ord a => QNamed a -> a)
-> (forall a. Num a => QNamed a -> a)
-> (forall a. Num a => QNamed a -> a)
-> Foldable QNamed
forall a. Eq a => a -> QNamed a -> Bool
forall a. Num a => QNamed a -> a
forall a. Ord a => QNamed a -> a
forall m. Monoid m => QNamed m -> m
forall a. QNamed a -> Bool
forall a. QNamed a -> Int
forall a. QNamed a -> [a]
forall a. (a -> a -> a) -> QNamed a -> a
forall m a. Monoid m => (a -> m) -> QNamed a -> m
forall b a. (b -> a -> b) -> b -> QNamed a -> b
forall a b. (a -> b -> b) -> b -> QNamed a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: QNamed a -> a
$cproduct :: forall a. Num a => QNamed a -> a
sum :: QNamed a -> a
$csum :: forall a. Num a => QNamed a -> a
minimum :: QNamed a -> a
$cminimum :: forall a. Ord a => QNamed a -> a
maximum :: QNamed a -> a
$cmaximum :: forall a. Ord a => QNamed a -> a
elem :: a -> QNamed a -> Bool
$celem :: forall a. Eq a => a -> QNamed a -> Bool
length :: QNamed a -> Int
$clength :: forall a. QNamed a -> Int
null :: QNamed a -> Bool
$cnull :: forall a. QNamed a -> Bool
toList :: QNamed a -> [a]
$ctoList :: forall a. QNamed a -> [a]
foldl1 :: (a -> a -> a) -> QNamed a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> QNamed a -> a
foldr1 :: (a -> a -> a) -> QNamed a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> QNamed a -> a
foldl' :: (b -> a -> b) -> b -> QNamed a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> QNamed a -> b
foldl :: (b -> a -> b) -> b -> QNamed a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> QNamed a -> b
foldr' :: (a -> b -> b) -> b -> QNamed a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> QNamed a -> b
foldr :: (a -> b -> b) -> b -> QNamed a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> QNamed a -> b
foldMap' :: (a -> m) -> QNamed a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> QNamed a -> m
foldMap :: (a -> m) -> QNamed a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> QNamed a -> m
fold :: QNamed m -> m
$cfold :: forall m. Monoid m => QNamed m -> m
Foldable, Functor QNamed
Foldable QNamed
Functor QNamed
-> Foldable QNamed
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> QNamed a -> f (QNamed b))
-> (forall (f :: * -> *) a.
Applicative f =>
QNamed (f a) -> f (QNamed a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> QNamed a -> m (QNamed b))
-> (forall (m :: * -> *) a.
Monad m =>
QNamed (m a) -> m (QNamed a))
-> Traversable QNamed
(a -> f b) -> QNamed a -> f (QNamed b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => QNamed (m a) -> m (QNamed a)
forall (f :: * -> *) a.
Applicative f =>
QNamed (f a) -> f (QNamed a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> QNamed a -> m (QNamed b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> QNamed a -> f (QNamed b)
sequence :: QNamed (m a) -> m (QNamed a)
$csequence :: forall (m :: * -> *) a. Monad m => QNamed (m a) -> m (QNamed a)
mapM :: (a -> m b) -> QNamed a -> m (QNamed b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> QNamed a -> m (QNamed b)
sequenceA :: QNamed (f a) -> f (QNamed a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
QNamed (f a) -> f (QNamed a)
traverse :: (a -> f b) -> QNamed a -> f (QNamed b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> QNamed a -> f (QNamed b)
$cp2Traversable :: Foldable QNamed
$cp1Traversable :: Functor QNamed
Traversable)
newtype ModuleName = MName { ModuleName -> [Name]
mnameToList :: [Name] }
deriving (ModuleName -> ModuleName -> Bool
(ModuleName -> ModuleName -> Bool)
-> (ModuleName -> ModuleName -> Bool) -> Eq ModuleName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModuleName -> ModuleName -> Bool
$c/= :: ModuleName -> ModuleName -> Bool
== :: ModuleName -> ModuleName -> Bool
$c== :: ModuleName -> ModuleName -> Bool
Eq, Eq ModuleName
Eq ModuleName
-> (ModuleName -> ModuleName -> Ordering)
-> (ModuleName -> ModuleName -> Bool)
-> (ModuleName -> ModuleName -> Bool)
-> (ModuleName -> ModuleName -> Bool)
-> (ModuleName -> ModuleName -> Bool)
-> (ModuleName -> ModuleName -> ModuleName)
-> (ModuleName -> ModuleName -> ModuleName)
-> Ord ModuleName
ModuleName -> ModuleName -> Bool
ModuleName -> ModuleName -> Ordering
ModuleName -> ModuleName -> ModuleName
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 :: ModuleName -> ModuleName -> ModuleName
$cmin :: ModuleName -> ModuleName -> ModuleName
max :: ModuleName -> ModuleName -> ModuleName
$cmax :: ModuleName -> ModuleName -> ModuleName
>= :: ModuleName -> ModuleName -> Bool
$c>= :: ModuleName -> ModuleName -> Bool
> :: ModuleName -> ModuleName -> Bool
$c> :: ModuleName -> ModuleName -> Bool
<= :: ModuleName -> ModuleName -> Bool
$c<= :: ModuleName -> ModuleName -> Bool
< :: ModuleName -> ModuleName -> Bool
$c< :: ModuleName -> ModuleName -> Bool
compare :: ModuleName -> ModuleName -> Ordering
$ccompare :: ModuleName -> ModuleName -> Ordering
$cp1Ord :: Eq ModuleName
Ord, Typeable ModuleName
DataType
Constr
Typeable ModuleName
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModuleName -> c ModuleName)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModuleName)
-> (ModuleName -> Constr)
-> (ModuleName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModuleName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ModuleName))
-> ((forall b. Data b => b -> b) -> ModuleName -> ModuleName)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModuleName -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModuleName -> r)
-> (forall u. (forall d. Data d => d -> u) -> ModuleName -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> ModuleName -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModuleName -> m ModuleName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModuleName -> m ModuleName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModuleName -> m ModuleName)
-> Data ModuleName
ModuleName -> DataType
ModuleName -> Constr
(forall b. Data b => b -> b) -> ModuleName -> ModuleName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModuleName -> c ModuleName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModuleName
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) -> ModuleName -> u
forall u. (forall d. Data d => d -> u) -> ModuleName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModuleName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModuleName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModuleName -> m ModuleName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModuleName -> m ModuleName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModuleName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModuleName -> c ModuleName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModuleName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModuleName)
$cMName :: Constr
$tModuleName :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> ModuleName -> m ModuleName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModuleName -> m ModuleName
gmapMp :: (forall d. Data d => d -> m d) -> ModuleName -> m ModuleName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ModuleName -> m ModuleName
gmapM :: (forall d. Data d => d -> m d) -> ModuleName -> m ModuleName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ModuleName -> m ModuleName
gmapQi :: Int -> (forall d. Data d => d -> u) -> ModuleName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ModuleName -> u
gmapQ :: (forall d. Data d => d -> u) -> ModuleName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ModuleName -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModuleName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ModuleName -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModuleName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ModuleName -> r
gmapT :: (forall b. Data b => b -> b) -> ModuleName -> ModuleName
$cgmapT :: (forall b. Data b => b -> b) -> ModuleName -> ModuleName
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModuleName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ModuleName)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ModuleName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ModuleName)
dataTypeOf :: ModuleName -> DataType
$cdataTypeOf :: ModuleName -> DataType
toConstr :: ModuleName -> Constr
$ctoConstr :: ModuleName -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModuleName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ModuleName
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModuleName -> c ModuleName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ModuleName -> c ModuleName
$cp1Data :: Typeable ModuleName
Data)
newtype AmbiguousQName = AmbQ { AmbiguousQName -> NonEmpty QName
unAmbQ :: NonEmpty QName }
deriving (AmbiguousQName -> AmbiguousQName -> Bool
(AmbiguousQName -> AmbiguousQName -> Bool)
-> (AmbiguousQName -> AmbiguousQName -> Bool) -> Eq AmbiguousQName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AmbiguousQName -> AmbiguousQName -> Bool
$c/= :: AmbiguousQName -> AmbiguousQName -> Bool
== :: AmbiguousQName -> AmbiguousQName -> Bool
$c== :: AmbiguousQName -> AmbiguousQName -> Bool
Eq, Eq AmbiguousQName
Eq AmbiguousQName
-> (AmbiguousQName -> AmbiguousQName -> Ordering)
-> (AmbiguousQName -> AmbiguousQName -> Bool)
-> (AmbiguousQName -> AmbiguousQName -> Bool)
-> (AmbiguousQName -> AmbiguousQName -> Bool)
-> (AmbiguousQName -> AmbiguousQName -> Bool)
-> (AmbiguousQName -> AmbiguousQName -> AmbiguousQName)
-> (AmbiguousQName -> AmbiguousQName -> AmbiguousQName)
-> Ord AmbiguousQName
AmbiguousQName -> AmbiguousQName -> Bool
AmbiguousQName -> AmbiguousQName -> Ordering
AmbiguousQName -> AmbiguousQName -> AmbiguousQName
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 :: AmbiguousQName -> AmbiguousQName -> AmbiguousQName
$cmin :: AmbiguousQName -> AmbiguousQName -> AmbiguousQName
max :: AmbiguousQName -> AmbiguousQName -> AmbiguousQName
$cmax :: AmbiguousQName -> AmbiguousQName -> AmbiguousQName
>= :: AmbiguousQName -> AmbiguousQName -> Bool
$c>= :: AmbiguousQName -> AmbiguousQName -> Bool
> :: AmbiguousQName -> AmbiguousQName -> Bool
$c> :: AmbiguousQName -> AmbiguousQName -> Bool
<= :: AmbiguousQName -> AmbiguousQName -> Bool
$c<= :: AmbiguousQName -> AmbiguousQName -> Bool
< :: AmbiguousQName -> AmbiguousQName -> Bool
$c< :: AmbiguousQName -> AmbiguousQName -> Bool
compare :: AmbiguousQName -> AmbiguousQName -> Ordering
$ccompare :: AmbiguousQName -> AmbiguousQName -> Ordering
$cp1Ord :: Eq AmbiguousQName
Ord, Typeable AmbiguousQName
DataType
Constr
Typeable AmbiguousQName
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AmbiguousQName -> c AmbiguousQName)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AmbiguousQName)
-> (AmbiguousQName -> Constr)
-> (AmbiguousQName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AmbiguousQName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AmbiguousQName))
-> ((forall b. Data b => b -> b)
-> AmbiguousQName -> AmbiguousQName)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AmbiguousQName -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AmbiguousQName -> r)
-> (forall u.
(forall d. Data d => d -> u) -> AmbiguousQName -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> AmbiguousQName -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName)
-> Data AmbiguousQName
AmbiguousQName -> DataType
AmbiguousQName -> Constr
(forall b. Data b => b -> b) -> AmbiguousQName -> AmbiguousQName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AmbiguousQName -> c AmbiguousQName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AmbiguousQName
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) -> AmbiguousQName -> u
forall u. (forall d. Data d => d -> u) -> AmbiguousQName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AmbiguousQName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AmbiguousQName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AmbiguousQName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AmbiguousQName -> c AmbiguousQName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AmbiguousQName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AmbiguousQName)
$cAmbQ :: Constr
$tAmbiguousQName :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName
gmapMp :: (forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName
gmapM :: (forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AmbiguousQName -> m AmbiguousQName
gmapQi :: Int -> (forall d. Data d => d -> u) -> AmbiguousQName -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AmbiguousQName -> u
gmapQ :: (forall d. Data d => d -> u) -> AmbiguousQName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AmbiguousQName -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AmbiguousQName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AmbiguousQName -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AmbiguousQName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AmbiguousQName -> r
gmapT :: (forall b. Data b => b -> b) -> AmbiguousQName -> AmbiguousQName
$cgmapT :: (forall b. Data b => b -> b) -> AmbiguousQName -> AmbiguousQName
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AmbiguousQName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AmbiguousQName)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c AmbiguousQName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AmbiguousQName)
dataTypeOf :: AmbiguousQName -> DataType
$cdataTypeOf :: AmbiguousQName -> DataType
toConstr :: AmbiguousQName -> Constr
$ctoConstr :: AmbiguousQName -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AmbiguousQName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AmbiguousQName
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AmbiguousQName -> c AmbiguousQName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AmbiguousQName -> c AmbiguousQName
$cp1Data :: Typeable AmbiguousQName
Data)
unambiguous :: QName -> AmbiguousQName
unambiguous :: QName -> AmbiguousQName
unambiguous QName
x = NonEmpty QName -> AmbiguousQName
AmbQ (QName
x QName -> [QName] -> NonEmpty QName
forall a. a -> [a] -> NonEmpty a
:| [])
headAmbQ :: AmbiguousQName -> QName
headAmbQ :: AmbiguousQName -> QName
headAmbQ (AmbQ NonEmpty QName
xs) = NonEmpty QName -> QName
forall a. NonEmpty a -> a
NonEmpty.head NonEmpty QName
xs
isAmbiguous :: AmbiguousQName -> Bool
isAmbiguous :: AmbiguousQName -> Bool
isAmbiguous (AmbQ (QName
_ :| [QName]
xs)) = Bool -> Bool
not ([QName] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [QName]
xs)
getUnambiguous :: AmbiguousQName -> Maybe QName
getUnambiguous :: AmbiguousQName -> Maybe QName
getUnambiguous (AmbQ (QName
x :| [])) = QName -> Maybe QName
forall a. a -> Maybe a
Just QName
x
getUnambiguous AmbiguousQName
_ = Maybe QName
forall a. Maybe a
Nothing
class IsProjP a where
isProjP :: a -> Maybe (ProjOrigin, AmbiguousQName)
instance IsProjP a => IsProjP (Arg a) where
isProjP :: Arg a -> Maybe (ProjOrigin, AmbiguousQName)
isProjP Arg a
p = case a -> Maybe (ProjOrigin, AmbiguousQName)
forall a. IsProjP a => a -> Maybe (ProjOrigin, AmbiguousQName)
isProjP (a -> Maybe (ProjOrigin, AmbiguousQName))
-> a -> Maybe (ProjOrigin, AmbiguousQName)
forall a b. (a -> b) -> a -> b
$ Arg a -> a
forall e. Arg e -> e
unArg Arg a
p of
Just (ProjOrigin
ProjPostfix , AmbiguousQName
f)
| Arg a -> Hiding
forall a. LensHiding a => a -> Hiding
getHiding Arg a
p Hiding -> Hiding -> Bool
forall a. Eq a => a -> a -> Bool
/= Hiding
NotHidden -> Maybe (ProjOrigin, AmbiguousQName)
forall a. Maybe a
Nothing
Maybe (ProjOrigin, AmbiguousQName)
x -> Maybe (ProjOrigin, AmbiguousQName)
x
instance IsProjP a => IsProjP (Named n a) where
isProjP :: Named n a -> Maybe (ProjOrigin, AmbiguousQName)
isProjP = a -> Maybe (ProjOrigin, AmbiguousQName)
forall a. IsProjP a => a -> Maybe (ProjOrigin, AmbiguousQName)
isProjP (a -> Maybe (ProjOrigin, AmbiguousQName))
-> (Named n a -> a)
-> Named n a
-> Maybe (ProjOrigin, AmbiguousQName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Named n a -> a
forall name a. Named name a -> a
namedThing
instance IsProjP Void where
isProjP :: Void -> Maybe (ProjOrigin, AmbiguousQName)
isProjP Void
_ = Maybe (ProjOrigin, AmbiguousQName)
forall a. HasCallStack => a
__IMPOSSIBLE__
isAnonymousModuleName :: ModuleName -> Bool
isAnonymousModuleName :: ModuleName -> Bool
isAnonymousModuleName (MName []) = Bool
False
isAnonymousModuleName (MName [Name]
ms) = Name -> Bool
forall a. IsNoName a => a -> Bool
isNoName (Name -> Bool) -> Name -> Bool
forall a b. (a -> b) -> a -> b
$ [Name] -> Name
forall a. [a] -> a
last [Name]
ms
withRangesOf :: ModuleName -> [C.Name] -> ModuleName
MName [Name]
ms withRangesOf :: ModuleName -> [Name] -> ModuleName
`withRangesOf` [Name]
ns = if Int
m Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
n then ModuleName
forall a. HasCallStack => a
__IMPOSSIBLE__ else [Name] -> ModuleName
MName ([Name] -> ModuleName) -> [Name] -> ModuleName
forall a b. (a -> b) -> a -> b
$
(Range -> Name -> Name) -> [Range] -> [Name] -> [Name]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith Range -> Name -> Name
forall t. SetRange t => Range -> t -> t
setRange (Int -> Range -> [Range]
forall a. Int -> a -> [a]
replicate (Int
m Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
n) Range
forall a. Range' a
noRange [Range] -> [Range] -> [Range]
forall a. [a] -> [a] -> [a]
++ (Name -> Range) -> [Name] -> [Range]
forall a b. (a -> b) -> [a] -> [b]
map Name -> Range
forall t. HasRange t => t -> Range
getRange [Name]
ns) [Name]
ms
where
m :: Int
m = [Name] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Name]
ms
n :: Int
n = [Name] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Name]
ns
withRangesOfQ :: ModuleName -> C.QName -> ModuleName
ModuleName
m withRangesOfQ :: ModuleName -> QName -> ModuleName
`withRangesOfQ` QName
q = ModuleName
m ModuleName -> [Name] -> ModuleName
`withRangesOf` QName -> [Name]
C.qnameParts QName
q
mnameFromList :: [Name] -> ModuleName
mnameFromList :: [Name] -> ModuleName
mnameFromList = [Name] -> ModuleName
MName
noModuleName :: ModuleName
noModuleName :: ModuleName
noModuleName = [Name] -> ModuleName
mnameFromList []
commonParentModule :: ModuleName -> ModuleName -> ModuleName
commonParentModule :: ModuleName -> ModuleName -> ModuleName
commonParentModule ModuleName
m1 ModuleName
m2 =
[Name] -> ModuleName
mnameFromList ([Name] -> ModuleName) -> [Name] -> ModuleName
forall a b. (a -> b) -> a -> b
$ [Name] -> [Name] -> [Name]
forall a. Eq a => [a] -> [a] -> [a]
commonPrefix (ModuleName -> [Name]
mnameToList ModuleName
m1) (ModuleName -> [Name]
mnameToList ModuleName
m2)
class MkName a where
mkName :: Range -> NameId -> a -> Name
mkName_ :: NameId -> a -> Name
mkName_ = Range -> NameId -> a -> Name
forall a. MkName a => Range -> NameId -> a -> Name
mkName Range
forall a. Range' a
noRange
instance MkName String where
mkName :: Range -> NameId -> String -> Name
mkName Range
r NameId
i String
s = NameId -> Name -> Range -> Fixity' -> Bool -> Name
Name NameId
i (Range -> NameInScope -> [NamePart] -> Name
C.Name Range
forall a. Range' a
noRange NameInScope
InScope (String -> [NamePart]
C.stringNameParts String
s)) Range
r Fixity'
noFixity' Bool
False
qnameToList :: QName -> [Name]
qnameToList :: QName -> [Name]
qnameToList (QName ModuleName
m Name
x) = ModuleName -> [Name]
mnameToList ModuleName
m [Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++ [Name
x]
qnameFromList :: [Name] -> QName
qnameFromList :: [Name] -> QName
qnameFromList [] = QName
forall a. HasCallStack => a
__IMPOSSIBLE__
qnameFromList [Name]
xs = ModuleName -> Name -> QName
QName ([Name] -> ModuleName
mnameFromList ([Name] -> ModuleName) -> [Name] -> ModuleName
forall a b. (a -> b) -> a -> b
$ [Name] -> [Name]
forall a. [a] -> [a]
init [Name]
xs) ([Name] -> Name
forall a. [a] -> a
last [Name]
xs)
qnameToMName :: QName -> ModuleName
qnameToMName :: QName -> ModuleName
qnameToMName = [Name] -> ModuleName
mnameFromList ([Name] -> ModuleName) -> (QName -> [Name]) -> QName -> ModuleName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> [Name]
qnameToList
mnameToQName :: ModuleName -> QName
mnameToQName :: ModuleName -> QName
mnameToQName = [Name] -> QName
qnameFromList ([Name] -> QName) -> (ModuleName -> [Name]) -> ModuleName -> QName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> [Name]
mnameToList
showQNameId :: QName -> String
showQNameId :: QName -> String
showQNameId QName
q = [Word64] -> String
forall a. Show a => a -> String
show [Word64]
ns String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"@" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Word64 -> String
forall a. Show a => a -> String
show Word64
m
where
is :: [NameId]
is = (Name -> NameId) -> [Name] -> [NameId]
forall a b. (a -> b) -> [a] -> [b]
map Name -> NameId
nameId ([Name] -> [NameId]) -> [Name] -> [NameId]
forall a b. (a -> b) -> a -> b
$ ModuleName -> [Name]
mnameToList (QName -> ModuleName
qnameModule QName
q) [Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++ [QName -> Name
qnameName QName
q]
ns :: [Word64]
ns = [ Word64
n | NameId Word64
n Word64
_ <- [NameId]
is ]
m :: Word64
m = [Word64] -> Word64
forall a. [a] -> a
head [ Word64
m | NameId Word64
_ Word64
m <- [NameId]
is ]
qnameToConcrete :: QName -> C.QName
qnameToConcrete :: QName -> QName
qnameToConcrete (QName ModuleName
m Name
x) =
(Name -> QName -> QName) -> QName -> [Name] -> QName
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Name -> QName -> QName
C.Qual (Name -> QName
C.QName (Name -> QName) -> Name -> QName
forall a b. (a -> b) -> a -> b
$ Name -> Name
nameConcrete Name
x) ([Name] -> QName) -> [Name] -> QName
forall a b. (a -> b) -> a -> b
$ (Name -> Name) -> [Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map Name -> Name
nameConcrete ([Name] -> [Name]) -> [Name] -> [Name]
forall a b. (a -> b) -> a -> b
$ ModuleName -> [Name]
mnameToList ModuleName
m
mnameToConcrete :: ModuleName -> C.QName
mnameToConcrete :: ModuleName -> QName
mnameToConcrete (MName []) = QName
forall a. HasCallStack => a
__IMPOSSIBLE__
mnameToConcrete (MName [Name]
xs) = (Name -> QName -> QName) -> QName -> [Name] -> QName
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Name -> QName -> QName
C.Qual (Name -> QName
C.QName (Name -> QName) -> Name -> QName
forall a b. (a -> b) -> a -> b
$ [Name] -> Name
forall a. [a] -> a
last [Name]
cs) ([Name] -> QName) -> [Name] -> QName
forall a b. (a -> b) -> a -> b
$ [Name] -> [Name]
forall a. [a] -> [a]
init [Name]
cs
where
cs :: [Name]
cs = (Name -> Name) -> [Name] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map Name -> Name
nameConcrete [Name]
xs
toTopLevelModuleName :: ModuleName -> C.TopLevelModuleName
toTopLevelModuleName :: ModuleName -> TopLevelModuleName
toTopLevelModuleName (MName []) = TopLevelModuleName
forall a. HasCallStack => a
__IMPOSSIBLE__
toTopLevelModuleName (MName [Name]
ms) = Range -> [String] -> TopLevelModuleName
C.TopLevelModuleName ([Name] -> Range
forall t. HasRange t => t -> Range
getRange [Name]
ms) ([String] -> TopLevelModuleName) -> [String] -> TopLevelModuleName
forall a b. (a -> b) -> a -> b
$ (Name -> String) -> [Name] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (Name -> String
C.nameToRawName (Name -> String) -> (Name -> Name) -> Name -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Name
nameConcrete) [Name]
ms
qualifyM :: ModuleName -> ModuleName -> ModuleName
qualifyM :: ModuleName -> ModuleName -> ModuleName
qualifyM ModuleName
m1 ModuleName
m2 = [Name] -> ModuleName
mnameFromList ([Name] -> ModuleName) -> [Name] -> ModuleName
forall a b. (a -> b) -> a -> b
$ ModuleName -> [Name]
mnameToList ModuleName
m1 [Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++ ModuleName -> [Name]
mnameToList ModuleName
m2
qualifyQ :: ModuleName -> QName -> QName
qualifyQ :: ModuleName -> QName -> QName
qualifyQ ModuleName
m QName
x = [Name] -> QName
qnameFromList ([Name] -> QName) -> [Name] -> QName
forall a b. (a -> b) -> a -> b
$ ModuleName -> [Name]
mnameToList ModuleName
m [Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++ QName -> [Name]
qnameToList QName
x
qualify :: ModuleName -> Name -> QName
qualify :: ModuleName -> Name -> QName
qualify = ModuleName -> Name -> QName
QName
qualify_ :: Name -> QName
qualify_ :: Name -> QName
qualify_ = ModuleName -> Name -> QName
qualify ModuleName
noModuleName
isOperator :: QName -> Bool
isOperator :: QName -> Bool
isOperator = Name -> Bool
C.isOperator (Name -> Bool) -> (QName -> Name) -> QName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Name
nameConcrete (Name -> Name) -> (QName -> Name) -> QName -> Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> Name
qnameName
isLeParentModuleOf :: ModuleName -> ModuleName -> Bool
isLeParentModuleOf :: ModuleName -> ModuleName -> Bool
isLeParentModuleOf = [Name] -> [Name] -> Bool
forall a. Eq a => [a] -> [a] -> Bool
isPrefixOf ([Name] -> [Name] -> Bool)
-> (ModuleName -> [Name]) -> ModuleName -> ModuleName -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` ModuleName -> [Name]
mnameToList
isLtParentModuleOf :: ModuleName -> ModuleName -> Bool
isLtParentModuleOf :: ModuleName -> ModuleName -> Bool
isLtParentModuleOf ModuleName
x ModuleName
y = Maybe [Name] -> Bool
forall a. Maybe a -> Bool
isJust (Maybe [Name] -> Bool) -> Maybe [Name] -> Bool
forall a b. (a -> b) -> a -> b
$ ((Name -> Name -> Bool) -> [Name] -> [Name] -> Maybe [Name]
forall a.
(a -> a -> Bool) -> Prefix a -> Prefix a -> Maybe (Prefix a)
stripPrefixBy Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
(==) ([Name] -> [Name] -> Maybe [Name])
-> (ModuleName -> [Name])
-> ModuleName
-> ModuleName
-> Maybe [Name]
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` ModuleName -> [Name]
mnameToList) ModuleName
x ModuleName
y
isLeChildModuleOf :: ModuleName -> ModuleName -> Bool
isLeChildModuleOf :: ModuleName -> ModuleName -> Bool
isLeChildModuleOf = (ModuleName -> ModuleName -> Bool)
-> ModuleName -> ModuleName -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip ModuleName -> ModuleName -> Bool
isLeParentModuleOf
isLtChildModuleOf :: ModuleName -> ModuleName -> Bool
isLtChildModuleOf :: ModuleName -> ModuleName -> Bool
isLtChildModuleOf = (ModuleName -> ModuleName -> Bool)
-> ModuleName -> ModuleName -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip ModuleName -> ModuleName -> Bool
isLtParentModuleOf
isInModule :: QName -> ModuleName -> Bool
isInModule :: QName -> ModuleName -> Bool
isInModule QName
q ModuleName
m = ModuleName -> [Name]
mnameToList ModuleName
m [Name] -> [Name] -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf` QName -> [Name]
qnameToList QName
q
nextName :: Name -> Name
nextName :: Name -> Name
nextName Name
x = Name
x { nameConcrete :: Name
nameConcrete = Name -> Name
C.nextName (Name -> Name
nameConcrete Name
x) }
sameRoot :: Name -> Name -> Bool
sameRoot :: Name -> Name -> Bool
sameRoot = Name -> Name -> Bool
C.sameRoot (Name -> Name -> Bool) -> (Name -> Name) -> Name -> Name -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Name -> Name
nameConcrete
instance Eq Name where
== :: Name -> Name -> Bool
(==) = NameId -> NameId -> Bool
forall a. Eq a => a -> a -> Bool
(==) (NameId -> NameId -> Bool)
-> (Name -> NameId) -> Name -> Name -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Name -> NameId
nameId
instance Ord Name where
compare :: Name -> Name -> Ordering
compare = NameId -> NameId -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (NameId -> NameId -> Ordering)
-> (Name -> NameId) -> Name -> Name -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Name -> NameId
nameId
instance Hashable Name where
{-# INLINE hashWithSalt #-}
hashWithSalt :: Int -> Name -> Int
hashWithSalt Int
salt = Int -> NameId -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt (NameId -> Int) -> (Name -> NameId) -> Name -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> NameId
nameId
instance Eq QName where
== :: QName -> QName -> Bool
(==) = Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Name -> Name -> Bool) -> (QName -> Name) -> QName -> QName -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` QName -> Name
qnameName
instance Ord QName where
compare :: QName -> QName -> Ordering
compare = Name -> Name -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Name -> Name -> Ordering)
-> (QName -> Name) -> QName -> QName -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` QName -> Name
qnameName
instance Hashable QName where
{-# INLINE hashWithSalt #-}
hashWithSalt :: Int -> QName -> Int
hashWithSalt Int
salt = Int -> Name -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt (Name -> Int) -> (QName -> Name) -> QName -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> Name
qnameName
instance IsNoName Name where
isNoName :: Name -> Bool
isNoName = Name -> Bool
forall a. IsNoName a => a -> Bool
isNoName (Name -> Bool) -> (Name -> Name) -> Name -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Name
nameConcrete
instance NumHoles Name where
numHoles :: Name -> Int
numHoles = Name -> Int
forall a. NumHoles a => a -> Int
numHoles (Name -> Int) -> (Name -> Name) -> Name -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Name
nameConcrete
instance NumHoles QName where
numHoles :: QName -> Int
numHoles = Name -> Int
forall a. NumHoles a => a -> Int
numHoles (Name -> Int) -> (QName -> Name) -> QName -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> Name
qnameName
instance NumHoles AmbiguousQName where
numHoles :: AmbiguousQName -> Int
numHoles = QName -> Int
forall a. NumHoles a => a -> Int
numHoles (QName -> Int)
-> (AmbiguousQName -> QName) -> AmbiguousQName -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AmbiguousQName -> QName
headAmbQ
lensQNameName :: Lens' Name QName
lensQNameName :: (Name -> f Name) -> QName -> f QName
lensQNameName Name -> f Name
f (QName ModuleName
m Name
n) = ModuleName -> Name -> QName
QName ModuleName
m (Name -> QName) -> f Name -> f QName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
f Name
n
instance LensFixity' Name where
lensFixity' :: (Fixity' -> f Fixity') -> Name -> f Name
lensFixity' Fixity' -> f Fixity'
f Name
n = Fixity' -> f Fixity'
f (Name -> Fixity'
nameFixity Name
n) f Fixity' -> (Fixity' -> Name) -> f Name
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Fixity'
fix' -> Name
n { nameFixity :: Fixity'
nameFixity = Fixity'
fix' }
instance LensFixity' QName where
lensFixity' :: (Fixity' -> f Fixity') -> QName -> f QName
lensFixity' = (Name -> f Name) -> QName -> f QName
Lens' Name QName
lensQNameName ((Name -> f Name) -> QName -> f QName)
-> ((Fixity' -> f Fixity') -> Name -> f Name)
-> (Fixity' -> f Fixity')
-> QName
-> f QName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Fixity' -> f Fixity') -> Name -> f Name
forall a. LensFixity' a => Lens' Fixity' a
lensFixity'
instance LensFixity Name where
lensFixity :: (Fixity -> f Fixity) -> Name -> f Name
lensFixity = (Fixity' -> f Fixity') -> Name -> f Name
forall a. LensFixity' a => Lens' Fixity' a
lensFixity' ((Fixity' -> f Fixity') -> Name -> f Name)
-> ((Fixity -> f Fixity) -> Fixity' -> f Fixity')
-> (Fixity -> f Fixity)
-> Name
-> f Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Fixity -> f Fixity) -> Fixity' -> f Fixity'
forall a. LensFixity a => Lens' Fixity a
lensFixity
instance LensFixity QName where
lensFixity :: (Fixity -> f Fixity) -> QName -> f QName
lensFixity = (Fixity' -> f Fixity') -> QName -> f QName
forall a. LensFixity' a => Lens' Fixity' a
lensFixity' ((Fixity' -> f Fixity') -> QName -> f QName)
-> ((Fixity -> f Fixity) -> Fixity' -> f Fixity')
-> (Fixity -> f Fixity)
-> QName
-> f QName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Fixity -> f Fixity) -> Fixity' -> f Fixity'
forall a. LensFixity a => Lens' Fixity a
lensFixity
instance LensInScope Name where
lensInScope :: (NameInScope -> f NameInScope) -> Name -> f Name
lensInScope NameInScope -> f NameInScope
f n :: Name
n@Name{ nameConcrete :: Name -> Name
nameConcrete = Name
x } =
(\Name
y -> Name
n { nameConcrete :: Name
nameConcrete = Name
y }) (Name -> Name) -> f Name -> f Name
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NameInScope -> f NameInScope) -> Name -> f Name
forall a. LensInScope a => Lens' NameInScope a
lensInScope NameInScope -> f NameInScope
f Name
x
instance LensInScope QName where
lensInScope :: (NameInScope -> f NameInScope) -> QName -> f QName
lensInScope NameInScope -> f NameInScope
f q :: QName
q@QName{ qnameName :: QName -> Name
qnameName = Name
n } =
(\Name
n' -> QName
q { qnameName :: Name
qnameName = Name
n' }) (Name -> QName) -> f Name -> f QName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NameInScope -> f NameInScope) -> Name -> f Name
forall a. LensInScope a => Lens' NameInScope a
lensInScope NameInScope -> f NameInScope
f Name
n
deriving instance Show a => Show (QNamed a)
deriving instance Show AmbiguousQName
instance Show Name where
show :: Name -> String
show = Name -> String
forall a. Pretty a => a -> String
prettyShow
instance Show ModuleName where
show :: ModuleName -> String
show = ModuleName -> String
forall a. Pretty a => a -> String
prettyShow
instance Show QName where
show :: QName -> String
show = QName -> String
forall a. Pretty a => a -> String
prettyShow
nameToArgName :: Name -> ArgName
nameToArgName :: Name -> String
nameToArgName = String -> String
stringToArgName (String -> String) -> (Name -> String) -> Name -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> String
forall a. Pretty a => a -> String
prettyShow
namedArgName :: NamedArg Name -> ArgName
namedArgName :: NamedArg Name -> String
namedArgName NamedArg Name
x = String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe (Name -> String
nameToArgName (Name -> String) -> Name -> String
forall a b. (a -> b) -> a -> b
$ NamedArg Name -> Name
forall a. NamedArg a -> a
namedArg NamedArg Name
x) (Maybe String -> String) -> Maybe String -> String
forall a b. (a -> b) -> a -> b
$ NamedArg Name -> Maybe String
forall a. LensNamed NamedName a => a -> Maybe String
bareNameOf NamedArg Name
x
instance Pretty Name where
pretty :: Name -> Doc
pretty = Name -> Doc
forall a. Pretty a => a -> Doc
pretty (Name -> Doc) -> (Name -> Name) -> Name -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Name
nameConcrete
instance Pretty ModuleName where
pretty :: ModuleName -> Doc
pretty = [Doc] -> Doc
hcat ([Doc] -> Doc) -> (ModuleName -> [Doc]) -> ModuleName -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> [Doc] -> [Doc]
punctuate Doc
"." ([Doc] -> [Doc]) -> (ModuleName -> [Doc]) -> ModuleName -> [Doc]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Doc) -> [Name] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map Name -> Doc
forall a. Pretty a => a -> Doc
pretty ([Name] -> [Doc]) -> (ModuleName -> [Name]) -> ModuleName -> [Doc]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> [Name]
mnameToList
instance Pretty QName where
pretty :: QName -> Doc
pretty = [Doc] -> Doc
hcat ([Doc] -> Doc) -> (QName -> [Doc]) -> QName -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> [Doc] -> [Doc]
punctuate Doc
"." ([Doc] -> [Doc]) -> (QName -> [Doc]) -> QName -> [Doc]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> Doc) -> [Name] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map Name -> Doc
forall a. Pretty a => a -> Doc
pretty ([Name] -> [Doc]) -> (QName -> [Name]) -> QName -> [Doc]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> [Name]
qnameToList
instance Pretty AmbiguousQName where
pretty :: AmbiguousQName -> Doc
pretty (AmbQ NonEmpty QName
qs) = [Doc] -> Doc
hcat ([Doc] -> Doc) -> [Doc] -> Doc
forall a b. (a -> b) -> a -> b
$ Doc -> [Doc] -> [Doc]
punctuate Doc
" | " ([Doc] -> [Doc]) -> [Doc] -> [Doc]
forall a b. (a -> b) -> a -> b
$ (QName -> Doc) -> [QName] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map QName -> Doc
forall a. Pretty a => a -> Doc
pretty (NonEmpty QName -> [QName]
forall a. NonEmpty a -> [a]
NonEmpty.toList NonEmpty QName
qs)
instance Pretty a => Pretty (QNamed a) where
pretty :: QNamed a -> Doc
pretty (QNamed QName
a a
b) = QName -> Doc
forall a. Pretty a => a -> Doc
pretty QName
a Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
"." Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> a -> Doc
forall a. Pretty a => a -> Doc
pretty a
b
instance HasRange Name where
getRange :: Name -> Range
getRange = Name -> Range
forall t. HasRange t => t -> Range
getRange (Name -> Range) -> (Name -> Name) -> Name -> Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Name
nameConcrete
instance HasRange ModuleName where
getRange :: ModuleName -> Range
getRange (MName []) = Range
forall a. Range' a
noRange
getRange (MName [Name]
xs) = [Name] -> Range
forall t. HasRange t => t -> Range
getRange [Name]
xs
instance HasRange QName where
getRange :: QName -> Range
getRange QName
q = (ModuleName, Name) -> Range
forall t. HasRange t => t -> Range
getRange (QName -> ModuleName
qnameModule QName
q, QName -> Name
qnameName QName
q)
instance HasRange AmbiguousQName where
getRange :: AmbiguousQName -> Range
getRange (AmbQ (QName
c :| [QName]
_)) = QName -> Range
forall t. HasRange t => t -> Range
getRange QName
c
instance SetRange Name where
setRange :: Range -> Name -> Name
setRange Range
r Name
x = Name
x { nameConcrete :: Name
nameConcrete = Range -> Name -> Name
forall t. SetRange t => Range -> t -> t
setRange Range
r (Name -> Name) -> Name -> Name
forall a b. (a -> b) -> a -> b
$ Name -> Name
nameConcrete Name
x }
instance SetRange QName where
setRange :: Range -> QName -> QName
setRange Range
r QName
q = QName
q { qnameModule :: ModuleName
qnameModule = Range -> ModuleName -> ModuleName
forall t. SetRange t => Range -> t -> t
setRange Range
r (ModuleName -> ModuleName) -> ModuleName -> ModuleName
forall a b. (a -> b) -> a -> b
$ QName -> ModuleName
qnameModule QName
q
, qnameName :: Name
qnameName = Range -> Name -> Name
forall t. SetRange t => Range -> t -> t
setRange Range
r (Name -> Name) -> Name -> Name
forall a b. (a -> b) -> a -> b
$ QName -> Name
qnameName QName
q
}
instance SetRange ModuleName where
setRange :: Range -> ModuleName -> ModuleName
setRange Range
r (MName [Name]
ns) = [Name] -> ModuleName
MName ((Range -> Name -> Name) -> [Range] -> [Name] -> [Name]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith Range -> Name -> Name
forall t. SetRange t => Range -> t -> t
setRange [Range]
rs [Name]
ns)
where
rs :: [Range]
rs = Int -> Range -> [Range]
forall a. Int -> a -> [a]
replicate ([Name] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Name]
ns Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Range
forall a. Range' a
noRange [Range] -> [Range] -> [Range]
forall a. [a] -> [a] -> [a]
++ [Range
r]
instance KillRange Name where
killRange :: Name -> Name
killRange (Name NameId
a Name
b Range
c Fixity'
d Bool
e) =
((NameId -> Name -> Range -> Fixity' -> Bool -> Name)
-> NameId -> Name -> Range -> Fixity' -> Bool -> Name
forall a b c d e.
(KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 NameId -> Name -> Range -> Fixity' -> Bool -> Name
Name NameId
a Name
b Range
c Fixity'
d Bool
e) { nameBindingSite :: Range
nameBindingSite = Range
c }
instance KillRange ModuleName where
killRange :: ModuleName -> ModuleName
killRange (MName [Name]
xs) = [Name] -> ModuleName
MName ([Name] -> ModuleName) -> [Name] -> ModuleName
forall a b. (a -> b) -> a -> b
$ [Name] -> [Name]
forall a. KillRange a => KillRangeT a
killRange [Name]
xs
instance KillRange QName where
killRange :: QName -> QName
killRange (QName ModuleName
a Name
b) = (ModuleName -> Name -> QName) -> ModuleName -> Name -> QName
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 ModuleName -> Name -> QName
QName ModuleName
a Name
b
instance KillRange AmbiguousQName where
killRange :: AmbiguousQName -> AmbiguousQName
killRange (AmbQ NonEmpty QName
xs) = NonEmpty QName -> AmbiguousQName
AmbQ (NonEmpty QName -> AmbiguousQName)
-> NonEmpty QName -> AmbiguousQName
forall a b. (a -> b) -> a -> b
$ KillRangeT (NonEmpty QName)
forall a. KillRange a => KillRangeT a
killRange NonEmpty QName
xs
instance Sized QName where
size :: QName -> Int
size = [Name] -> Int
forall a. Sized a => a -> Int
size ([Name] -> Int) -> (QName -> [Name]) -> QName -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> [Name]
qnameToList
instance Sized ModuleName where
size :: ModuleName -> Int
size = [Name] -> Int
forall a. Sized a => a -> Int
size ([Name] -> Int) -> (ModuleName -> [Name]) -> ModuleName -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> [Name]
mnameToList
instance NFData Name where
rnf :: Name -> ()
rnf (Name NameId
_ Name
a Range
_ Fixity'
b Bool
c) = Name -> ()
forall a. NFData a => a -> ()
rnf Name
a () -> () -> ()
`seq` Fixity' -> ()
forall a. NFData a => a -> ()
rnf Fixity'
b () -> () -> ()
`seq` Bool -> ()
forall a. NFData a => a -> ()
rnf Bool
c
instance NFData QName where
rnf :: QName -> ()
rnf (QName ModuleName
a Name
b) = ModuleName -> ()
forall a. NFData a => a -> ()
rnf ModuleName
a () -> () -> ()
`seq` Name -> ()
forall a. NFData a => a -> ()
rnf Name
b
instance NFData ModuleName where
rnf :: ModuleName -> ()
rnf (MName [Name]
a) = [Name] -> ()
forall a. NFData a => a -> ()
rnf [Name]
a