module Agda.TypeChecking.Free.Lazy where
import Control.Applicative hiding (empty)
import Control.Monad ( guard )
import Control.Monad.Reader ( MonadReader(..), asks, ReaderT, Reader, runReader )
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import Data.HashSet (HashSet)
import qualified Data.HashSet as HashSet
import Data.Semigroup ( Semigroup, (<>) )
import qualified Data.Set as Set
import Data.Set (Set)
import Agda.Syntax.Common
import Agda.Syntax.Internal
import Agda.Utils.Functor
import Agda.Utils.Lens
import Agda.Utils.Monad
import Agda.Utils.Null
import Agda.Utils.Semigroup
import Agda.Utils.Singleton
import Agda.Utils.Size
newtype MetaSet = MetaSet { MetaSet -> HashSet MetaId
theMetaSet :: HashSet MetaId }
deriving (MetaSet -> MetaSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetaSet -> MetaSet -> Bool
$c/= :: MetaSet -> MetaSet -> Bool
== :: MetaSet -> MetaSet -> Bool
$c== :: MetaSet -> MetaSet -> Bool
Eq, Variable -> MetaSet -> ShowS
[MetaSet] -> ShowS
MetaSet -> String
forall a.
(Variable -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetaSet] -> ShowS
$cshowList :: [MetaSet] -> ShowS
show :: MetaSet -> String
$cshow :: MetaSet -> String
showsPrec :: Variable -> MetaSet -> ShowS
$cshowsPrec :: Variable -> MetaSet -> ShowS
Show, MetaSet
MetaSet -> Bool
forall a. a -> (a -> Bool) -> Null a
null :: MetaSet -> Bool
$cnull :: MetaSet -> Bool
empty :: MetaSet
$cempty :: MetaSet
Null, NonEmpty MetaSet -> MetaSet
MetaSet -> MetaSet -> MetaSet
forall b. Integral b => b -> MetaSet -> MetaSet
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: forall b. Integral b => b -> MetaSet -> MetaSet
$cstimes :: forall b. Integral b => b -> MetaSet -> MetaSet
sconcat :: NonEmpty MetaSet -> MetaSet
$csconcat :: NonEmpty MetaSet -> MetaSet
<> :: MetaSet -> MetaSet -> MetaSet
$c<> :: MetaSet -> MetaSet -> MetaSet
Semigroup, Semigroup MetaSet
MetaSet
[MetaSet] -> MetaSet
MetaSet -> MetaSet -> MetaSet
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [MetaSet] -> MetaSet
$cmconcat :: [MetaSet] -> MetaSet
mappend :: MetaSet -> MetaSet -> MetaSet
$cmappend :: MetaSet -> MetaSet -> MetaSet
mempty :: MetaSet
$cmempty :: MetaSet
Monoid)
instance Singleton MetaId MetaSet where
singleton :: MetaId -> MetaSet
singleton = HashSet MetaId -> MetaSet
MetaSet forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall el coll. Singleton el coll => el -> coll
singleton
insertMetaSet :: MetaId -> MetaSet -> MetaSet
insertMetaSet :: MetaId -> MetaSet -> MetaSet
insertMetaSet MetaId
m (MetaSet HashSet MetaId
ms) = HashSet MetaId -> MetaSet
MetaSet forall a b. (a -> b) -> a -> b
$ forall a. (Eq a, Hashable a) => a -> HashSet a -> HashSet a
HashSet.insert MetaId
m HashSet MetaId
ms
foldrMetaSet :: (MetaId -> a -> a) -> a -> MetaSet -> a
foldrMetaSet :: forall a. (MetaId -> a -> a) -> a -> MetaSet -> a
foldrMetaSet MetaId -> a -> a
f a
e MetaSet
ms = forall b a. (b -> a -> a) -> a -> HashSet b -> a
HashSet.foldr MetaId -> a -> a
f a
e forall a b. (a -> b) -> a -> b
$ MetaSet -> HashSet MetaId
theMetaSet MetaSet
ms
metaSetToBlocker :: MetaSet -> Blocker
metaSetToBlocker :: MetaSet -> Blocker
metaSetToBlocker MetaSet
ms = Set Blocker -> Blocker
unblockOnAny forall a b. (a -> b) -> a -> b
$ forall a. (MetaId -> a -> a) -> a -> MetaSet -> a
foldrMetaSet (forall a. Ord a => a -> Set a -> Set a
Set.insert forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetaId -> Blocker
unblockOnMeta) forall a. Set a
Set.empty MetaSet
ms
data FlexRig' a
= Flexible a
| WeaklyRigid
| Unguarded
| StronglyRigid
deriving (FlexRig' a -> FlexRig' a -> Bool
forall a. Eq a => FlexRig' a -> FlexRig' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FlexRig' a -> FlexRig' a -> Bool
$c/= :: forall a. Eq a => FlexRig' a -> FlexRig' a -> Bool
== :: FlexRig' a -> FlexRig' a -> Bool
$c== :: forall a. Eq a => FlexRig' a -> FlexRig' a -> Bool
Eq, Variable -> FlexRig' a -> ShowS
forall a. Show a => Variable -> FlexRig' a -> ShowS
forall a. Show a => [FlexRig' a] -> ShowS
forall a. Show a => FlexRig' a -> String
forall a.
(Variable -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FlexRig' a] -> ShowS
$cshowList :: forall a. Show a => [FlexRig' a] -> ShowS
show :: FlexRig' a -> String
$cshow :: forall a. Show a => FlexRig' a -> String
showsPrec :: Variable -> FlexRig' a -> ShowS
$cshowsPrec :: forall a. Show a => Variable -> FlexRig' a -> ShowS
Show, forall a b. a -> FlexRig' b -> FlexRig' a
forall a b. (a -> b) -> FlexRig' a -> FlexRig' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> FlexRig' b -> FlexRig' a
$c<$ :: forall a b. a -> FlexRig' b -> FlexRig' a
fmap :: forall a b. (a -> b) -> FlexRig' a -> FlexRig' b
$cfmap :: forall a b. (a -> b) -> FlexRig' a -> FlexRig' b
Functor, forall a. Eq a => a -> FlexRig' a -> Bool
forall a. Num a => FlexRig' a -> a
forall a. Ord a => FlexRig' a -> a
forall m. Monoid m => FlexRig' m -> m
forall a. FlexRig' a -> Bool
forall a. FlexRig' a -> Variable
forall a. FlexRig' a -> [a]
forall a. (a -> a -> a) -> FlexRig' a -> a
forall m a. Monoid m => (a -> m) -> FlexRig' a -> m
forall b a. (b -> a -> b) -> b -> FlexRig' a -> b
forall a b. (a -> b -> b) -> b -> FlexRig' 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 -> Variable)
-> (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 :: forall a. Num a => FlexRig' a -> a
$cproduct :: forall a. Num a => FlexRig' a -> a
sum :: forall a. Num a => FlexRig' a -> a
$csum :: forall a. Num a => FlexRig' a -> a
minimum :: forall a. Ord a => FlexRig' a -> a
$cminimum :: forall a. Ord a => FlexRig' a -> a
maximum :: forall a. Ord a => FlexRig' a -> a
$cmaximum :: forall a. Ord a => FlexRig' a -> a
elem :: forall a. Eq a => a -> FlexRig' a -> Bool
$celem :: forall a. Eq a => a -> FlexRig' a -> Bool
length :: forall a. FlexRig' a -> Variable
$clength :: forall a. FlexRig' a -> Variable
null :: forall a. FlexRig' a -> Bool
$cnull :: forall a. FlexRig' a -> Bool
toList :: forall a. FlexRig' a -> [a]
$ctoList :: forall a. FlexRig' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> FlexRig' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> FlexRig' a -> a
foldr1 :: forall a. (a -> a -> a) -> FlexRig' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> FlexRig' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> FlexRig' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> FlexRig' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> FlexRig' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> FlexRig' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> FlexRig' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> FlexRig' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> FlexRig' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> FlexRig' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> FlexRig' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> FlexRig' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> FlexRig' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> FlexRig' a -> m
fold :: forall m. Monoid m => FlexRig' m -> m
$cfold :: forall m. Monoid m => FlexRig' m -> m
Foldable)
type FlexRig = FlexRig' MetaSet
class LensFlexRig a o | o -> a where
lensFlexRig :: Lens' (FlexRig' a) o
instance LensFlexRig a (FlexRig' a) where
lensFlexRig :: Lens' (FlexRig' a) (FlexRig' a)
lensFlexRig FlexRig' a -> f (FlexRig' a)
f FlexRig' a
x = FlexRig' a -> f (FlexRig' a)
f FlexRig' a
x
isFlexible :: LensFlexRig a o => o -> Bool
isFlexible :: forall a o. LensFlexRig a o => o -> Bool
isFlexible o
o = case o
o forall o i. o -> Lens' i o -> i
^. forall a o. LensFlexRig a o => Lens' (FlexRig' a) o
lensFlexRig of
Flexible {} -> Bool
True
FlexRig' a
_ -> Bool
False
isUnguarded :: LensFlexRig a o => o -> Bool
isUnguarded :: forall a o. LensFlexRig a o => o -> Bool
isUnguarded o
o = case o
o forall o i. o -> Lens' i o -> i
^. forall a o. LensFlexRig a o => Lens' (FlexRig' a) o
lensFlexRig of
FlexRig' a
Unguarded -> Bool
True
FlexRig' a
_ -> Bool
False
isWeaklyRigid :: LensFlexRig a o => o -> Bool
isWeaklyRigid :: forall a o. LensFlexRig a o => o -> Bool
isWeaklyRigid o
o = case o
o forall o i. o -> Lens' i o -> i
^. forall a o. LensFlexRig a o => Lens' (FlexRig' a) o
lensFlexRig of
FlexRig' a
WeaklyRigid -> Bool
True
FlexRig' a
_ -> Bool
False
isStronglyRigid :: LensFlexRig a o => o -> Bool
isStronglyRigid :: forall a o. LensFlexRig a o => o -> Bool
isStronglyRigid o
o = case o
o forall o i. o -> Lens' i o -> i
^. forall a o. LensFlexRig a o => Lens' (FlexRig' a) o
lensFlexRig of
FlexRig' a
StronglyRigid -> Bool
True
FlexRig' a
_ -> Bool
False
addFlexRig :: Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
addFlexRig :: forall a. Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
addFlexRig = forall a b c. ((a, b) -> c) -> a -> b -> c
curry forall a b. (a -> b) -> a -> b
$ \case
(FlexRig' a
StronglyRigid, FlexRig' a
_) -> forall a. FlexRig' a
StronglyRigid
(FlexRig' a
_, FlexRig' a
StronglyRigid) -> forall a. FlexRig' a
StronglyRigid
(FlexRig' a
Unguarded, FlexRig' a
_) -> forall a. FlexRig' a
Unguarded
(FlexRig' a
_, FlexRig' a
Unguarded) -> forall a. FlexRig' a
Unguarded
(FlexRig' a
WeaklyRigid, FlexRig' a
_) -> forall a. FlexRig' a
WeaklyRigid
(FlexRig' a
_, FlexRig' a
WeaklyRigid) -> forall a. FlexRig' a
WeaklyRigid
(Flexible a
ms1, Flexible a
ms2) -> forall a. a -> FlexRig' a
Flexible forall a b. (a -> b) -> a -> b
$ a
ms1 forall a. Semigroup a => a -> a -> a
<> a
ms2
zeroFlexRig :: Monoid a => FlexRig' a
zeroFlexRig :: forall a. Monoid a => FlexRig' a
zeroFlexRig = forall a. a -> FlexRig' a
Flexible forall a. Monoid a => a
mempty
omegaFlexRig :: FlexRig' a
omegaFlexRig :: forall a. FlexRig' a
omegaFlexRig = forall a. FlexRig' a
StronglyRigid
composeFlexRig :: Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
composeFlexRig :: forall a. Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
composeFlexRig = forall a b c. ((a, b) -> c) -> a -> b -> c
curry forall a b. (a -> b) -> a -> b
$ \case
(Flexible a
ms1, Flexible a
ms2) -> forall a. a -> FlexRig' a
Flexible forall a b. (a -> b) -> a -> b
$ a
ms1 forall a. Semigroup a => a -> a -> a
<> a
ms2
(Flexible a
ms1, FlexRig' a
_) -> forall a. a -> FlexRig' a
Flexible a
ms1
(FlexRig' a
_, Flexible a
ms2) -> forall a. a -> FlexRig' a
Flexible a
ms2
(FlexRig' a
WeaklyRigid, FlexRig' a
_) -> forall a. FlexRig' a
WeaklyRigid
(FlexRig' a
_, FlexRig' a
WeaklyRigid) -> forall a. FlexRig' a
WeaklyRigid
(FlexRig' a
StronglyRigid, FlexRig' a
_) -> forall a. FlexRig' a
StronglyRigid
(FlexRig' a
_, FlexRig' a
StronglyRigid) -> forall a. FlexRig' a
StronglyRigid
(FlexRig' a
Unguarded, FlexRig' a
Unguarded) -> forall a. FlexRig' a
Unguarded
oneFlexRig :: FlexRig' a
oneFlexRig :: forall a. FlexRig' a
oneFlexRig = forall a. FlexRig' a
Unguarded
data VarOcc' a = VarOcc
{ forall a. VarOcc' a -> FlexRig' a
varFlexRig :: FlexRig' a
, forall a. VarOcc' a -> Modality
varModality :: Modality
}
deriving (Variable -> VarOcc' a -> ShowS
forall a. Show a => Variable -> VarOcc' a -> ShowS
forall a. Show a => [VarOcc' a] -> ShowS
forall a. Show a => VarOcc' a -> String
forall a.
(Variable -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VarOcc' a] -> ShowS
$cshowList :: forall a. Show a => [VarOcc' a] -> ShowS
show :: VarOcc' a -> String
$cshow :: forall a. Show a => VarOcc' a -> String
showsPrec :: Variable -> VarOcc' a -> ShowS
$cshowsPrec :: forall a. Show a => Variable -> VarOcc' a -> ShowS
Show)
type VarOcc = VarOcc' MetaSet
instance Eq a => Eq (VarOcc' a) where
VarOcc FlexRig' a
fr Modality
m == :: VarOcc' a -> VarOcc' a -> Bool
== VarOcc FlexRig' a
fr' Modality
m' = FlexRig' a
fr forall a. Eq a => a -> a -> Bool
== FlexRig' a
fr' Bool -> Bool -> Bool
&& forall a b. (LensModality a, LensModality b) => a -> b -> Bool
sameModality Modality
m Modality
m'
instance LensModality (VarOcc' a) where
getModality :: VarOcc' a -> Modality
getModality = forall a. VarOcc' a -> Modality
varModality
mapModality :: (Modality -> Modality) -> VarOcc' a -> VarOcc' a
mapModality Modality -> Modality
f (VarOcc FlexRig' a
x Modality
r) = forall a. FlexRig' a -> Modality -> VarOcc' a
VarOcc FlexRig' a
x forall a b. (a -> b) -> a -> b
$ Modality -> Modality
f Modality
r
instance LensRelevance (VarOcc' a) where
instance LensQuantity (VarOcc' a) where
instance LensFlexRig a (VarOcc' a) where
lensFlexRig :: Lens' (FlexRig' a) (VarOcc' a)
lensFlexRig FlexRig' a -> f (FlexRig' a)
f (VarOcc FlexRig' a
fr Modality
m) = FlexRig' a -> f (FlexRig' a)
f FlexRig' a
fr forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ FlexRig' a
fr' -> forall a. FlexRig' a -> Modality -> VarOcc' a
VarOcc FlexRig' a
fr' Modality
m
instance Semigroup a => Semigroup (VarOcc' a) where
VarOcc FlexRig' a
o Modality
m <> :: VarOcc' a -> VarOcc' a -> VarOcc' a
<> VarOcc FlexRig' a
o' Modality
m' = forall a. FlexRig' a -> Modality -> VarOcc' a
VarOcc (forall a. Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
addFlexRig FlexRig' a
o FlexRig' a
o') (Modality -> Modality -> Modality
addModality Modality
m Modality
m')
instance (Semigroup a, Monoid a) => Monoid (VarOcc' a) where
mempty :: VarOcc' a
mempty = forall a. FlexRig' a -> Modality -> VarOcc' a
VarOcc (forall a. a -> FlexRig' a
Flexible forall a. Monoid a => a
mempty) Modality
zeroModality
mappend :: VarOcc' a -> VarOcc' a -> VarOcc' a
mappend = forall a. Semigroup a => a -> a -> a
(<>)
topVarOcc :: VarOcc' a
topVarOcc :: forall a. VarOcc' a
topVarOcc = forall a. FlexRig' a -> Modality -> VarOcc' a
VarOcc forall a. FlexRig' a
StronglyRigid Modality
topModality
composeVarOcc :: Semigroup a => VarOcc' a -> VarOcc' a -> VarOcc' a
composeVarOcc :: forall a. Semigroup a => VarOcc' a -> VarOcc' a -> VarOcc' a
composeVarOcc (VarOcc FlexRig' a
o Modality
m) (VarOcc FlexRig' a
o' Modality
m') = forall a. FlexRig' a -> Modality -> VarOcc' a
VarOcc (forall a. Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
composeFlexRig FlexRig' a
o FlexRig' a
o') (Modality -> Modality -> Modality
composeModality Modality
m Modality
m')
oneVarOcc :: VarOcc' a
oneVarOcc :: forall a. VarOcc' a
oneVarOcc = forall a. FlexRig' a -> Modality -> VarOcc' a
VarOcc forall a. FlexRig' a
Unguarded Modality
unitModality
class (Singleton MetaId a, Semigroup a, Monoid a, Semigroup c, Monoid c) => IsVarSet a c | c -> a where
withVarOcc :: VarOcc' a -> c -> c
type TheVarMap' a = IntMap (VarOcc' a)
newtype VarMap' a = VarMap { forall a. VarMap' a -> TheVarMap' a
theVarMap :: TheVarMap' a }
deriving (VarMap' a -> VarMap' a -> Bool
forall a. Eq a => VarMap' a -> VarMap' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VarMap' a -> VarMap' a -> Bool
$c/= :: forall a. Eq a => VarMap' a -> VarMap' a -> Bool
== :: VarMap' a -> VarMap' a -> Bool
$c== :: forall a. Eq a => VarMap' a -> VarMap' a -> Bool
Eq, Variable -> VarMap' a -> ShowS
forall a. Show a => Variable -> VarMap' a -> ShowS
forall a. Show a => [VarMap' a] -> ShowS
forall a. Show a => VarMap' a -> String
forall a.
(Variable -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VarMap' a] -> ShowS
$cshowList :: forall a. Show a => [VarMap' a] -> ShowS
show :: VarMap' a -> String
$cshow :: forall a. Show a => VarMap' a -> String
showsPrec :: Variable -> VarMap' a -> ShowS
$cshowsPrec :: forall a. Show a => Variable -> VarMap' a -> ShowS
Show)
type TheVarMap = TheVarMap' MetaSet
type VarMap = VarMap' MetaSet
instance Singleton Variable (VarMap' a) where
singleton :: Variable -> VarMap' a
singleton Variable
i = forall a. TheVarMap' a -> VarMap' a
VarMap forall a b. (a -> b) -> a -> b
$ forall a. Variable -> a -> IntMap a
IntMap.singleton Variable
i forall a. VarOcc' a
oneVarOcc
mapVarMap :: (TheVarMap' a -> TheVarMap' b) -> VarMap' a -> VarMap' b
mapVarMap :: forall a b.
(TheVarMap' a -> TheVarMap' b) -> VarMap' a -> VarMap' b
mapVarMap TheVarMap' a -> TheVarMap' b
f = forall a. TheVarMap' a -> VarMap' a
VarMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. TheVarMap' a -> TheVarMap' b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. VarMap' a -> TheVarMap' a
theVarMap
lookupVarMap :: Variable -> VarMap' a -> Maybe (VarOcc' a)
lookupVarMap :: forall a. Variable -> VarMap' a -> Maybe (VarOcc' a)
lookupVarMap Variable
i = forall a. Variable -> IntMap a -> Maybe a
IntMap.lookup Variable
i forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. VarMap' a -> TheVarMap' a
theVarMap
instance Semigroup a => Semigroup (VarMap' a) where
VarMap TheVarMap' a
m <> :: VarMap' a -> VarMap' a -> VarMap' a
<> VarMap TheVarMap' a
m' = forall a. TheVarMap' a -> VarMap' a
VarMap forall a b. (a -> b) -> a -> b
$ forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
IntMap.unionWith forall a. Semigroup a => a -> a -> a
(<>) TheVarMap' a
m TheVarMap' a
m'
instance Semigroup a => Monoid (VarMap' a) where
mempty :: VarMap' a
mempty = forall a. TheVarMap' a -> VarMap' a
VarMap forall a. IntMap a
IntMap.empty
mappend :: VarMap' a -> VarMap' a -> VarMap' a
mappend = forall a. Semigroup a => a -> a -> a
(<>)
mconcat :: [VarMap' a] -> VarMap' a
mconcat = forall a. TheVarMap' a -> VarMap' a
VarMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> f (IntMap a) -> IntMap a
IntMap.unionsWith forall a. Semigroup a => a -> a -> a
(<>) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map forall a. VarMap' a -> TheVarMap' a
theVarMap
instance (Singleton MetaId a, Semigroup a, Monoid a) => IsVarSet a (VarMap' a) where
withVarOcc :: VarOcc' a -> VarMap' a -> VarMap' a
withVarOcc VarOcc' a
o = forall a b.
(TheVarMap' a -> TheVarMap' b) -> VarMap' a -> VarMap' b
mapVarMap forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a -> b) -> a -> b
$ forall a. Semigroup a => VarOcc' a -> VarOcc' a -> VarOcc' a
composeVarOcc VarOcc' a
o
type TheFlexRigMap = IntMap (FlexRig' ())
newtype FlexRigMap = FlexRigMap { FlexRigMap -> TheFlexRigMap
theFlexRigMap :: TheFlexRigMap }
deriving (Variable -> FlexRigMap -> ShowS
[FlexRigMap] -> ShowS
FlexRigMap -> String
forall a.
(Variable -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FlexRigMap] -> ShowS
$cshowList :: [FlexRigMap] -> ShowS
show :: FlexRigMap -> String
$cshow :: FlexRigMap -> String
showsPrec :: Variable -> FlexRigMap -> ShowS
$cshowsPrec :: Variable -> FlexRigMap -> ShowS
Show, Singleton (Variable, FlexRig' ()))
mapFlexRigMap :: (TheFlexRigMap -> TheFlexRigMap) -> FlexRigMap -> FlexRigMap
mapFlexRigMap :: (TheFlexRigMap -> TheFlexRigMap) -> FlexRigMap -> FlexRigMap
mapFlexRigMap TheFlexRigMap -> TheFlexRigMap
f = TheFlexRigMap -> FlexRigMap
FlexRigMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. TheFlexRigMap -> TheFlexRigMap
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. FlexRigMap -> TheFlexRigMap
theFlexRigMap
instance Semigroup FlexRigMap where
FlexRigMap TheFlexRigMap
m <> :: FlexRigMap -> FlexRigMap -> FlexRigMap
<> FlexRigMap TheFlexRigMap
m' = TheFlexRigMap -> FlexRigMap
FlexRigMap forall a b. (a -> b) -> a -> b
$ forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
IntMap.unionWith forall a. Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
addFlexRig TheFlexRigMap
m TheFlexRigMap
m'
instance Monoid FlexRigMap where
mempty :: FlexRigMap
mempty = TheFlexRigMap -> FlexRigMap
FlexRigMap forall a. IntMap a
IntMap.empty
mappend :: FlexRigMap -> FlexRigMap -> FlexRigMap
mappend = forall a. Semigroup a => a -> a -> a
(<>)
mconcat :: [FlexRigMap] -> FlexRigMap
mconcat = TheFlexRigMap -> FlexRigMap
FlexRigMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> f (IntMap a) -> IntMap a
IntMap.unionsWith forall a. Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
addFlexRig forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map FlexRigMap -> TheFlexRigMap
theFlexRigMap
instance IsVarSet () FlexRigMap where
withVarOcc :: VarOcc' () -> FlexRigMap -> FlexRigMap
withVarOcc VarOcc' ()
o = (TheFlexRigMap -> TheFlexRigMap) -> FlexRigMap -> FlexRigMap
mapFlexRigMap forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a -> b) -> a -> b
$ forall a. Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
composeFlexRig forall a b. (a -> b) -> a -> b
$ () forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall a. VarOcc' a -> FlexRig' a
varFlexRig VarOcc' ()
o
instance Singleton MetaId () where
singleton :: MetaId -> ()
singleton MetaId
_ = ()
data IgnoreSorts
= IgnoreNot
| IgnoreInAnnotations
| IgnoreAll
deriving (IgnoreSorts -> IgnoreSorts -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IgnoreSorts -> IgnoreSorts -> Bool
$c/= :: IgnoreSorts -> IgnoreSorts -> Bool
== :: IgnoreSorts -> IgnoreSorts -> Bool
$c== :: IgnoreSorts -> IgnoreSorts -> Bool
Eq, Variable -> IgnoreSorts -> ShowS
[IgnoreSorts] -> ShowS
IgnoreSorts -> String
forall a.
(Variable -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IgnoreSorts] -> ShowS
$cshowList :: [IgnoreSorts] -> ShowS
show :: IgnoreSorts -> String
$cshow :: IgnoreSorts -> String
showsPrec :: Variable -> IgnoreSorts -> ShowS
$cshowsPrec :: Variable -> IgnoreSorts -> ShowS
Show)
data FreeEnv' a b c = FreeEnv
{ :: !b
, forall a b c. FreeEnv' a b c -> FlexRig' a
feFlexRig :: !(FlexRig' a)
, forall a b c. FreeEnv' a b c -> Modality
feModality :: !Modality
, forall a b c. FreeEnv' a b c -> Maybe Variable -> c
feSingleton :: Maybe Variable -> c
}
type Variable = Int
type SingleVar c = Variable -> c
type FreeEnv c = FreeEnv' MetaSet IgnoreSorts c
feIgnoreSorts :: FreeEnv' a IgnoreSorts c -> IgnoreSorts
feIgnoreSorts :: forall a c. FreeEnv' a IgnoreSorts c -> IgnoreSorts
feIgnoreSorts = forall a b c. FreeEnv' a b c -> b
feExtra
instance LensFlexRig a (FreeEnv' a b c) where
lensFlexRig :: Lens' (FlexRig' a) (FreeEnv' a b c)
lensFlexRig FlexRig' a -> f (FlexRig' a)
f FreeEnv' a b c
e = FlexRig' a -> f (FlexRig' a)
f (forall a b c. FreeEnv' a b c -> FlexRig' a
feFlexRig FreeEnv' a b c
e) forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ FlexRig' a
fr -> FreeEnv' a b c
e { feFlexRig :: FlexRig' a
feFlexRig = FlexRig' a
fr }
instance LensModality (FreeEnv' a b c) where
getModality :: FreeEnv' a b c -> Modality
getModality = forall a b c. FreeEnv' a b c -> Modality
feModality
mapModality :: (Modality -> Modality) -> FreeEnv' a b c -> FreeEnv' a b c
mapModality Modality -> Modality
f FreeEnv' a b c
e = FreeEnv' a b c
e { feModality :: Modality
feModality = Modality -> Modality
f (forall a b c. FreeEnv' a b c -> Modality
feModality FreeEnv' a b c
e) }
instance LensRelevance (FreeEnv' a b c) where
instance LensQuantity (FreeEnv' a b c) where
initFreeEnv :: Monoid c => b -> SingleVar c -> FreeEnv' a b c
initFreeEnv :: forall c b a. Monoid c => b -> SingleVar c -> FreeEnv' a b c
initFreeEnv b
e SingleVar c
sing = FreeEnv
{ feExtra :: b
feExtra = b
e
, feFlexRig :: FlexRig' a
feFlexRig = forall a. FlexRig' a
Unguarded
, feModality :: Modality
feModality = Modality
unitModality
, feSingleton :: Maybe Variable -> c
feSingleton = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty SingleVar c
sing
}
type FreeT a b m c = ReaderT (FreeEnv' a b c) m c
type FreeM a c = Reader (FreeEnv' a IgnoreSorts c) c
runFreeM :: IsVarSet a c => SingleVar c -> IgnoreSorts -> FreeM a c -> c
runFreeM :: forall a c.
IsVarSet a c =>
SingleVar c -> IgnoreSorts -> FreeM a c -> c
runFreeM SingleVar c
single IgnoreSorts
i FreeM a c
m = forall r a. Reader r a -> r -> a
runReader FreeM a c
m forall a b. (a -> b) -> a -> b
$ forall c b a. Monoid c => b -> SingleVar c -> FreeEnv' a b c
initFreeEnv IgnoreSorts
i SingleVar c
single
instance (Functor m, Applicative m, Monad m, Semigroup c, Monoid c) => Monoid (FreeT a b m c) where
mempty :: FreeT a b m c
mempty = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Monoid a => a
mempty
mappend :: FreeT a b m c -> FreeT a b m c -> FreeT a b m c
mappend = forall a. Semigroup a => a -> a -> a
(<>)
mconcat :: [FreeT a b m c] -> FreeT a b m c
mconcat = forall a. Monoid a => [a] -> a
mconcat forall (m :: * -> *) b c a.
Functor m =>
(b -> c) -> (a -> m b) -> a -> m c
<.> forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
variable :: (Monad m, IsVarSet a c) => Int -> FreeT a b m c
variable :: forall (m :: * -> *) a c b.
(Monad m, IsVarSet a c) =>
Variable -> FreeT a b m c
variable Variable
n = do
FlexRig' a
o <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks forall a b c. FreeEnv' a b c -> FlexRig' a
feFlexRig
Modality
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks forall a b c. FreeEnv' a b c -> Modality
feModality
Maybe Variable -> c
s <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks forall a b c. FreeEnv' a b c -> Maybe Variable -> c
feSingleton
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a c. IsVarSet a c => VarOcc' a -> c -> c
withVarOcc (forall a. FlexRig' a -> Modality -> VarOcc' a
VarOcc FlexRig' a
o Modality
r) (Maybe Variable -> c
s forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just Variable
n)
subVar :: Int -> Maybe Variable -> Maybe Variable
subVar :: Variable -> Maybe Variable -> Maybe Variable
subVar Variable
n Maybe Variable
x = do
Variable
i <- Maybe Variable
x
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ Variable
i forall a. Ord a => a -> a -> Bool
>= Variable
n
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Variable
i forall a. Num a => a -> a -> a
- Variable
n
underBinder :: MonadReader (FreeEnv' a b c) m => m z -> m z
underBinder :: forall a b c (m :: * -> *) z.
MonadReader (FreeEnv' a b c) m =>
m z -> m z
underBinder = forall a b c (m :: * -> *) z.
MonadReader (FreeEnv' a b c) m =>
Variable -> m z -> m z
underBinder' Variable
1
underBinder' :: MonadReader (FreeEnv' a b c) m => Nat -> m z -> m z
underBinder' :: forall a b c (m :: * -> *) z.
MonadReader (FreeEnv' a b c) m =>
Variable -> m z -> m z
underBinder' Variable
n = forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local forall a b. (a -> b) -> a -> b
$ \ FreeEnv' a b c
e -> FreeEnv' a b c
e { feSingleton :: Maybe Variable -> c
feSingleton = forall a b c. FreeEnv' a b c -> Maybe Variable -> c
feSingleton FreeEnv' a b c
e forall b c a. (b -> c) -> (a -> b) -> a -> c
. Variable -> Maybe Variable -> Maybe Variable
subVar Variable
n }
underModality :: (MonadReader r m, LensModality r, LensModality o) => o -> m z -> m z
underModality :: forall r (m :: * -> *) o z.
(MonadReader r m, LensModality r, LensModality o) =>
o -> m z -> m z
underModality = forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LensModality a => (Modality -> Modality) -> a -> a
mapModality forall b c a. (b -> c) -> (a -> b) -> a -> c
. Modality -> Modality -> Modality
composeModality forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LensModality a => a -> Modality
getModality
underRelevance :: (MonadReader r m, LensRelevance r, LensRelevance o) => o -> m z -> m z
underRelevance :: forall r (m :: * -> *) o z.
(MonadReader r m, LensRelevance r, LensRelevance o) =>
o -> m z -> m z
underRelevance = forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LensRelevance a => (Relevance -> Relevance) -> a -> a
mapRelevance forall b c a. (b -> c) -> (a -> b) -> a -> c
. Relevance -> Relevance -> Relevance
composeRelevance forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LensRelevance a => a -> Relevance
getRelevance
underFlexRig :: (MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) => o -> m z -> m z
underFlexRig :: forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig = forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i o. Lens' i o -> LensMap i o
over forall a o. LensFlexRig a o => Lens' (FlexRig' a) o
lensFlexRig forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Semigroup a => FlexRig' a -> FlexRig' a -> FlexRig' a
composeFlexRig forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall o (m :: * -> *) i. MonadReader o m => Lens' i o -> m i
view forall a o. LensFlexRig a o => Lens' (FlexRig' a) o
lensFlexRig
underConstructor :: (MonadReader r m, LensFlexRig a r, Semigroup a) => ConHead -> Elims -> m z -> m z
underConstructor :: forall r (m :: * -> *) a z.
(MonadReader r m, LensFlexRig a r, Semigroup a) =>
ConHead -> Elims -> m z -> m z
underConstructor (ConHead QName
_c DataOrRecord
_d Induction
i [Arg QName]
fs) Elims
es =
case Induction
i of
Induction
CoInductive -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig forall a. FlexRig' a
WeaklyRigid
Induction
Inductive | forall a. Sized a => a -> Variable
size Elims
es forall a. Eq a => a -> a -> Bool
== forall a. Sized a => a -> Variable
size [Arg QName]
fs -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig forall a. FlexRig' a
StronglyRigid
| Bool
otherwise -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig forall a. FlexRig' a
WeaklyRigid
class Free t where
freeVars' :: IsVarSet a c => t -> FreeM a c
default freeVars' :: (t ~ f b, Foldable f, Free b) => IsVarSet a c => t -> FreeM a c
freeVars' = forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars'
instance Free Term where
freeVars' :: forall a c. IsVarSet a c => Term -> FreeM a c
freeVars' Term
t = case Term -> Term
unSpine Term
t of
Var Variable
n Elims
ts -> forall (m :: * -> *) a c b.
(Monad m, IsVarSet a c) =>
Variable -> FreeT a b m c
variable Variable
n forall a. Monoid a => a -> a -> a
`mappend` do forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig forall a. FlexRig' a
WeaklyRigid forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Elims
ts
Lam ArgInfo
_ Abs Term
t -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig forall a. FlexRig' a
WeaklyRigid forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Abs Term
t
Lit Literal
_ -> forall a. Monoid a => a
mempty
Def QName
_ Elims
ts -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig forall a. FlexRig' a
WeaklyRigid forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Elims
ts
Con ConHead
c ConInfo
_ Elims
ts -> forall r (m :: * -> *) a z.
(MonadReader r m, LensFlexRig a r, Semigroup a) =>
ConHead -> Elims -> m z -> m z
underConstructor ConHead
c Elims
ts forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Elims
ts
Pi Dom Type
a Abs Type
b -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Dom Type
a,Abs Type
b)
Sort Sort
s -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Sort
s
Level Level
l -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Level
l
MetaV MetaId
m Elims
ts -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig (forall a. a -> FlexRig' a
Flexible forall a b. (a -> b) -> a -> b
$ forall el coll. Singleton el coll => el -> coll
singleton MetaId
m) forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Elims
ts
DontCare Term
mt -> forall r (m :: * -> *) o z.
(MonadReader r m, LensModality r, LensModality o) =>
o -> m z -> m z
underModality (Relevance -> Quantity -> Cohesion -> Modality
Modality Relevance
Irrelevant Quantity
unitQuantity Cohesion
unitCohesion) forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Term
mt
Dummy{} -> forall a. Monoid a => a
mempty
instance Free t => Free (Type' t) where
freeVars' :: forall a c. IsVarSet a c => Type' t -> FreeM a c
freeVars' (El Sort
s t
t) =
forall (m :: * -> *) a. Monad m => m Bool -> m a -> m a -> m a
ifM (forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((IgnoreSorts
IgnoreNot forall a. Eq a => a -> a -> Bool
==) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a c. FreeEnv' a IgnoreSorts c -> IgnoreSorts
feIgnoreSorts))
(forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Sort
s, t
t))
(forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' t
t)
instance Free Sort where
freeVars' :: forall a c. IsVarSet a c => Sort -> FreeM a c
freeVars' Sort
s =
forall (m :: * -> *) a. Monad m => m Bool -> m a -> m a -> m a
ifM (forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((IgnoreSorts
IgnoreAll forall a. Eq a => a -> a -> Bool
==) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a c. FreeEnv' a IgnoreSorts c -> IgnoreSorts
feIgnoreSorts)) forall a. Monoid a => a
mempty forall a b. (a -> b) -> a -> b
$
case Sort
s of
Type Level
a -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Level
a
Prop Level
a -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Level
a
Inf IsFibrant
_ Integer
_ -> forall a. Monoid a => a
mempty
SSet Level
a -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Level
a
Sort
SizeUniv -> forall a. Monoid a => a
mempty
Sort
LockUniv -> forall a. Monoid a => a
mempty
Sort
IntervalUniv -> forall a. Monoid a => a
mempty
PiSort Dom' Term Term
a Sort
s1 Abs Sort
s2 -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig (forall a. a -> FlexRig' a
Flexible forall a. Monoid a => a
mempty) (forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' forall a b. (a -> b) -> a -> b
$ forall t e. Dom' t e -> e
unDom Dom' Term Term
a) forall a. Monoid a => a -> a -> a
`mappend`
forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig forall a. FlexRig' a
WeaklyRigid (forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Sort
s1, Abs Sort
s2))
FunSort Sort
s1 Sort
s2 -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Sort
s1 forall a. Monoid a => a -> a -> a
`mappend` forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Sort
s2
UnivSort Sort
s -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig forall a. FlexRig' a
WeaklyRigid forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Sort
s
MetaS MetaId
x Elims
es -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig (forall a. a -> FlexRig' a
Flexible forall a b. (a -> b) -> a -> b
$ forall el coll. Singleton el coll => el -> coll
singleton MetaId
x) forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Elims
es
DefS QName
_ Elims
es -> forall r (m :: * -> *) a o z.
(MonadReader r m, LensFlexRig a r, Semigroup a, LensFlexRig a o) =>
o -> m z -> m z
underFlexRig forall a. FlexRig' a
WeaklyRigid forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Elims
es
DummyS{} -> forall a. Monoid a => a
mempty
instance Free Level where
freeVars' :: forall a c. IsVarSet a c => Level -> FreeM a c
freeVars' (Max Integer
_ [PlusLevel' Term]
as) = forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' [PlusLevel' Term]
as
instance Free t => Free (PlusLevel' t) where
freeVars' :: forall a c. IsVarSet a c => PlusLevel' t -> FreeM a c
freeVars' (Plus Integer
_ t
l) = forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' t
l
instance Free t => Free [t] where
instance Free t => Free (Maybe t) where
instance Free t => Free (WithHiding t) where
instance Free t => Free (Named nm t)
instance (Free t, Free u) => Free (t, u) where
freeVars' :: forall a c. IsVarSet a c => (t, u) -> FreeM a c
freeVars' (t
t, u
u) = forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' t
t forall a. Monoid a => a -> a -> a
`mappend` forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' u
u
instance (Free t, Free u, Free v) => Free (t, u, v) where
freeVars' :: forall a c. IsVarSet a c => (t, u, v) -> FreeM a c
freeVars' (t
t, u
u, v
v) = forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' t
t forall a. Monoid a => a -> a -> a
`mappend` forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' u
u forall a. Monoid a => a -> a -> a
`mappend` forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' v
v
instance Free t => Free (Elim' t) where
freeVars' :: forall a c. IsVarSet a c => Elim' t -> FreeM a c
freeVars' (Apply Arg t
t) = forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Arg t
t
freeVars' (Proj{} ) = forall a. Monoid a => a
mempty
freeVars' (IApply t
x t
y t
r) = forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (t
x,t
y,t
r)
instance Free t => Free (Arg t) where
freeVars' :: forall a c. IsVarSet a c => Arg t -> FreeM a c
freeVars' Arg t
t = forall r (m :: * -> *) o z.
(MonadReader r m, LensModality r, LensModality o) =>
o -> m z -> m z
underModality (forall a. LensModality a => a -> Modality
getModality Arg t
t) forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' forall a b. (a -> b) -> a -> b
$ forall e. Arg e -> e
unArg Arg t
t
instance Free t => Free (Dom t) where
freeVars' :: forall a c. IsVarSet a c => Dom t -> FreeM a c
freeVars' Dom t
d = forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (forall t e. Dom' t e -> Maybe t
domTactic Dom t
d, forall t e. Dom' t e -> e
unDom Dom t
d)
instance Free t => Free (Abs t) where
freeVars' :: forall a c. IsVarSet a c => Abs t -> FreeM a c
freeVars' (Abs String
_ t
b) = forall a b c (m :: * -> *) z.
MonadReader (FreeEnv' a b c) m =>
m z -> m z
underBinder forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' t
b
freeVars' (NoAbs String
_ t
b) = forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' t
b
instance Free t => Free (Tele t) where
freeVars' :: forall a c. IsVarSet a c => Tele t -> FreeM a c
freeVars' Tele t
EmptyTel = forall a. Monoid a => a
mempty
freeVars' (ExtendTel t
t Abs (Tele t)
tel) = forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (t
t, Abs (Tele t)
tel)
instance Free Clause where
freeVars' :: forall a c. IsVarSet a c => Clause -> FreeM a c
freeVars' Clause
cl = forall a b c (m :: * -> *) z.
MonadReader (FreeEnv' a b c) m =>
Variable -> m z -> m z
underBinder' (forall a. Sized a => a -> Variable
size forall a b. (a -> b) -> a -> b
$ Clause -> Telescope
clauseTel Clause
cl) forall a b. (a -> b) -> a -> b
$ forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' forall a b. (a -> b) -> a -> b
$ Clause -> Maybe Term
clauseBody Clause
cl
instance Free EqualityView where
freeVars' :: forall a c. IsVarSet a c => EqualityView -> FreeM a c
freeVars' = \case
OtherType Type
t -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Type
t
IdiomType Type
t -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Type
t
EqualityType Sort
s QName
_eq Args
l Arg Term
t Arg Term
a Arg Term
b -> forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Sort
s, Args
l, [Arg Term
t, Arg Term
a, Arg Term
b])