{-# LANGUAGE CPP                        #-}
{-# LANGUAGE BangPatterns               #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilies               #-} -- for type equality ~

module Agda.TypeChecking.Monad.Base where

import Prelude hiding (null)

import qualified Control.Concurrent as C
import qualified Control.Exception as E

import qualified Control.Monad.Fail as Fail

import Control.Monad.State
import Control.Monad.Reader
import Control.Monad.Writer hiding ((<>))
import Control.Monad.Trans.Identity
import Control.Monad.Trans.Maybe
import Control.Applicative hiding (empty)

import Data.Array (Ix)
import Data.Function
import Data.Int
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import qualified Data.List as List
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NonEmpty
import Data.Maybe
import Data.Map (Map)
import qualified Data.Map as Map -- hiding (singleton, null, empty)
import Data.Monoid ( Monoid, mempty, mappend )
import Data.Sequence (Seq)
import Data.Set (Set)
import qualified Data.Set as Set -- hiding (singleton, null, empty)
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HMap
import Data.Semigroup ( Semigroup, (<>)) --, Any(..) )
import Data.Data (Data, toConstr)
import Data.Foldable (Foldable)
import Data.String
import Data.Text.Lazy (Text)
import qualified Data.Text.Lazy as T

import Data.IORef

import qualified System.Console.Haskeline as Haskeline

import Agda.Benchmarking (Benchmark, Phase)

import Agda.Syntax.Concrete (TopLevelModuleName)
import Agda.Syntax.Common
import qualified Agda.Syntax.Concrete as C
import Agda.Syntax.Concrete.Definitions
  (NiceDeclaration, DeclarationWarning, declarationWarningName)
import qualified Agda.Syntax.Abstract as A
import Agda.Syntax.Abstract (AllNames)
import Agda.Syntax.Internal as I
import Agda.Syntax.Internal.Generic (TermLike(..))
import Agda.Syntax.Parser (ParseWarning)
import Agda.Syntax.Parser.Monad (parseWarningName)
import Agda.Syntax.Treeless (Compiled)
import Agda.Syntax.Notation
import Agda.Syntax.Position
import Agda.Syntax.Scope.Base
import qualified Agda.Syntax.Info as Info

import Agda.TypeChecking.CompiledClause
import Agda.TypeChecking.Coverage.SplitTree
import Agda.TypeChecking.Positivity.Occurrence
import Agda.TypeChecking.Free.Lazy (Free(freeVars'), underBinder', underBinder)

-- Args, defined in Agda.Syntax.Treeless and exported from Agda.Compiler.Backend
-- conflicts with Args, defined in Agda.Syntax.Internal and also imported here.
-- This only matters when interpreted in ghci, which sees all of the module's
-- exported symbols, not just the ones defined in the `.hs-boot`. See the
-- comment in ../../Compiler/Backend.hs-boot
import {-# SOURCE #-} Agda.Compiler.Backend hiding (Args)

import Agda.Interaction.Options
import Agda.Interaction.Options.Warnings
import {-# SOURCE #-} Agda.Interaction.Response
  (InteractionOutputCallback, defaultInteractionOutputCallback)
import Agda.Interaction.Highlighting.Precise
  (CompressedFile, HighlightingInfo)
import Agda.Interaction.Library

import Agda.Utils.Benchmark (MonadBench(..))
import Agda.Utils.Except
  ( Error(strMsg)
  , ExceptT
  , MonadError(catchError, throwError)
  , mapExceptT
  )
import Agda.Utils.FileName
import Agda.Utils.Functor
import Agda.Utils.Hash
import Agda.Utils.Lens
import Agda.Utils.List
import Agda.Utils.ListT
import qualified Agda.Utils.Maybe.Strict as Strict
import Agda.Utils.Monad
import Agda.Utils.Null
import Agda.Utils.Permutation
import Agda.Utils.Pretty
import Agda.Utils.Singleton
import Agda.Utils.SmallSet (SmallSet)
import qualified Agda.Utils.SmallSet as SmallSet
import Agda.Utils.Update
import Agda.Utils.WithDefault ( collapseDefault )

import Agda.Utils.Impossible

---------------------------------------------------------------------------
-- * Type checking state
---------------------------------------------------------------------------

data TCState = TCSt
  { TCState -> PreScopeState
stPreScopeState   :: !PreScopeState
    -- ^ The state which is frozen after scope checking.
  , TCState -> PostScopeState
stPostScopeState  :: !PostScopeState
    -- ^ The state which is modified after scope checking.
  , TCState -> PersistentTCState
stPersistentState :: !PersistentTCState
    -- ^ State which is forever, like a diamond.
  }

class Monad m => ReadTCState m where
  getTCState :: m TCState
  locallyTCState :: Lens' a TCState -> (a -> a) -> m b -> m b

  withTCState :: (TCState -> TCState) -> m a -> m a
  withTCState = Lens' TCState TCState -> (TCState -> TCState) -> m a -> m a
forall (m :: * -> *) a b.
ReadTCState m =>
Lens' a TCState -> (a -> a) -> m b -> m b
locallyTCState forall a. a -> a
Lens' TCState TCState
id

instance ReadTCState m => ReadTCState (MaybeT m) where
  getTCState :: MaybeT m TCState
getTCState = m TCState -> MaybeT m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState
  locallyTCState :: Lens' a TCState -> (a -> a) -> MaybeT m b -> MaybeT m b
locallyTCState Lens' a TCState
l = (m (Maybe b) -> m (Maybe b)) -> MaybeT m b -> MaybeT m b
forall (m :: * -> *) a (n :: * -> *) b.
(m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b
mapMaybeT ((m (Maybe b) -> m (Maybe b)) -> MaybeT m b -> MaybeT m b)
-> ((a -> a) -> m (Maybe b) -> m (Maybe b))
-> (a -> a)
-> MaybeT m b
-> MaybeT m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' a TCState -> (a -> a) -> m (Maybe b) -> m (Maybe b)
forall (m :: * -> *) a b.
ReadTCState m =>
Lens' a TCState -> (a -> a) -> m b -> m b
locallyTCState Lens' a TCState
l

instance ReadTCState m => ReadTCState (ListT m) where
  getTCState :: ListT m TCState
getTCState = m TCState -> ListT m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState
  locallyTCState :: Lens' a TCState -> (a -> a) -> ListT m b -> ListT m b
locallyTCState Lens' a TCState
l a -> a
f = m (Maybe (b, ListT m b)) -> ListT m b
forall (m :: * -> *) a. m (Maybe (a, ListT m a)) -> ListT m a
ListT (m (Maybe (b, ListT m b)) -> ListT m b)
-> (ListT m b -> m (Maybe (b, ListT m b)))
-> ListT m b
-> ListT m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' a TCState
-> (a -> a) -> m (Maybe (b, ListT m b)) -> m (Maybe (b, ListT m b))
forall (m :: * -> *) a b.
ReadTCState m =>
Lens' a TCState -> (a -> a) -> m b -> m b
locallyTCState Lens' a TCState
l a -> a
f (m (Maybe (b, ListT m b)) -> m (Maybe (b, ListT m b)))
-> (ListT m b -> m (Maybe (b, ListT m b)))
-> ListT m b
-> m (Maybe (b, ListT m b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ListT m b -> m (Maybe (b, ListT m b))
forall (m :: * -> *) a. ListT m a -> m (Maybe (a, ListT m a))
runListT

instance ReadTCState m => ReadTCState (ExceptT err m) where
  getTCState :: ExceptT err m TCState
getTCState = m TCState -> ExceptT err m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState
  locallyTCState :: Lens' a TCState -> (a -> a) -> ExceptT err m b -> ExceptT err m b
locallyTCState Lens' a TCState
l = (m (Either err b) -> m (Either err b))
-> ExceptT err m b -> ExceptT err m b
forall (m :: * -> *) e a (n :: * -> *) e' b.
(m (Either e a) -> n (Either e' b))
-> ExceptT e m a -> ExceptT e' n b
mapExceptT ((m (Either err b) -> m (Either err b))
 -> ExceptT err m b -> ExceptT err m b)
-> ((a -> a) -> m (Either err b) -> m (Either err b))
-> (a -> a)
-> ExceptT err m b
-> ExceptT err m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' a TCState -> (a -> a) -> m (Either err b) -> m (Either err b)
forall (m :: * -> *) a b.
ReadTCState m =>
Lens' a TCState -> (a -> a) -> m b -> m b
locallyTCState Lens' a TCState
l

instance ReadTCState m => ReadTCState (ReaderT r m) where
  getTCState :: ReaderT r m TCState
getTCState = m TCState -> ReaderT r m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState
  locallyTCState :: Lens' a TCState -> (a -> a) -> ReaderT r m b -> ReaderT r m b
locallyTCState Lens' a TCState
l = (m b -> m b) -> ReaderT r m b -> ReaderT r m b
forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT ((m b -> m b) -> ReaderT r m b -> ReaderT r m b)
-> ((a -> a) -> m b -> m b)
-> (a -> a)
-> ReaderT r m b
-> ReaderT r m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' a TCState -> (a -> a) -> m b -> m b
forall (m :: * -> *) a b.
ReadTCState m =>
Lens' a TCState -> (a -> a) -> m b -> m b
locallyTCState Lens' a TCState
l

instance (Monoid w, ReadTCState m) => ReadTCState (WriterT w m) where
  getTCState :: WriterT w m TCState
getTCState = m TCState -> WriterT w m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState
  locallyTCState :: Lens' a TCState -> (a -> a) -> WriterT w m b -> WriterT w m b
locallyTCState Lens' a TCState
l = (m (b, w) -> m (b, w)) -> WriterT w m b -> WriterT w m b
forall (m :: * -> *) a w (n :: * -> *) b w'.
(m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
mapWriterT ((m (b, w) -> m (b, w)) -> WriterT w m b -> WriterT w m b)
-> ((a -> a) -> m (b, w) -> m (b, w))
-> (a -> a)
-> WriterT w m b
-> WriterT w m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' a TCState -> (a -> a) -> m (b, w) -> m (b, w)
forall (m :: * -> *) a b.
ReadTCState m =>
Lens' a TCState -> (a -> a) -> m b -> m b
locallyTCState Lens' a TCState
l

instance ReadTCState m => ReadTCState (StateT s m) where
  getTCState :: StateT s m TCState
getTCState = m TCState -> StateT s m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState
  locallyTCState :: Lens' a TCState -> (a -> a) -> StateT s m b -> StateT s m b
locallyTCState Lens' a TCState
l = (m (b, s) -> m (b, s)) -> StateT s m b -> StateT s m b
forall (m :: * -> *) a s (n :: * -> *) b.
(m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
mapStateT ((m (b, s) -> m (b, s)) -> StateT s m b -> StateT s m b)
-> ((a -> a) -> m (b, s) -> m (b, s))
-> (a -> a)
-> StateT s m b
-> StateT s m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' a TCState -> (a -> a) -> m (b, s) -> m (b, s)
forall (m :: * -> *) a b.
ReadTCState m =>
Lens' a TCState -> (a -> a) -> m b -> m b
locallyTCState Lens' a TCState
l

instance Show TCState where
  show :: TCState -> String
show TCState
_ = String
"TCSt{}"

data PreScopeState = PreScopeState
  { PreScopeState -> CompressedFile
stPreTokens             :: !CompressedFile -- from lexer
    -- ^ Highlighting info for tokens (but not those tokens for
    -- which highlighting exists in 'stSyntaxInfo').
  , PreScopeState -> Signature
stPreImports            :: !Signature  -- XX populated by scope checker
    -- ^ Imported declared identifiers.
    --   Those most not be serialized!
  , PreScopeState -> Set ModuleName
stPreImportedModules    :: !(Set ModuleName)  -- imports logic
  , PreScopeState -> ModuleToSource
stPreModuleToSource     :: !ModuleToSource   -- imports
  , PreScopeState -> VisitedModules
stPreVisitedModules     :: !VisitedModules   -- imports
  , PreScopeState -> ScopeInfo
stPreScope              :: !ScopeInfo
    -- generated by scope checker, current file:
    -- which modules you have, public definitions, current file, maps concrete names to abstract names.
  , PreScopeState -> PatternSynDefns
stPrePatternSyns        :: !A.PatternSynDefns
    -- ^ Pattern synonyms of the current file.  Serialized.
  , PreScopeState -> PatternSynDefns
stPrePatternSynImports  :: !A.PatternSynDefns
    -- ^ Imported pattern synonyms.  Must not be serialized!
  , PreScopeState -> Maybe (Set QName)
stPreGeneralizedVars    :: !(Strict.Maybe (Set QName))
    -- ^ Collected generalizable variables; used during scope checking of terms
  , PreScopeState -> PragmaOptions
stPrePragmaOptions      :: !PragmaOptions
    -- ^ Options applying to the current file. @OPTIONS@
    -- pragmas only affect this field.
  , PreScopeState -> BuiltinThings PrimFun
stPreImportedBuiltins   :: !(BuiltinThings PrimFun)
  , PreScopeState -> DisplayForms
stPreImportedDisplayForms :: !DisplayForms
    -- ^ Display forms added by someone else to imported identifiers
  , PreScopeState -> InstanceTable
stPreImportedInstanceDefs :: !InstanceTable
  , PreScopeState -> Map String [ForeignCode]
stPreForeignCode        :: !(Map BackendName [ForeignCode])
    -- ^ @{-\# FOREIGN \#-}@ code that should be included in the compiled output.
    -- Does not include code for imported modules.
  , PreScopeState -> InteractionId
stPreFreshInteractionId :: !InteractionId
  , PreScopeState -> Map QName String
stPreImportedUserWarnings :: !(Map A.QName String)
    -- ^ Imported @UserWarning@s, not to be stored in the @Interface@
  , PreScopeState -> Map QName String
stPreLocalUserWarnings    :: !(Map A.QName String)
    -- ^ Locally defined @UserWarning@s, to be stored in the @Interface@
  , PreScopeState -> Maybe String
stPreWarningOnImport      :: !(Strict.Maybe String)
    -- ^ Whether the current module should raise a warning when opened
  , PreScopeState -> Set QName
stPreImportedPartialDefs :: !(Set QName)
    -- ^ Imported partial definitions, not to be stored in the @Interface@
  }

type DisambiguatedNames = IntMap A.QName

type ConcreteNames = Map Name [C.Name]

data PostScopeState = PostScopeState
  { PostScopeState -> CompressedFile
stPostSyntaxInfo          :: !CompressedFile
    -- ^ Highlighting info.
  , PostScopeState -> DisambiguatedNames
stPostDisambiguatedNames  :: !DisambiguatedNames
    -- ^ Disambiguation carried out by the type checker.
    --   Maps position of first name character to disambiguated @'A.QName'@
    --   for each @'A.AmbiguousQName'@ already passed by the type checker.
  , PostScopeState -> MetaStore
stPostMetaStore           :: !MetaStore
  , PostScopeState -> InteractionPoints
stPostInteractionPoints   :: !InteractionPoints -- scope checker first
  , PostScopeState -> Constraints
stPostAwakeConstraints    :: !Constraints
  , PostScopeState -> Constraints
stPostSleepingConstraints :: !Constraints
  , PostScopeState -> Bool
stPostDirty               :: !Bool -- local
    -- ^ Dirty when a constraint is added, used to prevent pointer update.
    -- Currently unused.
  , PostScopeState -> Set QName
stPostOccursCheckDefs     :: !(Set QName) -- local
    -- ^ Definitions to be considered during occurs check.
    --   Initialized to the current mutual block before the check.
    --   During occurs check, we remove definitions from this set
    --   as soon we have checked them.
  , PostScopeState -> Signature
stPostSignature           :: !Signature
    -- ^ Declared identifiers of the current file.
    --   These will be serialized after successful type checking.
  , PostScopeState -> Map ModuleName CheckpointId
stPostModuleCheckpoints   :: !(Map ModuleName CheckpointId)
    -- ^ For each module remember the checkpoint corresponding to the orignal
    --   context of the module parameters.
  , PostScopeState -> DisplayForms
stPostImportsDisplayForms :: !DisplayForms
    -- ^ Display forms we add for imported identifiers
  , PostScopeState -> Maybe ModuleName
stPostCurrentModule       :: !(Strict.Maybe ModuleName)
    -- ^ The current module is available after it has been type
    -- checked.
  , PostScopeState -> TempInstanceTable
stPostInstanceDefs        :: !TempInstanceTable
  , PostScopeState -> ConcreteNames
stPostConcreteNames       :: !ConcreteNames
    -- ^ Map keeping track of concrete names assigned to each abstract name
    --   (can be more than one name in case the first one is shadowed)
  , PostScopeState -> Map String [String]
stPostUsedNames           :: !(Map RawName [RawName])
    -- ^ Map keeping track for each name root (= name w/o numeric
    -- suffixes) what names with the same root have been used during a
    -- TC computation. This information is used to build the
    -- @ShadowingNames@ map.
  , PostScopeState -> Map Name [String]
stPostShadowingNames      :: !(Map Name [RawName])
    -- ^ Map keeping track for each (abstract) name the list of all
    -- (raw) names that it could maybe be shadowed by.
  , PostScopeState -> Statistics
stPostStatistics          :: !Statistics
    -- ^ Counters to collect various statistics about meta variables etc.
    --   Only for current file.
  , PostScopeState -> [TCWarning]
stPostTCWarnings          :: ![TCWarning]
  , PostScopeState -> Map MutualId MutualBlock
stPostMutualBlocks        :: !(Map MutualId MutualBlock)
  , PostScopeState -> BuiltinThings PrimFun
stPostLocalBuiltins       :: !(BuiltinThings PrimFun)
  , PostScopeState -> MetaId
stPostFreshMetaId         :: !MetaId
  , PostScopeState -> MutualId
stPostFreshMutualId       :: !MutualId
  , PostScopeState -> ProblemId
stPostFreshProblemId      :: !ProblemId
  , PostScopeState -> CheckpointId
stPostFreshCheckpointId   :: !CheckpointId
  , PostScopeState -> Int
stPostFreshInt            :: !Int
  , PostScopeState -> NameId
stPostFreshNameId         :: !NameId
  , PostScopeState -> Bool
stPostAreWeCaching        :: !Bool
  , PostScopeState -> Bool
stPostPostponeInstanceSearch :: !Bool
  , PostScopeState -> Bool
stPostConsideringInstance :: !Bool
  , PostScopeState -> Bool
stPostInstantiateBlocking :: !Bool
    -- ^ Should we instantiate away blocking metas?
    --   This can produce ill-typed terms but they are often more readable. See issue #3606.
    --   Best set to True only for calls to pretty*/reify to limit unwanted reductions.
  , PostScopeState -> Set QName
stPostLocalPartialDefs    :: !(Set QName)
    -- ^ Local partial definitions, to be stored in the @Interface@
  }

-- | A mutual block of names in the signature.
data MutualBlock = MutualBlock
  { MutualBlock -> MutualInfo
mutualInfo  :: Info.MutualInfo
    -- ^ The original info of the mutual block.
  , MutualBlock -> Set QName
mutualNames :: Set QName
  } deriving (Int -> MutualBlock -> ShowS
[MutualBlock] -> ShowS
MutualBlock -> String
(Int -> MutualBlock -> ShowS)
-> (MutualBlock -> String)
-> ([MutualBlock] -> ShowS)
-> Show MutualBlock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MutualBlock] -> ShowS
$cshowList :: [MutualBlock] -> ShowS
show :: MutualBlock -> String
$cshow :: MutualBlock -> String
showsPrec :: Int -> MutualBlock -> ShowS
$cshowsPrec :: Int -> MutualBlock -> ShowS
Show, MutualBlock -> MutualBlock -> Bool
(MutualBlock -> MutualBlock -> Bool)
-> (MutualBlock -> MutualBlock -> Bool) -> Eq MutualBlock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MutualBlock -> MutualBlock -> Bool
$c/= :: MutualBlock -> MutualBlock -> Bool
== :: MutualBlock -> MutualBlock -> Bool
$c== :: MutualBlock -> MutualBlock -> Bool
Eq)

instance Null MutualBlock where
  empty :: MutualBlock
empty = MutualInfo -> Set QName -> MutualBlock
MutualBlock MutualInfo
forall a. Null a => a
empty Set QName
forall a. Null a => a
empty

-- | A part of the state which is not reverted when an error is thrown
-- or the state is reset.
data PersistentTCState = PersistentTCSt
  { PersistentTCState -> DecodedModules
stDecodedModules    :: DecodedModules
  , PersistentTCState -> CommandLineOptions
stPersistentOptions :: CommandLineOptions
  , PersistentTCState -> InteractionOutputCallback
stInteractionOutputCallback  :: InteractionOutputCallback
    -- ^ Callback function to call when there is a response
    --   to give to the interactive frontend.
    --   See the documentation of 'InteractionOutputCallback'.
  , PersistentTCState -> Benchmark
stBenchmark         :: !Benchmark
    -- ^ Structure to track how much CPU time was spent on which Agda phase.
    --   Needs to be a strict field to avoid space leaks!
  , PersistentTCState -> Statistics
stAccumStatistics   :: !Statistics
    -- ^ Should be strict field.
  , PersistentTCState -> Maybe LoadedFileCache
stPersistLoadedFileCache :: !(Strict.Maybe LoadedFileCache)
    -- ^ Cached typechecking state from the last loaded file.
    --   Should be @Nothing@ when checking imports.
  , PersistentTCState -> [Backend]
stPersistBackends   :: [Backend]
    -- ^ Current backends with their options
  }

data LoadedFileCache = LoadedFileCache
  { LoadedFileCache -> CachedTypeCheckLog
lfcCached  :: !CachedTypeCheckLog
  , LoadedFileCache -> CachedTypeCheckLog
lfcCurrent :: !CurrentTypeCheckLog
  }

-- | A log of what the type checker does and states after the action is
-- completed.  The cached version is stored first executed action first.
type CachedTypeCheckLog = [(TypeCheckAction, PostScopeState)]

-- | Like 'CachedTypeCheckLog', but storing the log for an ongoing type
-- checking of a module.  Stored in reverse order (last performed action
-- first).
type CurrentTypeCheckLog = [(TypeCheckAction, PostScopeState)]

-- | A complete log for a module will look like this:
--
--   * 'Pragmas'
--
--   * 'EnterSection', entering the main module.
--
--   * 'Decl'/'EnterSection'/'LeaveSection', for declarations and nested
--     modules
--
--   * 'LeaveSection', leaving the main module.
data TypeCheckAction
  = EnterSection !Info.ModuleInfo !ModuleName !A.Telescope
  | LeaveSection !ModuleName
  | Decl !A.Declaration
    -- ^ Never a Section or ScopeDecl
  | Pragmas !PragmaOptions

-- | Empty persistent state.

initPersistentState :: PersistentTCState
initPersistentState :: PersistentTCState
initPersistentState = PersistentTCSt :: DecodedModules
-> CommandLineOptions
-> InteractionOutputCallback
-> Benchmark
-> Statistics
-> Maybe LoadedFileCache
-> [Backend]
-> PersistentTCState
PersistentTCSt
  { stPersistentOptions :: CommandLineOptions
stPersistentOptions         = CommandLineOptions
defaultOptions
  , stDecodedModules :: DecodedModules
stDecodedModules            = DecodedModules
forall k a. Map k a
Map.empty
  , stInteractionOutputCallback :: InteractionOutputCallback
stInteractionOutputCallback = InteractionOutputCallback
defaultInteractionOutputCallback
  , stBenchmark :: Benchmark
stBenchmark                 = Benchmark
forall a. Null a => a
empty
  , stAccumStatistics :: Statistics
stAccumStatistics           = Statistics
forall k a. Map k a
Map.empty
  , stPersistLoadedFileCache :: Maybe LoadedFileCache
stPersistLoadedFileCache    = Maybe LoadedFileCache
forall a. Null a => a
empty
  , stPersistBackends :: [Backend]
stPersistBackends           = []
  }

-- | Empty state of type checker.

initPreScopeState :: PreScopeState
initPreScopeState :: PreScopeState
initPreScopeState = PreScopeState :: CompressedFile
-> Signature
-> Set ModuleName
-> ModuleToSource
-> VisitedModules
-> ScopeInfo
-> PatternSynDefns
-> PatternSynDefns
-> Maybe (Set QName)
-> PragmaOptions
-> BuiltinThings PrimFun
-> DisplayForms
-> InstanceTable
-> Map String [ForeignCode]
-> InteractionId
-> Map QName String
-> Map QName String
-> Maybe String
-> Set QName
-> PreScopeState
PreScopeState
  { stPreTokens :: CompressedFile
stPreTokens               = CompressedFile
forall a. Monoid a => a
mempty
  , stPreImports :: Signature
stPreImports              = Signature
emptySignature
  , stPreImportedModules :: Set ModuleName
stPreImportedModules      = Set ModuleName
forall a. Set a
Set.empty
  , stPreModuleToSource :: ModuleToSource
stPreModuleToSource       = ModuleToSource
forall k a. Map k a
Map.empty
  , stPreVisitedModules :: VisitedModules
stPreVisitedModules       = VisitedModules
forall k a. Map k a
Map.empty
  , stPreScope :: ScopeInfo
stPreScope                = ScopeInfo
emptyScopeInfo
  , stPrePatternSyns :: PatternSynDefns
stPrePatternSyns          = PatternSynDefns
forall k a. Map k a
Map.empty
  , stPrePatternSynImports :: PatternSynDefns
stPrePatternSynImports    = PatternSynDefns
forall k a. Map k a
Map.empty
  , stPreGeneralizedVars :: Maybe (Set QName)
stPreGeneralizedVars      = Maybe (Set QName)
forall a. Monoid a => a
mempty
  , stPrePragmaOptions :: PragmaOptions
stPrePragmaOptions        = PragmaOptions
defaultInteractionOptions
  , stPreImportedBuiltins :: BuiltinThings PrimFun
stPreImportedBuiltins     = BuiltinThings PrimFun
forall k a. Map k a
Map.empty
  , stPreImportedDisplayForms :: DisplayForms
stPreImportedDisplayForms = DisplayForms
forall k v. HashMap k v
HMap.empty
  , stPreImportedInstanceDefs :: InstanceTable
stPreImportedInstanceDefs = InstanceTable
forall k a. Map k a
Map.empty
  , stPreForeignCode :: Map String [ForeignCode]
stPreForeignCode          = Map String [ForeignCode]
forall k a. Map k a
Map.empty
  , stPreFreshInteractionId :: InteractionId
stPreFreshInteractionId   = InteractionId
0
  , stPreImportedUserWarnings :: Map QName String
stPreImportedUserWarnings = Map QName String
forall k a. Map k a
Map.empty
  , stPreLocalUserWarnings :: Map QName String
stPreLocalUserWarnings    = Map QName String
forall k a. Map k a
Map.empty
  , stPreWarningOnImport :: Maybe String
stPreWarningOnImport      = Maybe String
forall a. Null a => a
empty
  , stPreImportedPartialDefs :: Set QName
stPreImportedPartialDefs  = Set QName
forall a. Set a
Set.empty
  }

initPostScopeState :: PostScopeState
initPostScopeState :: PostScopeState
initPostScopeState = PostScopeState :: CompressedFile
-> DisambiguatedNames
-> MetaStore
-> InteractionPoints
-> Constraints
-> Constraints
-> Bool
-> Set QName
-> Signature
-> Map ModuleName CheckpointId
-> DisplayForms
-> Maybe ModuleName
-> TempInstanceTable
-> ConcreteNames
-> Map String [String]
-> Map Name [String]
-> Statistics
-> [TCWarning]
-> Map MutualId MutualBlock
-> BuiltinThings PrimFun
-> MetaId
-> MutualId
-> ProblemId
-> CheckpointId
-> Int
-> NameId
-> Bool
-> Bool
-> Bool
-> Bool
-> Set QName
-> PostScopeState
PostScopeState
  { stPostSyntaxInfo :: CompressedFile
stPostSyntaxInfo           = CompressedFile
forall a. Monoid a => a
mempty
  , stPostDisambiguatedNames :: DisambiguatedNames
stPostDisambiguatedNames   = DisambiguatedNames
forall a. IntMap a
IntMap.empty
  , stPostMetaStore :: MetaStore
stPostMetaStore            = MetaStore
forall a. IntMap a
IntMap.empty
  , stPostInteractionPoints :: InteractionPoints
stPostInteractionPoints    = InteractionPoints
forall k a. Map k a
Map.empty
  , stPostAwakeConstraints :: Constraints
stPostAwakeConstraints     = []
  , stPostSleepingConstraints :: Constraints
stPostSleepingConstraints  = []
  , stPostDirty :: Bool
stPostDirty                = Bool
False
  , stPostOccursCheckDefs :: Set QName
stPostOccursCheckDefs      = Set QName
forall a. Set a
Set.empty
  , stPostSignature :: Signature
stPostSignature            = Signature
emptySignature
  , stPostModuleCheckpoints :: Map ModuleName CheckpointId
stPostModuleCheckpoints    = Map ModuleName CheckpointId
forall k a. Map k a
Map.empty
  , stPostImportsDisplayForms :: DisplayForms
stPostImportsDisplayForms  = DisplayForms
forall k v. HashMap k v
HMap.empty
  , stPostCurrentModule :: Maybe ModuleName
stPostCurrentModule        = Maybe ModuleName
forall a. Null a => a
empty
  , stPostInstanceDefs :: TempInstanceTable
stPostInstanceDefs         = (InstanceTable
forall k a. Map k a
Map.empty , Set QName
forall a. Set a
Set.empty)
  , stPostConcreteNames :: ConcreteNames
stPostConcreteNames        = ConcreteNames
forall k a. Map k a
Map.empty
  , stPostUsedNames :: Map String [String]
stPostUsedNames            = Map String [String]
forall k a. Map k a
Map.empty
  , stPostShadowingNames :: Map Name [String]
stPostShadowingNames       = Map Name [String]
forall k a. Map k a
Map.empty
  , stPostStatistics :: Statistics
stPostStatistics           = Statistics
forall k a. Map k a
Map.empty
  , stPostTCWarnings :: [TCWarning]
stPostTCWarnings           = []
  , stPostMutualBlocks :: Map MutualId MutualBlock
stPostMutualBlocks         = Map MutualId MutualBlock
forall k a. Map k a
Map.empty
  , stPostLocalBuiltins :: BuiltinThings PrimFun
stPostLocalBuiltins        = BuiltinThings PrimFun
forall k a. Map k a
Map.empty
  , stPostFreshMetaId :: MetaId
stPostFreshMetaId          = MetaId
0
  , stPostFreshMutualId :: MutualId
stPostFreshMutualId        = MutualId
0
  , stPostFreshProblemId :: ProblemId
stPostFreshProblemId       = ProblemId
1
  , stPostFreshCheckpointId :: CheckpointId
stPostFreshCheckpointId    = CheckpointId
1
  , stPostFreshInt :: Int
stPostFreshInt             = Int
0
  , stPostFreshNameId :: NameId
stPostFreshNameId           = Word64 -> Word64 -> NameId
NameId Word64
0 Word64
0
  , stPostAreWeCaching :: Bool
stPostAreWeCaching         = Bool
False
  , stPostPostponeInstanceSearch :: Bool
stPostPostponeInstanceSearch = Bool
False
  , stPostConsideringInstance :: Bool
stPostConsideringInstance  = Bool
False
  , stPostInstantiateBlocking :: Bool
stPostInstantiateBlocking  = Bool
False
  , stPostLocalPartialDefs :: Set QName
stPostLocalPartialDefs     = Set QName
forall a. Set a
Set.empty
  }

initState :: TCState
initState :: TCState
initState = TCSt :: PreScopeState -> PostScopeState -> PersistentTCState -> TCState
TCSt
  { stPreScopeState :: PreScopeState
stPreScopeState   = PreScopeState
initPreScopeState
  , stPostScopeState :: PostScopeState
stPostScopeState  = PostScopeState
initPostScopeState
  , stPersistentState :: PersistentTCState
stPersistentState = PersistentTCState
initPersistentState
  }

-- * st-prefixed lenses
------------------------------------------------------------------------

stTokens :: Lens' CompressedFile TCState
stTokens :: (CompressedFile -> f CompressedFile) -> TCState -> f TCState
stTokens CompressedFile -> f CompressedFile
f TCState
s =
  CompressedFile -> f CompressedFile
f (PreScopeState -> CompressedFile
stPreTokens (TCState -> PreScopeState
stPreScopeState TCState
s)) f CompressedFile -> (CompressedFile -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \CompressedFile
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreTokens :: CompressedFile
stPreTokens = CompressedFile
x}}

stImports :: Lens' Signature TCState
stImports :: (Signature -> f Signature) -> TCState -> f TCState
stImports Signature -> f Signature
f TCState
s =
  Signature -> f Signature
f (PreScopeState -> Signature
stPreImports (TCState -> PreScopeState
stPreScopeState TCState
s)) f Signature -> (Signature -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Signature
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreImports :: Signature
stPreImports = Signature
x}}

stImportedModules :: Lens' (Set ModuleName) TCState
stImportedModules :: (Set ModuleName -> f (Set ModuleName)) -> TCState -> f TCState
stImportedModules Set ModuleName -> f (Set ModuleName)
f TCState
s =
  Set ModuleName -> f (Set ModuleName)
f (PreScopeState -> Set ModuleName
stPreImportedModules (TCState -> PreScopeState
stPreScopeState TCState
s)) f (Set ModuleName) -> (Set ModuleName -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Set ModuleName
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreImportedModules :: Set ModuleName
stPreImportedModules = Set ModuleName
x}}

stModuleToSource :: Lens' ModuleToSource TCState
stModuleToSource :: (ModuleToSource -> f ModuleToSource) -> TCState -> f TCState
stModuleToSource ModuleToSource -> f ModuleToSource
f TCState
s =
  ModuleToSource -> f ModuleToSource
f (PreScopeState -> ModuleToSource
stPreModuleToSource (TCState -> PreScopeState
stPreScopeState TCState
s)) f ModuleToSource -> (ModuleToSource -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ModuleToSource
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreModuleToSource :: ModuleToSource
stPreModuleToSource = ModuleToSource
x}}

stVisitedModules :: Lens' VisitedModules TCState
stVisitedModules :: (VisitedModules -> f VisitedModules) -> TCState -> f TCState
stVisitedModules VisitedModules -> f VisitedModules
f TCState
s =
  VisitedModules -> f VisitedModules
f (PreScopeState -> VisitedModules
stPreVisitedModules (TCState -> PreScopeState
stPreScopeState TCState
s)) f VisitedModules -> (VisitedModules -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \VisitedModules
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreVisitedModules :: VisitedModules
stPreVisitedModules = VisitedModules
x}}

stScope :: Lens' ScopeInfo TCState
stScope :: (ScopeInfo -> f ScopeInfo) -> TCState -> f TCState
stScope ScopeInfo -> f ScopeInfo
f TCState
s =
  ScopeInfo -> f ScopeInfo
f (PreScopeState -> ScopeInfo
stPreScope (TCState -> PreScopeState
stPreScopeState TCState
s)) f ScopeInfo -> (ScopeInfo -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ScopeInfo
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreScope :: ScopeInfo
stPreScope = ScopeInfo
x}}

stPatternSyns :: Lens' A.PatternSynDefns TCState
stPatternSyns :: (PatternSynDefns -> f PatternSynDefns) -> TCState -> f TCState
stPatternSyns PatternSynDefns -> f PatternSynDefns
f TCState
s =
  PatternSynDefns -> f PatternSynDefns
f (PreScopeState -> PatternSynDefns
stPrePatternSyns (TCState -> PreScopeState
stPreScopeState TCState
s)) f PatternSynDefns -> (PatternSynDefns -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \PatternSynDefns
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPrePatternSyns :: PatternSynDefns
stPrePatternSyns = PatternSynDefns
x}}

stPatternSynImports :: Lens' A.PatternSynDefns TCState
stPatternSynImports :: (PatternSynDefns -> f PatternSynDefns) -> TCState -> f TCState
stPatternSynImports PatternSynDefns -> f PatternSynDefns
f TCState
s =
  PatternSynDefns -> f PatternSynDefns
f (PreScopeState -> PatternSynDefns
stPrePatternSynImports (TCState -> PreScopeState
stPreScopeState TCState
s)) f PatternSynDefns -> (PatternSynDefns -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \PatternSynDefns
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPrePatternSynImports :: PatternSynDefns
stPrePatternSynImports = PatternSynDefns
x}}

stGeneralizedVars :: Lens' (Maybe (Set QName)) TCState
stGeneralizedVars :: (Maybe (Set QName) -> f (Maybe (Set QName)))
-> TCState -> f TCState
stGeneralizedVars Maybe (Set QName) -> f (Maybe (Set QName))
f TCState
s =
  Maybe (Set QName) -> f (Maybe (Set QName))
f (Maybe (Set QName) -> Maybe (Set QName)
forall a. Maybe a -> Maybe a
Strict.toLazy (Maybe (Set QName) -> Maybe (Set QName))
-> Maybe (Set QName) -> Maybe (Set QName)
forall a b. (a -> b) -> a -> b
$ PreScopeState -> Maybe (Set QName)
stPreGeneralizedVars (TCState -> PreScopeState
stPreScopeState TCState
s)) f (Maybe (Set QName))
-> (Maybe (Set QName) -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Maybe (Set QName)
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreGeneralizedVars :: Maybe (Set QName)
stPreGeneralizedVars = Maybe (Set QName) -> Maybe (Set QName)
forall a. Maybe a -> Maybe a
Strict.toStrict Maybe (Set QName)
x}}

stPragmaOptions :: Lens' PragmaOptions TCState
stPragmaOptions :: (PragmaOptions -> f PragmaOptions) -> TCState -> f TCState
stPragmaOptions PragmaOptions -> f PragmaOptions
f TCState
s =
  PragmaOptions -> f PragmaOptions
f (PreScopeState -> PragmaOptions
stPrePragmaOptions (TCState -> PreScopeState
stPreScopeState TCState
s)) f PragmaOptions -> (PragmaOptions -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \PragmaOptions
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPrePragmaOptions :: PragmaOptions
stPrePragmaOptions = PragmaOptions
x}}

stImportedBuiltins :: Lens' (BuiltinThings PrimFun) TCState
stImportedBuiltins :: (BuiltinThings PrimFun -> f (BuiltinThings PrimFun))
-> TCState -> f TCState
stImportedBuiltins BuiltinThings PrimFun -> f (BuiltinThings PrimFun)
f TCState
s =
  BuiltinThings PrimFun -> f (BuiltinThings PrimFun)
f (PreScopeState -> BuiltinThings PrimFun
stPreImportedBuiltins (TCState -> PreScopeState
stPreScopeState TCState
s)) f (BuiltinThings PrimFun)
-> (BuiltinThings PrimFun -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \BuiltinThings PrimFun
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreImportedBuiltins :: BuiltinThings PrimFun
stPreImportedBuiltins = BuiltinThings PrimFun
x}}

stForeignCode :: Lens' (Map BackendName [ForeignCode]) TCState
stForeignCode :: (Map String [ForeignCode] -> f (Map String [ForeignCode]))
-> TCState -> f TCState
stForeignCode Map String [ForeignCode] -> f (Map String [ForeignCode])
f TCState
s =
  Map String [ForeignCode] -> f (Map String [ForeignCode])
f (PreScopeState -> Map String [ForeignCode]
stPreForeignCode (TCState -> PreScopeState
stPreScopeState TCState
s)) f (Map String [ForeignCode])
-> (Map String [ForeignCode] -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Map String [ForeignCode]
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreForeignCode :: Map String [ForeignCode]
stPreForeignCode = Map String [ForeignCode]
x}}

stFreshInteractionId :: Lens' InteractionId TCState
stFreshInteractionId :: (InteractionId -> f InteractionId) -> TCState -> f TCState
stFreshInteractionId InteractionId -> f InteractionId
f TCState
s =
  InteractionId -> f InteractionId
f (PreScopeState -> InteractionId
stPreFreshInteractionId (TCState -> PreScopeState
stPreScopeState TCState
s)) f InteractionId -> (InteractionId -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \InteractionId
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreFreshInteractionId :: InteractionId
stPreFreshInteractionId = InteractionId
x}}

stImportedUserWarnings :: Lens' (Map A.QName String) TCState
stImportedUserWarnings :: (Map QName String -> f (Map QName String)) -> TCState -> f TCState
stImportedUserWarnings Map QName String -> f (Map QName String)
f TCState
s =
  Map QName String -> f (Map QName String)
f (PreScopeState -> Map QName String
stPreImportedUserWarnings (TCState -> PreScopeState
stPreScopeState TCState
s)) f (Map QName String) -> (Map QName String -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ Map QName String
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreImportedUserWarnings :: Map QName String
stPreImportedUserWarnings = Map QName String
x}}

stLocalUserWarnings :: Lens' (Map A.QName String) TCState
stLocalUserWarnings :: (Map QName String -> f (Map QName String)) -> TCState -> f TCState
stLocalUserWarnings Map QName String -> f (Map QName String)
f TCState
s =
  Map QName String -> f (Map QName String)
f (PreScopeState -> Map QName String
stPreLocalUserWarnings (TCState -> PreScopeState
stPreScopeState TCState
s)) f (Map QName String) -> (Map QName String -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ Map QName String
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreLocalUserWarnings :: Map QName String
stPreLocalUserWarnings = Map QName String
x}}

getUserWarnings :: ReadTCState m => m (Map A.QName String)
getUserWarnings :: m (Map QName String)
getUserWarnings = do
  Map QName String
iuw <- Lens' (Map QName String) TCState -> m (Map QName String)
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' (Map QName String) TCState
stImportedUserWarnings
  Map QName String
luw <- Lens' (Map QName String) TCState -> m (Map QName String)
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' (Map QName String) TCState
stLocalUserWarnings
  Map QName String -> m (Map QName String)
forall (m :: * -> *) a. Monad m => a -> m a
return (Map QName String -> m (Map QName String))
-> Map QName String -> m (Map QName String)
forall a b. (a -> b) -> a -> b
$ Map QName String
iuw Map QName String -> Map QName String -> Map QName String
forall k a. Ord k => Map k a -> Map k a -> Map k a
`Map.union` Map QName String
luw

stWarningOnImport :: Lens' (Maybe String) TCState
stWarningOnImport :: (Maybe String -> f (Maybe String)) -> TCState -> f TCState
stWarningOnImport Maybe String -> f (Maybe String)
f TCState
s =
  Maybe String -> f (Maybe String)
f (Maybe String -> Maybe String
forall a. Maybe a -> Maybe a
Strict.toLazy (Maybe String -> Maybe String) -> Maybe String -> Maybe String
forall a b. (a -> b) -> a -> b
$ PreScopeState -> Maybe String
stPreWarningOnImport (TCState -> PreScopeState
stPreScopeState TCState
s)) f (Maybe String) -> (Maybe String -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ Maybe String
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreWarningOnImport :: Maybe String
stPreWarningOnImport = Maybe String -> Maybe String
forall a. Maybe a -> Maybe a
Strict.toStrict Maybe String
x}}

stImportedPartialDefs :: Lens' (Set QName) TCState
stImportedPartialDefs :: (Set QName -> f (Set QName)) -> TCState -> f TCState
stImportedPartialDefs Set QName -> f (Set QName)
f TCState
s =
  Set QName -> f (Set QName)
f (PreScopeState -> Set QName
stPreImportedPartialDefs (TCState -> PreScopeState
stPreScopeState TCState
s)) f (Set QName) -> (Set QName -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ Set QName
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreImportedPartialDefs :: Set QName
stPreImportedPartialDefs = Set QName
x}}

stLocalPartialDefs :: Lens' (Set QName) TCState
stLocalPartialDefs :: (Set QName -> f (Set QName)) -> TCState -> f TCState
stLocalPartialDefs Set QName -> f (Set QName)
f TCState
s =
  Set QName -> f (Set QName)
f (PostScopeState -> Set QName
stPostLocalPartialDefs (TCState -> PostScopeState
stPostScopeState TCState
s)) f (Set QName) -> (Set QName -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ Set QName
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostLocalPartialDefs :: Set QName
stPostLocalPartialDefs = Set QName
x}}

getPartialDefs :: ReadTCState m => m (Set QName)
getPartialDefs :: m (Set QName)
getPartialDefs = do
  Set QName
ipd <- Lens' (Set QName) TCState -> m (Set QName)
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' (Set QName) TCState
stImportedPartialDefs
  Set QName
lpd <- Lens' (Set QName) TCState -> m (Set QName)
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' (Set QName) TCState
stLocalPartialDefs
  Set QName -> m (Set QName)
forall (m :: * -> *) a. Monad m => a -> m a
return (Set QName -> m (Set QName)) -> Set QName -> m (Set QName)
forall a b. (a -> b) -> a -> b
$ Set QName
ipd Set QName -> Set QName -> Set QName
forall a. Ord a => Set a -> Set a -> Set a
`Set.union` Set QName
lpd

stLoadedFileCache :: Lens' (Maybe LoadedFileCache) TCState
stLoadedFileCache :: (Maybe LoadedFileCache -> f (Maybe LoadedFileCache))
-> TCState -> f TCState
stLoadedFileCache Maybe LoadedFileCache -> f (Maybe LoadedFileCache)
f TCState
s =
  Maybe LoadedFileCache -> f (Maybe LoadedFileCache)
f (Maybe LoadedFileCache -> Maybe LoadedFileCache
forall a. Maybe a -> Maybe a
Strict.toLazy (Maybe LoadedFileCache -> Maybe LoadedFileCache)
-> Maybe LoadedFileCache -> Maybe LoadedFileCache
forall a b. (a -> b) -> a -> b
$ PersistentTCState -> Maybe LoadedFileCache
stPersistLoadedFileCache (TCState -> PersistentTCState
stPersistentState TCState
s)) f (Maybe LoadedFileCache)
-> (Maybe LoadedFileCache -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Maybe LoadedFileCache
x -> TCState
s {stPersistentState :: PersistentTCState
stPersistentState = (TCState -> PersistentTCState
stPersistentState TCState
s) {stPersistLoadedFileCache :: Maybe LoadedFileCache
stPersistLoadedFileCache = Maybe LoadedFileCache -> Maybe LoadedFileCache
forall a. Maybe a -> Maybe a
Strict.toStrict Maybe LoadedFileCache
x}}

stBackends :: Lens' [Backend] TCState
stBackends :: ([Backend] -> f [Backend]) -> TCState -> f TCState
stBackends [Backend] -> f [Backend]
f TCState
s =
  [Backend] -> f [Backend]
f (PersistentTCState -> [Backend]
stPersistBackends (TCState -> PersistentTCState
stPersistentState TCState
s)) f [Backend] -> ([Backend] -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \[Backend]
x -> TCState
s {stPersistentState :: PersistentTCState
stPersistentState = (TCState -> PersistentTCState
stPersistentState TCState
s) {stPersistBackends :: [Backend]
stPersistBackends = [Backend]
x}}

stFreshNameId :: Lens' NameId TCState
stFreshNameId :: (NameId -> f NameId) -> TCState -> f TCState
stFreshNameId NameId -> f NameId
f TCState
s =
  NameId -> f NameId
f (PostScopeState -> NameId
stPostFreshNameId (TCState -> PostScopeState
stPostScopeState TCState
s)) f NameId -> (NameId -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \NameId
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostFreshNameId :: NameId
stPostFreshNameId = NameId
x}}

stSyntaxInfo :: Lens' CompressedFile TCState
stSyntaxInfo :: (CompressedFile -> f CompressedFile) -> TCState -> f TCState
stSyntaxInfo CompressedFile -> f CompressedFile
f TCState
s =
  CompressedFile -> f CompressedFile
f (PostScopeState -> CompressedFile
stPostSyntaxInfo (TCState -> PostScopeState
stPostScopeState TCState
s)) f CompressedFile -> (CompressedFile -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \CompressedFile
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostSyntaxInfo :: CompressedFile
stPostSyntaxInfo = CompressedFile
x}}

stDisambiguatedNames :: Lens' DisambiguatedNames TCState
stDisambiguatedNames :: (DisambiguatedNames -> f DisambiguatedNames)
-> TCState -> f TCState
stDisambiguatedNames DisambiguatedNames -> f DisambiguatedNames
f TCState
s =
  DisambiguatedNames -> f DisambiguatedNames
f (PostScopeState -> DisambiguatedNames
stPostDisambiguatedNames (TCState -> PostScopeState
stPostScopeState TCState
s)) f DisambiguatedNames
-> (DisambiguatedNames -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \DisambiguatedNames
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostDisambiguatedNames :: DisambiguatedNames
stPostDisambiguatedNames = DisambiguatedNames
x}}

stMetaStore :: Lens' MetaStore TCState
stMetaStore :: (MetaStore -> f MetaStore) -> TCState -> f TCState
stMetaStore MetaStore -> f MetaStore
f TCState
s =
  MetaStore -> f MetaStore
f (PostScopeState -> MetaStore
stPostMetaStore (TCState -> PostScopeState
stPostScopeState TCState
s)) f MetaStore -> (MetaStore -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \MetaStore
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostMetaStore :: MetaStore
stPostMetaStore = MetaStore
x}}

stInteractionPoints :: Lens' InteractionPoints TCState
stInteractionPoints :: (InteractionPoints -> f InteractionPoints) -> TCState -> f TCState
stInteractionPoints InteractionPoints -> f InteractionPoints
f TCState
s =
  InteractionPoints -> f InteractionPoints
f (PostScopeState -> InteractionPoints
stPostInteractionPoints (TCState -> PostScopeState
stPostScopeState TCState
s)) f InteractionPoints -> (InteractionPoints -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \InteractionPoints
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostInteractionPoints :: InteractionPoints
stPostInteractionPoints = InteractionPoints
x}}

stAwakeConstraints :: Lens' Constraints TCState
stAwakeConstraints :: (Constraints -> f Constraints) -> TCState -> f TCState
stAwakeConstraints Constraints -> f Constraints
f TCState
s =
  Constraints -> f Constraints
f (PostScopeState -> Constraints
stPostAwakeConstraints (TCState -> PostScopeState
stPostScopeState TCState
s)) f Constraints -> (Constraints -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Constraints
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostAwakeConstraints :: Constraints
stPostAwakeConstraints = Constraints
x}}

stSleepingConstraints :: Lens' Constraints TCState
stSleepingConstraints :: (Constraints -> f Constraints) -> TCState -> f TCState
stSleepingConstraints Constraints -> f Constraints
f TCState
s =
  Constraints -> f Constraints
f (PostScopeState -> Constraints
stPostSleepingConstraints (TCState -> PostScopeState
stPostScopeState TCState
s)) f Constraints -> (Constraints -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Constraints
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostSleepingConstraints :: Constraints
stPostSleepingConstraints = Constraints
x}}

stDirty :: Lens' Bool TCState
stDirty :: (Bool -> f Bool) -> TCState -> f TCState
stDirty Bool -> f Bool
f TCState
s =
  Bool -> f Bool
f (PostScopeState -> Bool
stPostDirty (TCState -> PostScopeState
stPostScopeState TCState
s)) f Bool -> (Bool -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Bool
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostDirty :: Bool
stPostDirty = Bool
x}}

stOccursCheckDefs :: Lens' (Set QName) TCState
stOccursCheckDefs :: (Set QName -> f (Set QName)) -> TCState -> f TCState
stOccursCheckDefs Set QName -> f (Set QName)
f TCState
s =
  Set QName -> f (Set QName)
f (PostScopeState -> Set QName
stPostOccursCheckDefs (TCState -> PostScopeState
stPostScopeState TCState
s)) f (Set QName) -> (Set QName -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Set QName
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostOccursCheckDefs :: Set QName
stPostOccursCheckDefs = Set QName
x}}

stSignature :: Lens' Signature TCState
stSignature :: (Signature -> f Signature) -> TCState -> f TCState
stSignature Signature -> f Signature
f TCState
s =
  Signature -> f Signature
f (PostScopeState -> Signature
stPostSignature (TCState -> PostScopeState
stPostScopeState TCState
s)) f Signature -> (Signature -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Signature
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostSignature :: Signature
stPostSignature = Signature
x}}

stModuleCheckpoints :: Lens' (Map ModuleName CheckpointId) TCState
stModuleCheckpoints :: (Map ModuleName CheckpointId -> f (Map ModuleName CheckpointId))
-> TCState -> f TCState
stModuleCheckpoints Map ModuleName CheckpointId -> f (Map ModuleName CheckpointId)
f TCState
s =
  Map ModuleName CheckpointId -> f (Map ModuleName CheckpointId)
f (PostScopeState -> Map ModuleName CheckpointId
stPostModuleCheckpoints (TCState -> PostScopeState
stPostScopeState TCState
s)) f (Map ModuleName CheckpointId)
-> (Map ModuleName CheckpointId -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Map ModuleName CheckpointId
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostModuleCheckpoints :: Map ModuleName CheckpointId
stPostModuleCheckpoints = Map ModuleName CheckpointId
x}}

stImportsDisplayForms :: Lens' DisplayForms TCState
stImportsDisplayForms :: (DisplayForms -> f DisplayForms) -> TCState -> f TCState
stImportsDisplayForms DisplayForms -> f DisplayForms
f TCState
s =
  DisplayForms -> f DisplayForms
f (PostScopeState -> DisplayForms
stPostImportsDisplayForms (TCState -> PostScopeState
stPostScopeState TCState
s)) f DisplayForms -> (DisplayForms -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \DisplayForms
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostImportsDisplayForms :: DisplayForms
stPostImportsDisplayForms = DisplayForms
x}}

stImportedDisplayForms :: Lens' DisplayForms TCState
stImportedDisplayForms :: (DisplayForms -> f DisplayForms) -> TCState -> f TCState
stImportedDisplayForms DisplayForms -> f DisplayForms
f TCState
s =
  DisplayForms -> f DisplayForms
f (PreScopeState -> DisplayForms
stPreImportedDisplayForms (TCState -> PreScopeState
stPreScopeState TCState
s)) f DisplayForms -> (DisplayForms -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \DisplayForms
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreImportedDisplayForms :: DisplayForms
stPreImportedDisplayForms = DisplayForms
x}}

stCurrentModule :: Lens' (Maybe ModuleName) TCState
stCurrentModule :: (Maybe ModuleName -> f (Maybe ModuleName)) -> TCState -> f TCState
stCurrentModule Maybe ModuleName -> f (Maybe ModuleName)
f TCState
s =
  Maybe ModuleName -> f (Maybe ModuleName)
f (Maybe ModuleName -> Maybe ModuleName
forall a. Maybe a -> Maybe a
Strict.toLazy (Maybe ModuleName -> Maybe ModuleName)
-> Maybe ModuleName -> Maybe ModuleName
forall a b. (a -> b) -> a -> b
$ PostScopeState -> Maybe ModuleName
stPostCurrentModule (TCState -> PostScopeState
stPostScopeState TCState
s)) f (Maybe ModuleName) -> (Maybe ModuleName -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Maybe ModuleName
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostCurrentModule :: Maybe ModuleName
stPostCurrentModule = Maybe ModuleName -> Maybe ModuleName
forall a. Maybe a -> Maybe a
Strict.toStrict Maybe ModuleName
x}}

stImportedInstanceDefs :: Lens' InstanceTable TCState
stImportedInstanceDefs :: (InstanceTable -> f InstanceTable) -> TCState -> f TCState
stImportedInstanceDefs InstanceTable -> f InstanceTable
f TCState
s =
  InstanceTable -> f InstanceTable
f (PreScopeState -> InstanceTable
stPreImportedInstanceDefs (TCState -> PreScopeState
stPreScopeState TCState
s)) f InstanceTable -> (InstanceTable -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \InstanceTable
x -> TCState
s {stPreScopeState :: PreScopeState
stPreScopeState = (TCState -> PreScopeState
stPreScopeState TCState
s) {stPreImportedInstanceDefs :: InstanceTable
stPreImportedInstanceDefs = InstanceTable
x}}

stInstanceDefs :: Lens' TempInstanceTable TCState
stInstanceDefs :: (TempInstanceTable -> f TempInstanceTable) -> TCState -> f TCState
stInstanceDefs TempInstanceTable -> f TempInstanceTable
f TCState
s =
  TempInstanceTable -> f TempInstanceTable
f (PostScopeState -> TempInstanceTable
stPostInstanceDefs (TCState -> PostScopeState
stPostScopeState TCState
s)) f TempInstanceTable -> (TempInstanceTable -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \TempInstanceTable
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostInstanceDefs :: TempInstanceTable
stPostInstanceDefs = TempInstanceTable
x}}

stConcreteNames :: Lens' ConcreteNames TCState
stConcreteNames :: (ConcreteNames -> f ConcreteNames) -> TCState -> f TCState
stConcreteNames ConcreteNames -> f ConcreteNames
f TCState
s =
  ConcreteNames -> f ConcreteNames
f (PostScopeState -> ConcreteNames
stPostConcreteNames (TCState -> PostScopeState
stPostScopeState TCState
s)) f ConcreteNames -> (ConcreteNames -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ConcreteNames
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostConcreteNames :: ConcreteNames
stPostConcreteNames = ConcreteNames
x}}

stUsedNames :: Lens' (Map RawName [RawName]) TCState
stUsedNames :: (Map String [String] -> f (Map String [String]))
-> TCState -> f TCState
stUsedNames Map String [String] -> f (Map String [String])
f TCState
s =
  Map String [String] -> f (Map String [String])
f (PostScopeState -> Map String [String]
stPostUsedNames (TCState -> PostScopeState
stPostScopeState TCState
s)) f (Map String [String])
-> (Map String [String] -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Map String [String]
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostUsedNames :: Map String [String]
stPostUsedNames = Map String [String]
x}}

stShadowingNames :: Lens' (Map Name [RawName]) TCState
stShadowingNames :: (Map Name [String] -> f (Map Name [String]))
-> TCState -> f TCState
stShadowingNames Map Name [String] -> f (Map Name [String])
f TCState
s =
  Map Name [String] -> f (Map Name [String])
f (PostScopeState -> Map Name [String]
stPostShadowingNames (TCState -> PostScopeState
stPostScopeState TCState
s)) f (Map Name [String])
-> (Map Name [String] -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Map Name [String]
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostShadowingNames :: Map Name [String]
stPostShadowingNames = Map Name [String]
x}}

stStatistics :: Lens' Statistics TCState
stStatistics :: (Statistics -> f Statistics) -> TCState -> f TCState
stStatistics Statistics -> f Statistics
f TCState
s =
  Statistics -> f Statistics
f (PostScopeState -> Statistics
stPostStatistics (TCState -> PostScopeState
stPostScopeState TCState
s)) f Statistics -> (Statistics -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Statistics
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostStatistics :: Statistics
stPostStatistics = Statistics
x}}

stTCWarnings :: Lens' [TCWarning] TCState
stTCWarnings :: ([TCWarning] -> f [TCWarning]) -> TCState -> f TCState
stTCWarnings [TCWarning] -> f [TCWarning]
f TCState
s =
  [TCWarning] -> f [TCWarning]
f (PostScopeState -> [TCWarning]
stPostTCWarnings (TCState -> PostScopeState
stPostScopeState TCState
s)) f [TCWarning] -> ([TCWarning] -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \[TCWarning]
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostTCWarnings :: [TCWarning]
stPostTCWarnings = [TCWarning]
x}}

stMutualBlocks :: Lens' (Map MutualId MutualBlock) TCState
stMutualBlocks :: (Map MutualId MutualBlock -> f (Map MutualId MutualBlock))
-> TCState -> f TCState
stMutualBlocks Map MutualId MutualBlock -> f (Map MutualId MutualBlock)
f TCState
s =
  Map MutualId MutualBlock -> f (Map MutualId MutualBlock)
f (PostScopeState -> Map MutualId MutualBlock
stPostMutualBlocks (TCState -> PostScopeState
stPostScopeState TCState
s)) f (Map MutualId MutualBlock)
-> (Map MutualId MutualBlock -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Map MutualId MutualBlock
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostMutualBlocks :: Map MutualId MutualBlock
stPostMutualBlocks = Map MutualId MutualBlock
x}}

stLocalBuiltins :: Lens' (BuiltinThings PrimFun) TCState
stLocalBuiltins :: (BuiltinThings PrimFun -> f (BuiltinThings PrimFun))
-> TCState -> f TCState
stLocalBuiltins BuiltinThings PrimFun -> f (BuiltinThings PrimFun)
f TCState
s =
  BuiltinThings PrimFun -> f (BuiltinThings PrimFun)
f (PostScopeState -> BuiltinThings PrimFun
stPostLocalBuiltins (TCState -> PostScopeState
stPostScopeState TCState
s)) f (BuiltinThings PrimFun)
-> (BuiltinThings PrimFun -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \BuiltinThings PrimFun
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostLocalBuiltins :: BuiltinThings PrimFun
stPostLocalBuiltins = BuiltinThings PrimFun
x}}

stFreshMetaId :: Lens' MetaId TCState
stFreshMetaId :: (MetaId -> f MetaId) -> TCState -> f TCState
stFreshMetaId MetaId -> f MetaId
f TCState
s =
  MetaId -> f MetaId
f (PostScopeState -> MetaId
stPostFreshMetaId (TCState -> PostScopeState
stPostScopeState TCState
s)) f MetaId -> (MetaId -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \MetaId
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostFreshMetaId :: MetaId
stPostFreshMetaId = MetaId
x}}

stFreshMutualId :: Lens' MutualId TCState
stFreshMutualId :: (MutualId -> f MutualId) -> TCState -> f TCState
stFreshMutualId MutualId -> f MutualId
f TCState
s =
  MutualId -> f MutualId
f (PostScopeState -> MutualId
stPostFreshMutualId (TCState -> PostScopeState
stPostScopeState TCState
s)) f MutualId -> (MutualId -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \MutualId
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostFreshMutualId :: MutualId
stPostFreshMutualId = MutualId
x}}

stFreshProblemId :: Lens' ProblemId TCState
stFreshProblemId :: (ProblemId -> f ProblemId) -> TCState -> f TCState
stFreshProblemId ProblemId -> f ProblemId
f TCState
s =
  ProblemId -> f ProblemId
f (PostScopeState -> ProblemId
stPostFreshProblemId (TCState -> PostScopeState
stPostScopeState TCState
s)) f ProblemId -> (ProblemId -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ProblemId
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostFreshProblemId :: ProblemId
stPostFreshProblemId = ProblemId
x}}

stFreshCheckpointId :: Lens' CheckpointId TCState
stFreshCheckpointId :: (CheckpointId -> f CheckpointId) -> TCState -> f TCState
stFreshCheckpointId CheckpointId -> f CheckpointId
f TCState
s =
  CheckpointId -> f CheckpointId
f (PostScopeState -> CheckpointId
stPostFreshCheckpointId (TCState -> PostScopeState
stPostScopeState TCState
s)) f CheckpointId -> (CheckpointId -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \CheckpointId
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostFreshCheckpointId :: CheckpointId
stPostFreshCheckpointId = CheckpointId
x}}

stFreshInt :: Lens' Int TCState
stFreshInt :: (Int -> f Int) -> TCState -> f TCState
stFreshInt Int -> f Int
f TCState
s =
  Int -> f Int
f (PostScopeState -> Int
stPostFreshInt (TCState -> PostScopeState
stPostScopeState TCState
s)) f Int -> (Int -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Int
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostFreshInt :: Int
stPostFreshInt = Int
x}}

-- use @areWeCaching@ from the Caching module instead.
stAreWeCaching :: Lens' Bool TCState
stAreWeCaching :: (Bool -> f Bool) -> TCState -> f TCState
stAreWeCaching Bool -> f Bool
f TCState
s =
  Bool -> f Bool
f (PostScopeState -> Bool
stPostAreWeCaching (TCState -> PostScopeState
stPostScopeState TCState
s)) f Bool -> (Bool -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Bool
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostAreWeCaching :: Bool
stPostAreWeCaching = Bool
x}}

stPostponeInstanceSearch :: Lens' Bool TCState
stPostponeInstanceSearch :: (Bool -> f Bool) -> TCState -> f TCState
stPostponeInstanceSearch Bool -> f Bool
f TCState
s =
  Bool -> f Bool
f (PostScopeState -> Bool
stPostPostponeInstanceSearch (TCState -> PostScopeState
stPostScopeState TCState
s)) f Bool -> (Bool -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Bool
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostPostponeInstanceSearch :: Bool
stPostPostponeInstanceSearch = Bool
x}}

stConsideringInstance :: Lens' Bool TCState
stConsideringInstance :: (Bool -> f Bool) -> TCState -> f TCState
stConsideringInstance Bool -> f Bool
f TCState
s =
  Bool -> f Bool
f (PostScopeState -> Bool
stPostConsideringInstance (TCState -> PostScopeState
stPostScopeState TCState
s)) f Bool -> (Bool -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Bool
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostConsideringInstance :: Bool
stPostConsideringInstance = Bool
x}}

stInstantiateBlocking :: Lens' Bool TCState
stInstantiateBlocking :: (Bool -> f Bool) -> TCState -> f TCState
stInstantiateBlocking Bool -> f Bool
f TCState
s =
  Bool -> f Bool
f (PostScopeState -> Bool
stPostInstantiateBlocking (TCState -> PostScopeState
stPostScopeState TCState
s)) f Bool -> (Bool -> TCState) -> f TCState
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Bool
x -> TCState
s {stPostScopeState :: PostScopeState
stPostScopeState = (TCState -> PostScopeState
stPostScopeState TCState
s) {stPostInstantiateBlocking :: Bool
stPostInstantiateBlocking = Bool
x}}

stBuiltinThings :: TCState -> BuiltinThings PrimFun
stBuiltinThings :: TCState -> BuiltinThings PrimFun
stBuiltinThings TCState
s = (TCState
sTCState
-> Lens' (BuiltinThings PrimFun) TCState -> BuiltinThings PrimFun
forall o i. o -> Lens' i o -> i
^.Lens' (BuiltinThings PrimFun) TCState
stLocalBuiltins) BuiltinThings PrimFun
-> BuiltinThings PrimFun -> BuiltinThings PrimFun
forall k a. Ord k => Map k a -> Map k a -> Map k a
`Map.union` (TCState
sTCState
-> Lens' (BuiltinThings PrimFun) TCState -> BuiltinThings PrimFun
forall o i. o -> Lens' i o -> i
^.Lens' (BuiltinThings PrimFun) TCState
stImportedBuiltins)


-- * Fresh things
------------------------------------------------------------------------

class Enum i => HasFresh i where
    freshLens :: Lens' i TCState
    nextFresh' :: i -> i
    nextFresh' = i -> i
forall a. Enum a => a -> a
succ

nextFresh :: HasFresh i => TCState -> (i, TCState)
nextFresh :: TCState -> (i, TCState)
nextFresh TCState
s =
  let !c :: i
c = TCState
sTCState -> Lens' i TCState -> i
forall o i. o -> Lens' i o -> i
^.forall i. HasFresh i => Lens' i TCState
Lens' i TCState
freshLens
  in (i
c, Lens' i TCState -> LensSet i TCState
forall i o. Lens' i o -> LensSet i o
set forall i. HasFresh i => Lens' i TCState
Lens' i TCState
freshLens (i -> i
forall i. HasFresh i => i -> i
nextFresh' i
c) TCState
s)

class Monad m => MonadFresh i m where
  fresh :: m i

instance MonadFresh i m => MonadFresh i (ReaderT r m) where
  fresh :: ReaderT r m i
fresh = m i -> ReaderT r m i
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m i
forall i (m :: * -> *). MonadFresh i m => m i
fresh

instance MonadFresh i m => MonadFresh i (StateT s m) where
  fresh :: StateT s m i
fresh = m i -> StateT s m i
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m i
forall i (m :: * -> *). MonadFresh i m => m i
fresh

instance HasFresh i => MonadFresh i TCM where
  fresh :: TCM i
fresh = do
        !TCState
s <- TCMT IO TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
        let (!i
c , !TCState
s') = TCState -> (i, TCState)
forall i. HasFresh i => TCState -> (i, TCState)
nextFresh TCState
s
        TCState -> TCMT IO ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC TCState
s'
        i -> TCM i
forall (m :: * -> *) a. Monad m => a -> m a
return i
c

instance HasFresh MetaId where
  freshLens :: (MetaId -> f MetaId) -> TCState -> f TCState
freshLens = (MetaId -> f MetaId) -> TCState -> f TCState
Lens' MetaId TCState
stFreshMetaId

instance HasFresh MutualId where
  freshLens :: (MutualId -> f MutualId) -> TCState -> f TCState
freshLens = (MutualId -> f MutualId) -> TCState -> f TCState
Lens' MutualId TCState
stFreshMutualId

instance HasFresh InteractionId where
  freshLens :: (InteractionId -> f InteractionId) -> TCState -> f TCState
freshLens = (InteractionId -> f InteractionId) -> TCState -> f TCState
Lens' InteractionId TCState
stFreshInteractionId

instance HasFresh NameId where
  freshLens :: (NameId -> f NameId) -> TCState -> f TCState
freshLens = (NameId -> f NameId) -> TCState -> f TCState
Lens' NameId TCState
stFreshNameId
  -- nextFresh increments the current fresh name by 2 so @NameId@s used
  -- before caching starts do not overlap with the ones used after.
  nextFresh' :: NameId -> NameId
nextFresh' = NameId -> NameId
forall a. Enum a => a -> a
succ (NameId -> NameId) -> (NameId -> NameId) -> NameId -> NameId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameId -> NameId
forall a. Enum a => a -> a
succ

instance HasFresh Int where
  freshLens :: (Int -> f Int) -> TCState -> f TCState
freshLens = (Int -> f Int) -> TCState -> f TCState
Lens' Int TCState
stFreshInt

newtype ProblemId = ProblemId Nat
  deriving (Typeable ProblemId
DataType
Constr
Typeable ProblemId
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ProblemId -> c ProblemId)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ProblemId)
-> (ProblemId -> Constr)
-> (ProblemId -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ProblemId))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ProblemId))
-> ((forall b. Data b => b -> b) -> ProblemId -> ProblemId)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ProblemId -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ProblemId -> r)
-> (forall u. (forall d. Data d => d -> u) -> ProblemId -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ProblemId -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ProblemId -> m ProblemId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ProblemId -> m ProblemId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ProblemId -> m ProblemId)
-> Data ProblemId
ProblemId -> DataType
ProblemId -> Constr
(forall b. Data b => b -> b) -> ProblemId -> ProblemId
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProblemId -> c ProblemId
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProblemId
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) -> ProblemId -> u
forall u. (forall d. Data d => d -> u) -> ProblemId -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemId -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemId -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ProblemId -> m ProblemId
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ProblemId -> m ProblemId
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProblemId
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProblemId -> c ProblemId
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ProblemId)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ProblemId)
$cProblemId :: Constr
$tProblemId :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> ProblemId -> m ProblemId
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ProblemId -> m ProblemId
gmapMp :: (forall d. Data d => d -> m d) -> ProblemId -> m ProblemId
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ProblemId -> m ProblemId
gmapM :: (forall d. Data d => d -> m d) -> ProblemId -> m ProblemId
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ProblemId -> m ProblemId
gmapQi :: Int -> (forall d. Data d => d -> u) -> ProblemId -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ProblemId -> u
gmapQ :: (forall d. Data d => d -> u) -> ProblemId -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ProblemId -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemId -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemId -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemId -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemId -> r
gmapT :: (forall b. Data b => b -> b) -> ProblemId -> ProblemId
$cgmapT :: (forall b. Data b => b -> b) -> ProblemId -> ProblemId
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ProblemId)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ProblemId)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ProblemId)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ProblemId)
dataTypeOf :: ProblemId -> DataType
$cdataTypeOf :: ProblemId -> DataType
toConstr :: ProblemId -> Constr
$ctoConstr :: ProblemId -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProblemId
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProblemId
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProblemId -> c ProblemId
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProblemId -> c ProblemId
$cp1Data :: Typeable ProblemId
Data, ProblemId -> ProblemId -> Bool
(ProblemId -> ProblemId -> Bool)
-> (ProblemId -> ProblemId -> Bool) -> Eq ProblemId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProblemId -> ProblemId -> Bool
$c/= :: ProblemId -> ProblemId -> Bool
== :: ProblemId -> ProblemId -> Bool
$c== :: ProblemId -> ProblemId -> Bool
Eq, Eq ProblemId
Eq ProblemId
-> (ProblemId -> ProblemId -> Ordering)
-> (ProblemId -> ProblemId -> Bool)
-> (ProblemId -> ProblemId -> Bool)
-> (ProblemId -> ProblemId -> Bool)
-> (ProblemId -> ProblemId -> Bool)
-> (ProblemId -> ProblemId -> ProblemId)
-> (ProblemId -> ProblemId -> ProblemId)
-> Ord ProblemId
ProblemId -> ProblemId -> Bool
ProblemId -> ProblemId -> Ordering
ProblemId -> ProblemId -> ProblemId
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 :: ProblemId -> ProblemId -> ProblemId
$cmin :: ProblemId -> ProblemId -> ProblemId
max :: ProblemId -> ProblemId -> ProblemId
$cmax :: ProblemId -> ProblemId -> ProblemId
>= :: ProblemId -> ProblemId -> Bool
$c>= :: ProblemId -> ProblemId -> Bool
> :: ProblemId -> ProblemId -> Bool
$c> :: ProblemId -> ProblemId -> Bool
<= :: ProblemId -> ProblemId -> Bool
$c<= :: ProblemId -> ProblemId -> Bool
< :: ProblemId -> ProblemId -> Bool
$c< :: ProblemId -> ProblemId -> Bool
compare :: ProblemId -> ProblemId -> Ordering
$ccompare :: ProblemId -> ProblemId -> Ordering
$cp1Ord :: Eq ProblemId
Ord, Int -> ProblemId
ProblemId -> Int
ProblemId -> [ProblemId]
ProblemId -> ProblemId
ProblemId -> ProblemId -> [ProblemId]
ProblemId -> ProblemId -> ProblemId -> [ProblemId]
(ProblemId -> ProblemId)
-> (ProblemId -> ProblemId)
-> (Int -> ProblemId)
-> (ProblemId -> Int)
-> (ProblemId -> [ProblemId])
-> (ProblemId -> ProblemId -> [ProblemId])
-> (ProblemId -> ProblemId -> [ProblemId])
-> (ProblemId -> ProblemId -> ProblemId -> [ProblemId])
-> Enum ProblemId
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: ProblemId -> ProblemId -> ProblemId -> [ProblemId]
$cenumFromThenTo :: ProblemId -> ProblemId -> ProblemId -> [ProblemId]
enumFromTo :: ProblemId -> ProblemId -> [ProblemId]
$cenumFromTo :: ProblemId -> ProblemId -> [ProblemId]
enumFromThen :: ProblemId -> ProblemId -> [ProblemId]
$cenumFromThen :: ProblemId -> ProblemId -> [ProblemId]
enumFrom :: ProblemId -> [ProblemId]
$cenumFrom :: ProblemId -> [ProblemId]
fromEnum :: ProblemId -> Int
$cfromEnum :: ProblemId -> Int
toEnum :: Int -> ProblemId
$ctoEnum :: Int -> ProblemId
pred :: ProblemId -> ProblemId
$cpred :: ProblemId -> ProblemId
succ :: ProblemId -> ProblemId
$csucc :: ProblemId -> ProblemId
Enum, Num ProblemId
Ord ProblemId
Num ProblemId
-> Ord ProblemId -> (ProblemId -> Rational) -> Real ProblemId
ProblemId -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: ProblemId -> Rational
$ctoRational :: ProblemId -> Rational
$cp2Real :: Ord ProblemId
$cp1Real :: Num ProblemId
Real, Enum ProblemId
Real ProblemId
Real ProblemId
-> Enum ProblemId
-> (ProblemId -> ProblemId -> ProblemId)
-> (ProblemId -> ProblemId -> ProblemId)
-> (ProblemId -> ProblemId -> ProblemId)
-> (ProblemId -> ProblemId -> ProblemId)
-> (ProblemId -> ProblemId -> (ProblemId, ProblemId))
-> (ProblemId -> ProblemId -> (ProblemId, ProblemId))
-> (ProblemId -> Integer)
-> Integral ProblemId
ProblemId -> Integer
ProblemId -> ProblemId -> (ProblemId, ProblemId)
ProblemId -> ProblemId -> ProblemId
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: ProblemId -> Integer
$ctoInteger :: ProblemId -> Integer
divMod :: ProblemId -> ProblemId -> (ProblemId, ProblemId)
$cdivMod :: ProblemId -> ProblemId -> (ProblemId, ProblemId)
quotRem :: ProblemId -> ProblemId -> (ProblemId, ProblemId)
$cquotRem :: ProblemId -> ProblemId -> (ProblemId, ProblemId)
mod :: ProblemId -> ProblemId -> ProblemId
$cmod :: ProblemId -> ProblemId -> ProblemId
div :: ProblemId -> ProblemId -> ProblemId
$cdiv :: ProblemId -> ProblemId -> ProblemId
rem :: ProblemId -> ProblemId -> ProblemId
$crem :: ProblemId -> ProblemId -> ProblemId
quot :: ProblemId -> ProblemId -> ProblemId
$cquot :: ProblemId -> ProblemId -> ProblemId
$cp2Integral :: Enum ProblemId
$cp1Integral :: Real ProblemId
Integral, Integer -> ProblemId
ProblemId -> ProblemId
ProblemId -> ProblemId -> ProblemId
(ProblemId -> ProblemId -> ProblemId)
-> (ProblemId -> ProblemId -> ProblemId)
-> (ProblemId -> ProblemId -> ProblemId)
-> (ProblemId -> ProblemId)
-> (ProblemId -> ProblemId)
-> (ProblemId -> ProblemId)
-> (Integer -> ProblemId)
-> Num ProblemId
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> ProblemId
$cfromInteger :: Integer -> ProblemId
signum :: ProblemId -> ProblemId
$csignum :: ProblemId -> ProblemId
abs :: ProblemId -> ProblemId
$cabs :: ProblemId -> ProblemId
negate :: ProblemId -> ProblemId
$cnegate :: ProblemId -> ProblemId
* :: ProblemId -> ProblemId -> ProblemId
$c* :: ProblemId -> ProblemId -> ProblemId
- :: ProblemId -> ProblemId -> ProblemId
$c- :: ProblemId -> ProblemId -> ProblemId
+ :: ProblemId -> ProblemId -> ProblemId
$c+ :: ProblemId -> ProblemId -> ProblemId
Num)

-- TODO: 'Show' should output Haskell-parseable representations.
-- The following instance is deprecated, and Pretty[TCM] should be used
-- instead. Later, simply derive Show for this type.

-- ASR (28 December 2014). This instance is not used anymore (module
-- the test suite) when reporting errors. See Issue 1293.

-- This particular Show instance is ok because of the Num instance.
instance Show ProblemId where
  show :: ProblemId -> String
show (ProblemId Int
n) = Int -> String
forall a. Show a => a -> String
show Int
n

instance Pretty ProblemId where
  pretty :: ProblemId -> Doc
pretty (ProblemId Int
n) = Int -> Doc
forall a. Pretty a => a -> Doc
pretty Int
n

instance HasFresh ProblemId where
  freshLens :: (ProblemId -> f ProblemId) -> TCState -> f TCState
freshLens = (ProblemId -> f ProblemId) -> TCState -> f TCState
Lens' ProblemId TCState
stFreshProblemId

newtype CheckpointId = CheckpointId Int
  deriving (Typeable CheckpointId
DataType
Constr
Typeable CheckpointId
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CheckpointId -> c CheckpointId)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CheckpointId)
-> (CheckpointId -> Constr)
-> (CheckpointId -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CheckpointId))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CheckpointId))
-> ((forall b. Data b => b -> b) -> CheckpointId -> CheckpointId)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CheckpointId -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CheckpointId -> r)
-> (forall u. (forall d. Data d => d -> u) -> CheckpointId -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CheckpointId -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId)
-> Data CheckpointId
CheckpointId -> DataType
CheckpointId -> Constr
(forall b. Data b => b -> b) -> CheckpointId -> CheckpointId
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CheckpointId -> c CheckpointId
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CheckpointId
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) -> CheckpointId -> u
forall u. (forall d. Data d => d -> u) -> CheckpointId -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CheckpointId -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CheckpointId -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CheckpointId
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CheckpointId -> c CheckpointId
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CheckpointId)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CheckpointId)
$cCheckpointId :: Constr
$tCheckpointId :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId
gmapMp :: (forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId
gmapM :: (forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CheckpointId -> m CheckpointId
gmapQi :: Int -> (forall d. Data d => d -> u) -> CheckpointId -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CheckpointId -> u
gmapQ :: (forall d. Data d => d -> u) -> CheckpointId -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CheckpointId -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CheckpointId -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CheckpointId -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CheckpointId -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CheckpointId -> r
gmapT :: (forall b. Data b => b -> b) -> CheckpointId -> CheckpointId
$cgmapT :: (forall b. Data b => b -> b) -> CheckpointId -> CheckpointId
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CheckpointId)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CheckpointId)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CheckpointId)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CheckpointId)
dataTypeOf :: CheckpointId -> DataType
$cdataTypeOf :: CheckpointId -> DataType
toConstr :: CheckpointId -> Constr
$ctoConstr :: CheckpointId -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CheckpointId
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CheckpointId
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CheckpointId -> c CheckpointId
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CheckpointId -> c CheckpointId
$cp1Data :: Typeable CheckpointId
Data, CheckpointId -> CheckpointId -> Bool
(CheckpointId -> CheckpointId -> Bool)
-> (CheckpointId -> CheckpointId -> Bool) -> Eq CheckpointId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CheckpointId -> CheckpointId -> Bool
$c/= :: CheckpointId -> CheckpointId -> Bool
== :: CheckpointId -> CheckpointId -> Bool
$c== :: CheckpointId -> CheckpointId -> Bool
Eq, Eq CheckpointId
Eq CheckpointId
-> (CheckpointId -> CheckpointId -> Ordering)
-> (CheckpointId -> CheckpointId -> Bool)
-> (CheckpointId -> CheckpointId -> Bool)
-> (CheckpointId -> CheckpointId -> Bool)
-> (CheckpointId -> CheckpointId -> Bool)
-> (CheckpointId -> CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId -> CheckpointId)
-> Ord CheckpointId
CheckpointId -> CheckpointId -> Bool
CheckpointId -> CheckpointId -> Ordering
CheckpointId -> CheckpointId -> CheckpointId
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 :: CheckpointId -> CheckpointId -> CheckpointId
$cmin :: CheckpointId -> CheckpointId -> CheckpointId
max :: CheckpointId -> CheckpointId -> CheckpointId
$cmax :: CheckpointId -> CheckpointId -> CheckpointId
>= :: CheckpointId -> CheckpointId -> Bool
$c>= :: CheckpointId -> CheckpointId -> Bool
> :: CheckpointId -> CheckpointId -> Bool
$c> :: CheckpointId -> CheckpointId -> Bool
<= :: CheckpointId -> CheckpointId -> Bool
$c<= :: CheckpointId -> CheckpointId -> Bool
< :: CheckpointId -> CheckpointId -> Bool
$c< :: CheckpointId -> CheckpointId -> Bool
compare :: CheckpointId -> CheckpointId -> Ordering
$ccompare :: CheckpointId -> CheckpointId -> Ordering
$cp1Ord :: Eq CheckpointId
Ord, Int -> CheckpointId
CheckpointId -> Int
CheckpointId -> [CheckpointId]
CheckpointId -> CheckpointId
CheckpointId -> CheckpointId -> [CheckpointId]
CheckpointId -> CheckpointId -> CheckpointId -> [CheckpointId]
(CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId)
-> (Int -> CheckpointId)
-> (CheckpointId -> Int)
-> (CheckpointId -> [CheckpointId])
-> (CheckpointId -> CheckpointId -> [CheckpointId])
-> (CheckpointId -> CheckpointId -> [CheckpointId])
-> (CheckpointId -> CheckpointId -> CheckpointId -> [CheckpointId])
-> Enum CheckpointId
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: CheckpointId -> CheckpointId -> CheckpointId -> [CheckpointId]
$cenumFromThenTo :: CheckpointId -> CheckpointId -> CheckpointId -> [CheckpointId]
enumFromTo :: CheckpointId -> CheckpointId -> [CheckpointId]
$cenumFromTo :: CheckpointId -> CheckpointId -> [CheckpointId]
enumFromThen :: CheckpointId -> CheckpointId -> [CheckpointId]
$cenumFromThen :: CheckpointId -> CheckpointId -> [CheckpointId]
enumFrom :: CheckpointId -> [CheckpointId]
$cenumFrom :: CheckpointId -> [CheckpointId]
fromEnum :: CheckpointId -> Int
$cfromEnum :: CheckpointId -> Int
toEnum :: Int -> CheckpointId
$ctoEnum :: Int -> CheckpointId
pred :: CheckpointId -> CheckpointId
$cpred :: CheckpointId -> CheckpointId
succ :: CheckpointId -> CheckpointId
$csucc :: CheckpointId -> CheckpointId
Enum, Num CheckpointId
Ord CheckpointId
Num CheckpointId
-> Ord CheckpointId
-> (CheckpointId -> Rational)
-> Real CheckpointId
CheckpointId -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: CheckpointId -> Rational
$ctoRational :: CheckpointId -> Rational
$cp2Real :: Ord CheckpointId
$cp1Real :: Num CheckpointId
Real, Enum CheckpointId
Real CheckpointId
Real CheckpointId
-> Enum CheckpointId
-> (CheckpointId -> CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId -> (CheckpointId, CheckpointId))
-> (CheckpointId -> CheckpointId -> (CheckpointId, CheckpointId))
-> (CheckpointId -> Integer)
-> Integral CheckpointId
CheckpointId -> Integer
CheckpointId -> CheckpointId -> (CheckpointId, CheckpointId)
CheckpointId -> CheckpointId -> CheckpointId
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: CheckpointId -> Integer
$ctoInteger :: CheckpointId -> Integer
divMod :: CheckpointId -> CheckpointId -> (CheckpointId, CheckpointId)
$cdivMod :: CheckpointId -> CheckpointId -> (CheckpointId, CheckpointId)
quotRem :: CheckpointId -> CheckpointId -> (CheckpointId, CheckpointId)
$cquotRem :: CheckpointId -> CheckpointId -> (CheckpointId, CheckpointId)
mod :: CheckpointId -> CheckpointId -> CheckpointId
$cmod :: CheckpointId -> CheckpointId -> CheckpointId
div :: CheckpointId -> CheckpointId -> CheckpointId
$cdiv :: CheckpointId -> CheckpointId -> CheckpointId
rem :: CheckpointId -> CheckpointId -> CheckpointId
$crem :: CheckpointId -> CheckpointId -> CheckpointId
quot :: CheckpointId -> CheckpointId -> CheckpointId
$cquot :: CheckpointId -> CheckpointId -> CheckpointId
$cp2Integral :: Enum CheckpointId
$cp1Integral :: Real CheckpointId
Integral, Integer -> CheckpointId
CheckpointId -> CheckpointId
CheckpointId -> CheckpointId -> CheckpointId
(CheckpointId -> CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId)
-> (CheckpointId -> CheckpointId)
-> (Integer -> CheckpointId)
-> Num CheckpointId
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> CheckpointId
$cfromInteger :: Integer -> CheckpointId
signum :: CheckpointId -> CheckpointId
$csignum :: CheckpointId -> CheckpointId
abs :: CheckpointId -> CheckpointId
$cabs :: CheckpointId -> CheckpointId
negate :: CheckpointId -> CheckpointId
$cnegate :: CheckpointId -> CheckpointId
* :: CheckpointId -> CheckpointId -> CheckpointId
$c* :: CheckpointId -> CheckpointId -> CheckpointId
- :: CheckpointId -> CheckpointId -> CheckpointId
$c- :: CheckpointId -> CheckpointId -> CheckpointId
+ :: CheckpointId -> CheckpointId -> CheckpointId
$c+ :: CheckpointId -> CheckpointId -> CheckpointId
Num)

instance Show CheckpointId where
  show :: CheckpointId -> String
show (CheckpointId Int
n) = Int -> String
forall a. Show a => a -> String
show Int
n

instance Pretty CheckpointId where
  pretty :: CheckpointId -> Doc
pretty (CheckpointId Int
n) = Int -> Doc
forall a. Pretty a => a -> Doc
pretty Int
n

instance HasFresh CheckpointId where
  freshLens :: (CheckpointId -> f CheckpointId) -> TCState -> f TCState
freshLens = (CheckpointId -> f CheckpointId) -> TCState -> f TCState
Lens' CheckpointId TCState
stFreshCheckpointId

freshName :: MonadFresh NameId m => Range -> String -> m Name
freshName :: Range -> String -> m Name
freshName Range
r String
s = do
  NameId
i <- m NameId
forall i (m :: * -> *). MonadFresh i m => m i
fresh
  Name -> m Name
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> m Name) -> Name -> m Name
forall a b. (a -> b) -> a -> b
$ Range -> NameId -> String -> Name
forall a. MkName a => Range -> NameId -> a -> Name
mkName Range
r NameId
i String
s

freshNoName :: MonadFresh NameId m => Range -> m Name
freshNoName :: Range -> m Name
freshNoName Range
r =
    do  NameId
i <- m NameId
forall i (m :: * -> *). MonadFresh i m => m i
fresh
        Name -> m Name
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> m Name) -> Name -> m Name
forall a b. (a -> b) -> a -> b
$ NameId -> Name -> Range -> Fixity' -> Bool -> Name
Name NameId
i (Range -> NameId -> Name
C.NoName Range
forall a. Range' a
noRange NameId
i) Range
r Fixity'
noFixity' Bool
False

freshNoName_ :: MonadFresh NameId m => m Name
freshNoName_ :: m Name
freshNoName_ = Range -> m Name
forall (m :: * -> *). MonadFresh NameId m => Range -> m Name
freshNoName Range
forall a. Range' a
noRange

freshRecordName :: MonadFresh NameId m => m Name
freshRecordName :: m Name
freshRecordName = do
  NameId
i <- m NameId
forall i (m :: * -> *). MonadFresh i m => m i
fresh
  Name -> m Name
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> m Name) -> Name -> m Name
forall a b. (a -> b) -> a -> b
$ NameId -> Name -> Range -> Fixity' -> Bool -> Name
Name NameId
i (Range -> NameInScope -> [NamePart] -> Name
C.Name Range
forall a. Range' a
noRange NameInScope
C.NotInScope [String -> NamePart
C.Id String
"r"]) Range
forall a. Range' a
noRange Fixity'
noFixity' Bool
True

-- | Create a fresh name from @a@.
class FreshName a where
  freshName_ :: MonadFresh NameId m => a -> m Name

instance FreshName (Range, String) where
  freshName_ :: (Range, String) -> m Name
freshName_ = (Range -> String -> m Name) -> (Range, String) -> m Name
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Range -> String -> m Name
forall (m :: * -> *).
MonadFresh NameId m =>
Range -> String -> m Name
freshName

instance FreshName String where
  freshName_ :: String -> m Name
freshName_ = Range -> String -> m Name
forall (m :: * -> *).
MonadFresh NameId m =>
Range -> String -> m Name
freshName Range
forall a. Range' a
noRange

instance FreshName Range where
  freshName_ :: Range -> m Name
freshName_ = Range -> m Name
forall (m :: * -> *). MonadFresh NameId m => Range -> m Name
freshNoName

instance FreshName () where
  freshName_ :: () -> m Name
freshName_ () = m Name
forall (m :: * -> *). MonadFresh NameId m => m Name
freshNoName_

---------------------------------------------------------------------------
-- ** Managing file names
---------------------------------------------------------------------------

-- | Maps top-level module names to the corresponding source file
-- names.

type ModuleToSource = Map TopLevelModuleName AbsolutePath

-- | Maps source file names to the corresponding top-level module
-- names.

type SourceToModule = Map AbsolutePath TopLevelModuleName

-- | Creates a 'SourceToModule' map based on 'stModuleToSource'.
--
--   O(n log n).
--
--   For a single reverse lookup in 'stModuleToSource',
--   rather use 'lookupModuleFromSourse'.

sourceToModule :: TCM SourceToModule
sourceToModule :: TCM SourceToModule
sourceToModule =
  [(AbsolutePath, TopLevelModuleName)] -> SourceToModule
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
     ([(AbsolutePath, TopLevelModuleName)] -> SourceToModule)
-> (ModuleToSource -> [(AbsolutePath, TopLevelModuleName)])
-> ModuleToSource
-> SourceToModule
forall b c a. (b -> c) -> (a -> b) -> a -> c
.  ((TopLevelModuleName, AbsolutePath)
 -> (AbsolutePath, TopLevelModuleName))
-> [(TopLevelModuleName, AbsolutePath)]
-> [(AbsolutePath, TopLevelModuleName)]
forall a b. (a -> b) -> [a] -> [b]
List.map (\(TopLevelModuleName
m, AbsolutePath
f) -> (AbsolutePath
f, TopLevelModuleName
m))
     ([(TopLevelModuleName, AbsolutePath)]
 -> [(AbsolutePath, TopLevelModuleName)])
-> (ModuleToSource -> [(TopLevelModuleName, AbsolutePath)])
-> ModuleToSource
-> [(AbsolutePath, TopLevelModuleName)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.  ModuleToSource -> [(TopLevelModuleName, AbsolutePath)]
forall k a. Map k a -> [(k, a)]
Map.toList
    (ModuleToSource -> SourceToModule)
-> TCMT IO ModuleToSource -> TCM SourceToModule
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Lens' ModuleToSource TCState -> TCMT IO ModuleToSource
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useTC Lens' ModuleToSource TCState
stModuleToSource

-- | Lookup an 'AbsolutePath' in 'sourceToModule'.
--
--   O(n).

lookupModuleFromSource :: ReadTCState m => AbsolutePath -> m (Maybe TopLevelModuleName)
lookupModuleFromSource :: AbsolutePath -> m (Maybe TopLevelModuleName)
lookupModuleFromSource AbsolutePath
f =
  ((TopLevelModuleName, AbsolutePath) -> TopLevelModuleName)
-> Maybe (TopLevelModuleName, AbsolutePath)
-> Maybe TopLevelModuleName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TopLevelModuleName, AbsolutePath) -> TopLevelModuleName
forall a b. (a, b) -> a
fst (Maybe (TopLevelModuleName, AbsolutePath)
 -> Maybe TopLevelModuleName)
-> (ModuleToSource -> Maybe (TopLevelModuleName, AbsolutePath))
-> ModuleToSource
-> Maybe TopLevelModuleName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((TopLevelModuleName, AbsolutePath) -> Bool)
-> [(TopLevelModuleName, AbsolutePath)]
-> Maybe (TopLevelModuleName, AbsolutePath)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
List.find ((AbsolutePath
f AbsolutePath -> AbsolutePath -> Bool
forall a. Eq a => a -> a -> Bool
==) (AbsolutePath -> Bool)
-> ((TopLevelModuleName, AbsolutePath) -> AbsolutePath)
-> (TopLevelModuleName, AbsolutePath)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TopLevelModuleName, AbsolutePath) -> AbsolutePath
forall a b. (a, b) -> b
snd) ([(TopLevelModuleName, AbsolutePath)]
 -> Maybe (TopLevelModuleName, AbsolutePath))
-> (ModuleToSource -> [(TopLevelModuleName, AbsolutePath)])
-> ModuleToSource
-> Maybe (TopLevelModuleName, AbsolutePath)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleToSource -> [(TopLevelModuleName, AbsolutePath)]
forall k a. Map k a -> [(k, a)]
Map.toList (ModuleToSource -> Maybe TopLevelModuleName)
-> m ModuleToSource -> m (Maybe TopLevelModuleName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Lens' ModuleToSource TCState -> m ModuleToSource
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' ModuleToSource TCState
stModuleToSource


---------------------------------------------------------------------------
-- ** Associating concrete names to an abstract name
---------------------------------------------------------------------------

-- | A monad that has read and write access to the stConcreteNames
--   part of the TCState. Basically, this is a synonym for `MonadState
--   ConcreteNames m` (which cannot be used directly because of the
--   limitations of Haskell's typeclass system).
class Monad m => MonadStConcreteNames m where
  runStConcreteNames :: StateT ConcreteNames m a -> m a

  useConcreteNames :: m ConcreteNames
  useConcreteNames = StateT ConcreteNames m ConcreteNames -> m ConcreteNames
forall (m :: * -> *) a.
MonadStConcreteNames m =>
StateT ConcreteNames m a -> m a
runStConcreteNames StateT ConcreteNames m ConcreteNames
forall s (m :: * -> *). MonadState s m => m s
get

  modifyConcreteNames :: (ConcreteNames -> ConcreteNames) -> m ()
  modifyConcreteNames = StateT ConcreteNames m () -> m ()
forall (m :: * -> *) a.
MonadStConcreteNames m =>
StateT ConcreteNames m a -> m a
runStConcreteNames (StateT ConcreteNames m () -> m ())
-> ((ConcreteNames -> ConcreteNames) -> StateT ConcreteNames m ())
-> (ConcreteNames -> ConcreteNames)
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ConcreteNames -> ConcreteNames) -> StateT ConcreteNames m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify

instance MonadStConcreteNames TCM where
  runStConcreteNames :: StateT ConcreteNames TCM a -> TCM a
runStConcreteNames StateT ConcreteNames TCM a
m = Lens' ConcreteNames TCState
-> (ConcreteNames -> TCM (a, ConcreteNames)) -> TCM a
forall (m :: * -> *) a r.
MonadTCState m =>
Lens' a TCState -> (a -> m (r, a)) -> m r
stateTCLensM Lens' ConcreteNames TCState
stConcreteNames ((ConcreteNames -> TCM (a, ConcreteNames)) -> TCM a)
-> (ConcreteNames -> TCM (a, ConcreteNames)) -> TCM a
forall a b. (a -> b) -> a -> b
$ StateT ConcreteNames TCM a
-> ConcreteNames -> TCM (a, ConcreteNames)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT StateT ConcreteNames TCM a
m

instance MonadStConcreteNames m => MonadStConcreteNames (ReaderT r m) where
  runStConcreteNames :: StateT ConcreteNames (ReaderT r m) a -> ReaderT r m a
runStConcreteNames StateT ConcreteNames (ReaderT r m) a
m = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ StateT ConcreteNames m a -> m a
forall (m :: * -> *) a.
MonadStConcreteNames m =>
StateT ConcreteNames m a -> m a
runStConcreteNames (StateT ConcreteNames m a -> m a)
-> (r -> StateT ConcreteNames m a) -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ConcreteNames -> m (a, ConcreteNames)) -> StateT ConcreteNames m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT ((ConcreteNames -> m (a, ConcreteNames))
 -> StateT ConcreteNames m a)
-> (r -> ConcreteNames -> m (a, ConcreteNames))
-> r
-> StateT ConcreteNames m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ConcreteNames -> r -> m (a, ConcreteNames))
-> r -> ConcreteNames -> m (a, ConcreteNames)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((ConcreteNames -> r -> m (a, ConcreteNames))
 -> r -> ConcreteNames -> m (a, ConcreteNames))
-> (ConcreteNames -> r -> m (a, ConcreteNames))
-> r
-> ConcreteNames
-> m (a, ConcreteNames)
forall a b. (a -> b) -> a -> b
$ ReaderT r m (a, ConcreteNames) -> r -> m (a, ConcreteNames)
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (ReaderT r m (a, ConcreteNames) -> r -> m (a, ConcreteNames))
-> (ConcreteNames -> ReaderT r m (a, ConcreteNames))
-> ConcreteNames
-> r
-> m (a, ConcreteNames)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StateT ConcreteNames (ReaderT r m) a
-> ConcreteNames -> ReaderT r m (a, ConcreteNames)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT StateT ConcreteNames (ReaderT r m) a
m)

instance MonadStConcreteNames m => MonadStConcreteNames (StateT s m) where
  runStConcreteNames :: StateT ConcreteNames (StateT s m) a -> StateT s m a
runStConcreteNames StateT ConcreteNames (StateT s m) a
m = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
s -> StateT ConcreteNames m (a, s) -> m (a, s)
forall (m :: * -> *) a.
MonadStConcreteNames m =>
StateT ConcreteNames m a -> m a
runStConcreteNames (StateT ConcreteNames m (a, s) -> m (a, s))
-> StateT ConcreteNames m (a, s) -> m (a, s)
forall a b. (a -> b) -> a -> b
$ (ConcreteNames -> m ((a, s), ConcreteNames))
-> StateT ConcreteNames m (a, s)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT ((ConcreteNames -> m ((a, s), ConcreteNames))
 -> StateT ConcreteNames m (a, s))
-> (ConcreteNames -> m ((a, s), ConcreteNames))
-> StateT ConcreteNames m (a, s)
forall a b. (a -> b) -> a -> b
$ \ConcreteNames
ns -> do
    ((a
x,ConcreteNames
ns'),s
s') <- StateT s m (a, ConcreteNames) -> s -> m ((a, ConcreteNames), s)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (StateT ConcreteNames (StateT s m) a
-> ConcreteNames -> StateT s m (a, ConcreteNames)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT StateT ConcreteNames (StateT s m) a
m ConcreteNames
ns) s
s
    ((a, s), ConcreteNames) -> m ((a, s), ConcreteNames)
forall (m :: * -> *) a. Monad m => a -> m a
return ((a
x,s
s'),ConcreteNames
ns')

---------------------------------------------------------------------------
-- ** Interface
---------------------------------------------------------------------------

data ModuleInfo = ModuleInfo
  { ModuleInfo -> Interface
miInterface  :: Interface
  , ModuleInfo -> Bool
miWarnings   :: Bool
    -- ^ 'True' if warnings were encountered when the module was type
    -- checked.
  , ModuleInfo -> Bool
miPrimitive  :: Bool
    -- ^ 'True' if the module is a primitive module, which should always
    -- be importable.
  }

-- Note that the use of 'C.TopLevelModuleName' here is a potential
-- performance problem, because these names do not contain unique
-- identifiers.

type VisitedModules = Map C.TopLevelModuleName ModuleInfo
type DecodedModules = Map C.TopLevelModuleName Interface

data ForeignCode = ForeignCode Range String
  deriving Int -> ForeignCode -> ShowS
[ForeignCode] -> ShowS
ForeignCode -> String
(Int -> ForeignCode -> ShowS)
-> (ForeignCode -> String)
-> ([ForeignCode] -> ShowS)
-> Show ForeignCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ForeignCode] -> ShowS
$cshowList :: [ForeignCode] -> ShowS
show :: ForeignCode -> String
$cshow :: ForeignCode -> String
showsPrec :: Int -> ForeignCode -> ShowS
$cshowsPrec :: Int -> ForeignCode -> ShowS
Show

data Interface = Interface
  { Interface -> Word64
iSourceHash      :: Hash
    -- ^ Hash of the source code.
  , Interface -> Text
iSource          :: Text
    -- ^ The source code. The source code is stored so that the HTML
    -- and LaTeX backends can generate their output without having to
    -- re-read the (possibly out of date) source code.
  , Interface -> FileType
iFileType        :: FileType
    -- ^ Source file type, determined from the file extension
  , Interface -> [(ModuleName, Word64)]
iImportedModules :: [(ModuleName, Hash)]
    -- ^ Imported modules and their hashes.
  , Interface -> ModuleName
iModuleName      :: ModuleName
    -- ^ Module name of this interface.
  , Interface -> Map ModuleName Scope
iScope           :: Map ModuleName Scope
    -- ^ Scope defined by this module.
    --
    --   Andreas, AIM XX: Too avoid duplicate serialization, this field is
    --   not serialized, so if you deserialize an interface, @iScope@
    --   will be empty.
    --   But 'constructIScope' constructs 'iScope' from 'iInsideScope'.
  , Interface -> ScopeInfo
iInsideScope     :: ScopeInfo
    -- ^ Scope after we loaded this interface.
    --   Used in 'Agda.Interaction.BasicOps.AtTopLevel'
    --   and     'Agda.Interaction.CommandLine.interactionLoop'.
  , Interface -> Signature
iSignature       :: Signature
  , Interface -> DisplayForms
iDisplayForms    :: DisplayForms
    -- ^ Display forms added for imported identifiers.
  , Interface -> Map QName String
iUserWarnings    :: Map A.QName String
    -- ^ User warnings for imported identifiers
  , Interface -> Maybe String
iImportWarning   :: Maybe String
    -- ^ Whether this module should raise a warning when imported
  , Interface -> BuiltinThings (String, QName)
iBuiltin         :: BuiltinThings (String, QName)
  , Interface -> Map String [ForeignCode]
iForeignCode     :: Map BackendName [ForeignCode]
  , Interface -> CompressedFile
iHighlighting    :: HighlightingInfo
  , Interface -> [[String]]
iPragmaOptions   :: [OptionsPragma]
    -- ^ Pragma options set in the file.
  , Interface -> PragmaOptions
iOptionsUsed     :: PragmaOptions
    -- ^ Options/features used when checking the file (can be different
    --   from options set directly in the file).
  , Interface -> PatternSynDefns
iPatternSyns     :: A.PatternSynDefns
  , Interface -> [TCWarning]
iWarnings        :: [TCWarning]
  , Interface -> Set QName
iPartialDefs     :: Set QName
  }
  deriving Int -> Interface -> ShowS
[Interface] -> ShowS
Interface -> String
(Int -> Interface -> ShowS)
-> (Interface -> String)
-> ([Interface] -> ShowS)
-> Show Interface
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Interface] -> ShowS
$cshowList :: [Interface] -> ShowS
show :: Interface -> String
$cshow :: Interface -> String
showsPrec :: Int -> Interface -> ShowS
$cshowsPrec :: Int -> Interface -> ShowS
Show

instance Pretty Interface where
  pretty :: Interface -> Doc
pretty (Interface
            Word64
sourceH Text
source FileType
fileT [(ModuleName, Word64)]
importedM ModuleName
moduleN Map ModuleName Scope
scope ScopeInfo
insideS Signature
signature
            DisplayForms
display Map QName String
userwarn Maybe String
importwarn BuiltinThings (String, QName)
builtin Map String [ForeignCode]
foreignCode CompressedFile
highlighting [[String]]
pragmaO
            PragmaOptions
oUsed PatternSynDefns
patternS [TCWarning]
warnings Set QName
partialdefs) =

    Doc -> Int -> Doc -> Doc
hang Doc
"Interface" Int
2 (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ [Doc] -> Doc
vcat
      [ Doc
"source hash:"         Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc) -> (Word64 -> String) -> Word64 -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word64 -> String
forall a. Show a => a -> String
show) Word64
sourceH
      , Doc
"source:"              Doc -> Doc -> Doc
$$  Int -> Doc -> Doc
nest Int
2 (String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
source)
      , Doc
"file type:"           Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc) -> (FileType -> String) -> FileType -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileType -> String
forall a. Show a => a -> String
show) FileType
fileT
      , Doc
"imported modules:"    Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc)
-> ([(ModuleName, Word64)] -> String)
-> [(ModuleName, Word64)]
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(ModuleName, Word64)] -> String
forall a. Show a => a -> String
show) [(ModuleName, Word64)]
importedM
      , Doc
"module name:"         Doc -> Doc -> Doc
<+> ModuleName -> Doc
forall a. Pretty a => a -> Doc
pretty ModuleName
moduleN
      , Doc
"scope:"               Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc)
-> (Map ModuleName Scope -> String) -> Map ModuleName Scope -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map ModuleName Scope -> String
forall a. Show a => a -> String
show) Map ModuleName Scope
scope
      , Doc
"inside scope:"        Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc) -> (ScopeInfo -> String) -> ScopeInfo -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ScopeInfo -> String
forall a. Show a => a -> String
show) ScopeInfo
insideS
      , Doc
"signature:"           Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc) -> (Signature -> String) -> Signature -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Signature -> String
forall a. Show a => a -> String
show) Signature
signature
      , Doc
"display:"             Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc) -> (DisplayForms -> String) -> DisplayForms -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DisplayForms -> String
forall a. Show a => a -> String
show) DisplayForms
display
      , Doc
"user warnings:"       Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc)
-> (Map QName String -> String) -> Map QName String -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map QName String -> String
forall a. Show a => a -> String
show) Map QName String
userwarn
      , Doc
"import warning:"      Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc) -> (Maybe String -> String) -> Maybe String -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe String -> String
forall a. Show a => a -> String
show) Maybe String
importwarn
      , Doc
"builtin:"             Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc)
-> (BuiltinThings (String, QName) -> String)
-> BuiltinThings (String, QName)
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BuiltinThings (String, QName) -> String
forall a. Show a => a -> String
show) BuiltinThings (String, QName)
builtin
      , Doc
"Foreign code:"        Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc)
-> (Map String [ForeignCode] -> String)
-> Map String [ForeignCode]
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map String [ForeignCode] -> String
forall a. Show a => a -> String
show) Map String [ForeignCode]
foreignCode
      , Doc
"highlighting:"        Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc)
-> (CompressedFile -> String) -> CompressedFile -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CompressedFile -> String
forall a. Show a => a -> String
show) CompressedFile
highlighting
      , Doc
"pragma options:"      Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc) -> ([[String]] -> String) -> [[String]] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[String]] -> String
forall a. Show a => a -> String
show) [[String]]
pragmaO
      , Doc
"options used:"        Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc)
-> (PragmaOptions -> String) -> PragmaOptions -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PragmaOptions -> String
forall a. Show a => a -> String
show) PragmaOptions
oUsed
      , Doc
"pattern syns:"        Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc)
-> (PatternSynDefns -> String) -> PatternSynDefns -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PatternSynDefns -> String
forall a. Show a => a -> String
show) PatternSynDefns
patternS
      , Doc
"warnings:"            Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc) -> ([TCWarning] -> String) -> [TCWarning] -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TCWarning] -> String
forall a. Show a => a -> String
show) [TCWarning]
warnings
      , Doc
"partial definitions:" Doc -> Doc -> Doc
<+> (String -> Doc
forall a. Pretty a => a -> Doc
pretty (String -> Doc) -> (Set QName -> String) -> Set QName -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set QName -> String
forall a. Show a => a -> String
show) Set QName
partialdefs
      ]

-- | Combines the source hash and the (full) hashes of the imported modules.
iFullHash :: Interface -> Hash
iFullHash :: Interface -> Word64
iFullHash Interface
i = [Word64] -> Word64
combineHashes ([Word64] -> Word64) -> [Word64] -> Word64
forall a b. (a -> b) -> a -> b
$ Interface -> Word64
iSourceHash Interface
i Word64 -> [Word64] -> [Word64]
forall a. a -> [a] -> [a]
: ((ModuleName, Word64) -> Word64)
-> [(ModuleName, Word64)] -> [Word64]
forall a b. (a -> b) -> [a] -> [b]
List.map (ModuleName, Word64) -> Word64
forall a b. (a, b) -> b
snd (Interface -> [(ModuleName, Word64)]
iImportedModules Interface
i)

---------------------------------------------------------------------------
-- ** Closure
---------------------------------------------------------------------------

data Closure a = Closure
  { Closure a -> Signature
clSignature        :: Signature
  , Closure a -> TCEnv
clEnv              :: TCEnv
  , Closure a -> ScopeInfo
clScope            :: ScopeInfo
  , Closure a -> Map ModuleName CheckpointId
clModuleCheckpoints :: Map ModuleName CheckpointId
  , Closure a -> a
clValue            :: a
  }
    deriving (Typeable (Closure a)
DataType
Constr
Typeable (Closure a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Closure a -> c (Closure a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Closure a))
-> (Closure a -> Constr)
-> (Closure a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Closure a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Closure a)))
-> ((forall b. Data b => b -> b) -> Closure a -> Closure a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Closure a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Closure a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Closure a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Closure a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Closure a -> m (Closure a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Closure a -> m (Closure a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Closure a -> m (Closure a))
-> Data (Closure a)
Closure a -> DataType
Closure a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Closure a))
(forall b. Data b => b -> b) -> Closure a -> Closure a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Closure a -> c (Closure a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Closure a)
forall a. Data a => Typeable (Closure a)
forall a. Data a => Closure a -> DataType
forall a. Data a => Closure a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Closure a -> Closure a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Closure a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Closure a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Closure a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Closure a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Closure a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Closure a -> c (Closure a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Closure a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Closure a))
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) -> Closure a -> u
forall u. (forall d. Data d => d -> u) -> Closure a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Closure a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Closure a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Closure a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Closure a -> c (Closure a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Closure a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Closure a))
$cClosure :: Constr
$tClosure :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
gmapMp :: (forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
gmapM :: (forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Closure a -> m (Closure a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Closure a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Closure a -> u
gmapQ :: (forall d. Data d => d -> u) -> Closure a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Closure a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Closure a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Closure a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Closure a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Closure a -> r
gmapT :: (forall b. Data b => b -> b) -> Closure a -> Closure a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Closure a -> Closure a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Closure a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Closure a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Closure a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Closure a))
dataTypeOf :: Closure a -> DataType
$cdataTypeOf :: forall a. Data a => Closure a -> DataType
toConstr :: Closure a -> Constr
$ctoConstr :: forall a. Data a => Closure a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Closure a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Closure a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Closure a -> c (Closure a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Closure a -> c (Closure a)
$cp1Data :: forall a. Data a => Typeable (Closure a)
Data, a -> Closure b -> Closure a
(a -> b) -> Closure a -> Closure b
(forall a b. (a -> b) -> Closure a -> Closure b)
-> (forall a b. a -> Closure b -> Closure a) -> Functor Closure
forall a b. a -> Closure b -> Closure a
forall a b. (a -> b) -> Closure a -> Closure b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Closure b -> Closure a
$c<$ :: forall a b. a -> Closure b -> Closure a
fmap :: (a -> b) -> Closure a -> Closure b
$cfmap :: forall a b. (a -> b) -> Closure a -> Closure b
Functor, Closure a -> Bool
(a -> m) -> Closure a -> m
(a -> b -> b) -> b -> Closure a -> b
(forall m. Monoid m => Closure m -> m)
-> (forall m a. Monoid m => (a -> m) -> Closure a -> m)
-> (forall m a. Monoid m => (a -> m) -> Closure a -> m)
-> (forall a b. (a -> b -> b) -> b -> Closure a -> b)
-> (forall a b. (a -> b -> b) -> b -> Closure a -> b)
-> (forall b a. (b -> a -> b) -> b -> Closure a -> b)
-> (forall b a. (b -> a -> b) -> b -> Closure a -> b)
-> (forall a. (a -> a -> a) -> Closure a -> a)
-> (forall a. (a -> a -> a) -> Closure a -> a)
-> (forall a. Closure a -> [a])
-> (forall a. Closure a -> Bool)
-> (forall a. Closure a -> Int)
-> (forall a. Eq a => a -> Closure a -> Bool)
-> (forall a. Ord a => Closure a -> a)
-> (forall a. Ord a => Closure a -> a)
-> (forall a. Num a => Closure a -> a)
-> (forall a. Num a => Closure a -> a)
-> Foldable Closure
forall a. Eq a => a -> Closure a -> Bool
forall a. Num a => Closure a -> a
forall a. Ord a => Closure a -> a
forall m. Monoid m => Closure m -> m
forall a. Closure a -> Bool
forall a. Closure a -> Int
forall a. Closure a -> [a]
forall a. (a -> a -> a) -> Closure a -> a
forall m a. Monoid m => (a -> m) -> Closure a -> m
forall b a. (b -> a -> b) -> b -> Closure a -> b
forall a b. (a -> b -> b) -> b -> Closure 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 :: Closure a -> a
$cproduct :: forall a. Num a => Closure a -> a
sum :: Closure a -> a
$csum :: forall a. Num a => Closure a -> a
minimum :: Closure a -> a
$cminimum :: forall a. Ord a => Closure a -> a
maximum :: Closure a -> a
$cmaximum :: forall a. Ord a => Closure a -> a
elem :: a -> Closure a -> Bool
$celem :: forall a. Eq a => a -> Closure a -> Bool
length :: Closure a -> Int
$clength :: forall a. Closure a -> Int
null :: Closure a -> Bool
$cnull :: forall a. Closure a -> Bool
toList :: Closure a -> [a]
$ctoList :: forall a. Closure a -> [a]
foldl1 :: (a -> a -> a) -> Closure a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Closure a -> a
foldr1 :: (a -> a -> a) -> Closure a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Closure a -> a
foldl' :: (b -> a -> b) -> b -> Closure a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Closure a -> b
foldl :: (b -> a -> b) -> b -> Closure a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Closure a -> b
foldr' :: (a -> b -> b) -> b -> Closure a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Closure a -> b
foldr :: (a -> b -> b) -> b -> Closure a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Closure a -> b
foldMap' :: (a -> m) -> Closure a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Closure a -> m
foldMap :: (a -> m) -> Closure a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Closure a -> m
fold :: Closure m -> m
$cfold :: forall m. Monoid m => Closure m -> m
Foldable)

instance Show a => Show (Closure a) where
  show :: Closure a -> String
show Closure a
cl = String
"Closure { clValue = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ a -> String
forall a. Show a => a -> String
show (Closure a -> a
forall a. Closure a -> a
clValue Closure a
cl) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" }"

instance HasRange a => HasRange (Closure a) where
  getRange :: Closure a -> Range
getRange = a -> Range
forall t. HasRange t => t -> Range
getRange (a -> Range) -> (Closure a -> a) -> Closure a -> Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Closure a -> a
forall a. Closure a -> a
clValue

class LensClosure a b | b -> a where
  lensClosure :: Lens' (Closure a) b

instance LensClosure a (Closure a) where
  lensClosure :: (Closure a -> f (Closure a)) -> Closure a -> f (Closure a)
lensClosure = (Closure a -> f (Closure a)) -> Closure a -> f (Closure a)
forall a. a -> a
id

instance LensTCEnv (Closure a) where
  lensTCEnv :: (TCEnv -> f TCEnv) -> Closure a -> f (Closure a)
lensTCEnv TCEnv -> f TCEnv
f Closure a
cl = (TCEnv -> f TCEnv
f (TCEnv -> f TCEnv) -> TCEnv -> f TCEnv
forall a b. (a -> b) -> a -> b
$! Closure a -> TCEnv
forall a. Closure a -> TCEnv
clEnv Closure a
cl) f TCEnv -> (TCEnv -> Closure a) -> f (Closure a)
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ TCEnv
env -> Closure a
cl { clEnv :: TCEnv
clEnv = TCEnv
env }

buildClosure :: (MonadTCEnv m, ReadTCState m) => a -> m (Closure a)
buildClosure :: a -> m (Closure a)
buildClosure a
x = do
    TCEnv
env   <- m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
    Signature
sig   <- Lens' Signature TCState -> m Signature
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' Signature TCState
stSignature
    ScopeInfo
scope <- Lens' ScopeInfo TCState -> m ScopeInfo
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' ScopeInfo TCState
stScope
    Map ModuleName CheckpointId
cps   <- Lens' (Map ModuleName CheckpointId) TCState
-> m (Map ModuleName CheckpointId)
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' (Map ModuleName CheckpointId) TCState
stModuleCheckpoints
    Closure a -> m (Closure a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Closure a -> m (Closure a)) -> Closure a -> m (Closure a)
forall a b. (a -> b) -> a -> b
$ Signature
-> TCEnv
-> ScopeInfo
-> Map ModuleName CheckpointId
-> a
-> Closure a
forall a.
Signature
-> TCEnv
-> ScopeInfo
-> Map ModuleName CheckpointId
-> a
-> Closure a
Closure Signature
sig TCEnv
env ScopeInfo
scope Map ModuleName CheckpointId
cps a
x

---------------------------------------------------------------------------
-- ** Constraints
---------------------------------------------------------------------------

type Constraints = [ProblemConstraint]

data ProblemConstraint = PConstr
  { ProblemConstraint -> Set ProblemId
constraintProblems :: Set ProblemId
  , ProblemConstraint -> Closure Constraint
theConstraint      :: Closure Constraint
  }
  deriving (Typeable ProblemConstraint
DataType
Constr
Typeable ProblemConstraint
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> ProblemConstraint
    -> c ProblemConstraint)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ProblemConstraint)
-> (ProblemConstraint -> Constr)
-> (ProblemConstraint -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ProblemConstraint))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ProblemConstraint))
-> ((forall b. Data b => b -> b)
    -> ProblemConstraint -> ProblemConstraint)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ProblemConstraint -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ProblemConstraint -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> ProblemConstraint -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ProblemConstraint -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> ProblemConstraint -> m ProblemConstraint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ProblemConstraint -> m ProblemConstraint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ProblemConstraint -> m ProblemConstraint)
-> Data ProblemConstraint
ProblemConstraint -> DataType
ProblemConstraint -> Constr
(forall b. Data b => b -> b)
-> ProblemConstraint -> ProblemConstraint
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProblemConstraint -> c ProblemConstraint
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProblemConstraint
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) -> ProblemConstraint -> u
forall u. (forall d. Data d => d -> u) -> ProblemConstraint -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemConstraint -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemConstraint -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ProblemConstraint -> m ProblemConstraint
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ProblemConstraint -> m ProblemConstraint
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProblemConstraint
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProblemConstraint -> c ProblemConstraint
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ProblemConstraint)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ProblemConstraint)
$cPConstr :: Constr
$tProblemConstraint :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> ProblemConstraint -> m ProblemConstraint
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ProblemConstraint -> m ProblemConstraint
gmapMp :: (forall d. Data d => d -> m d)
-> ProblemConstraint -> m ProblemConstraint
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ProblemConstraint -> m ProblemConstraint
gmapM :: (forall d. Data d => d -> m d)
-> ProblemConstraint -> m ProblemConstraint
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ProblemConstraint -> m ProblemConstraint
gmapQi :: Int -> (forall d. Data d => d -> u) -> ProblemConstraint -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ProblemConstraint -> u
gmapQ :: (forall d. Data d => d -> u) -> ProblemConstraint -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ProblemConstraint -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemConstraint -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemConstraint -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemConstraint -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ProblemConstraint -> r
gmapT :: (forall b. Data b => b -> b)
-> ProblemConstraint -> ProblemConstraint
$cgmapT :: (forall b. Data b => b -> b)
-> ProblemConstraint -> ProblemConstraint
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ProblemConstraint)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ProblemConstraint)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ProblemConstraint)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ProblemConstraint)
dataTypeOf :: ProblemConstraint -> DataType
$cdataTypeOf :: ProblemConstraint -> DataType
toConstr :: ProblemConstraint -> Constr
$ctoConstr :: ProblemConstraint -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProblemConstraint
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProblemConstraint
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProblemConstraint -> c ProblemConstraint
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProblemConstraint -> c ProblemConstraint
$cp1Data :: Typeable ProblemConstraint
Data, Int -> ProblemConstraint -> ShowS
Constraints -> ShowS
ProblemConstraint -> String
(Int -> ProblemConstraint -> ShowS)
-> (ProblemConstraint -> String)
-> (Constraints -> ShowS)
-> Show ProblemConstraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: Constraints -> ShowS
$cshowList :: Constraints -> ShowS
show :: ProblemConstraint -> String
$cshow :: ProblemConstraint -> String
showsPrec :: Int -> ProblemConstraint -> ShowS
$cshowsPrec :: Int -> ProblemConstraint -> ShowS
Show)

instance HasRange ProblemConstraint where
  getRange :: ProblemConstraint -> Range
getRange = Closure Constraint -> Range
forall t. HasRange t => t -> Range
getRange (Closure Constraint -> Range)
-> (ProblemConstraint -> Closure Constraint)
-> ProblemConstraint
-> Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ProblemConstraint -> Closure Constraint
theConstraint

data Constraint
  = ValueCmp Comparison CompareAs Term Term
  | ValueCmpOnFace Comparison Term Type Term Term
  | ElimCmp [Polarity] [IsForced] Type Term [Elim] [Elim]
  | TelCmp Type Type Comparison Telescope Telescope -- ^ the two types are for the error message only
  | SortCmp Comparison Sort Sort
  | LevelCmp Comparison Level Level
--  | ShortCut MetaId Term Type
--    -- ^ A delayed instantiation.  Replaces @ValueCmp@ in 'postponeTypeCheckingProblem'.
  | HasBiggerSort Sort
  | HasPTSRule (Dom Type) (Abs Sort)
  | CheckMetaInst MetaId
  | UnBlock MetaId
  | Guarded Constraint ProblemId
  | IsEmpty Range Type
    -- ^ The range is the one of the absurd pattern.
  | CheckSizeLtSat Term
    -- ^ Check that the 'Term' is either not a SIZELT or a non-empty SIZELT.
  | FindInstance MetaId (Maybe MetaId) (Maybe [Candidate])
    -- ^ the first argument is the instance argument, the second one is the meta
    --   on which the constraint may be blocked on and the third one is the list
    --   of candidates (or Nothing if we haven’t determined the list of
    --   candidates yet)
  | CheckFunDef Delayed A.DefInfo QName [A.Clause]
  | UnquoteTactic (Maybe MetaId) Term Term Type   -- ^ First argument is computation and the others are hole and goal type
  deriving (Typeable Constraint
DataType
Constr
Typeable Constraint
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Constraint -> c Constraint)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Constraint)
-> (Constraint -> Constr)
-> (Constraint -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Constraint))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Constraint))
-> ((forall b. Data b => b -> b) -> Constraint -> Constraint)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Constraint -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Constraint -> r)
-> (forall u. (forall d. Data d => d -> u) -> Constraint -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Constraint -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Constraint -> m Constraint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Constraint -> m Constraint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Constraint -> m Constraint)
-> Data Constraint
Constraint -> DataType
Constraint -> Constr
(forall b. Data b => b -> b) -> Constraint -> Constraint
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Constraint -> c Constraint
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Constraint
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) -> Constraint -> u
forall u. (forall d. Data d => d -> u) -> Constraint -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Constraint -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Constraint -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Constraint -> m Constraint
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Constraint -> m Constraint
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Constraint
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Constraint -> c Constraint
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Constraint)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Constraint)
$cUnquoteTactic :: Constr
$cCheckFunDef :: Constr
$cFindInstance :: Constr
$cCheckSizeLtSat :: Constr
$cIsEmpty :: Constr
$cGuarded :: Constr
$cUnBlock :: Constr
$cCheckMetaInst :: Constr
$cHasPTSRule :: Constr
$cHasBiggerSort :: Constr
$cLevelCmp :: Constr
$cSortCmp :: Constr
$cTelCmp :: Constr
$cElimCmp :: Constr
$cValueCmpOnFace :: Constr
$cValueCmp :: Constr
$tConstraint :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Constraint -> m Constraint
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Constraint -> m Constraint
gmapMp :: (forall d. Data d => d -> m d) -> Constraint -> m Constraint
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Constraint -> m Constraint
gmapM :: (forall d. Data d => d -> m d) -> Constraint -> m Constraint
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Constraint -> m Constraint
gmapQi :: Int -> (forall d. Data d => d -> u) -> Constraint -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Constraint -> u
gmapQ :: (forall d. Data d => d -> u) -> Constraint -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Constraint -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Constraint -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Constraint -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Constraint -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Constraint -> r
gmapT :: (forall b. Data b => b -> b) -> Constraint -> Constraint
$cgmapT :: (forall b. Data b => b -> b) -> Constraint -> Constraint
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Constraint)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Constraint)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Constraint)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Constraint)
dataTypeOf :: Constraint -> DataType
$cdataTypeOf :: Constraint -> DataType
toConstr :: Constraint -> Constr
$ctoConstr :: Constraint -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Constraint
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Constraint
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Constraint -> c Constraint
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Constraint -> c Constraint
$cp1Data :: Typeable Constraint
Data, Int -> Constraint -> ShowS
[Constraint] -> ShowS
Constraint -> String
(Int -> Constraint -> ShowS)
-> (Constraint -> String)
-> ([Constraint] -> ShowS)
-> Show Constraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Constraint] -> ShowS
$cshowList :: [Constraint] -> ShowS
show :: Constraint -> String
$cshow :: Constraint -> String
showsPrec :: Int -> Constraint -> ShowS
$cshowsPrec :: Int -> Constraint -> ShowS
Show)

instance HasRange Constraint where
  getRange :: Constraint -> Range
getRange (IsEmpty Range
r Type
t) = Range
r
  getRange Constraint
_ = Range
forall a. Range' a
noRange
{- no Range instances for Term, Type, Elm, Tele, Sort, Level, MetaId
  getRange (ValueCmp cmp a u v) = getRange (a,u,v)
  getRange (ElimCmp pol a v es es') = getRange (a,v,es,es')
  getRange (TelCmp a b cmp tel tel') = getRange (a,b,tel,tel')
  getRange (SortCmp cmp s s') = getRange (s,s')
  getRange (LevelCmp cmp l l') = getRange (l,l')
  getRange (UnBlock x) = getRange x
  getRange (Guarded c pid) = getRange c
  getRange (FindInstance x cands) = getRange x
-}

instance Free Constraint where
  freeVars' :: Constraint -> FreeM a c
freeVars' Constraint
c =
    case Constraint
c of
      ValueCmp Comparison
_ CompareAs
t Term
u Term
v      -> (CompareAs, (Term, Term)) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (CompareAs
t, (Term
u, Term
v))
      ValueCmpOnFace Comparison
_ Term
p Type
t Term
u Term
v -> (Term, (Type, (Term, Term))) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Term
p, (Type
t, (Term
u, Term
v)))
      ElimCmp [Polarity]
_ [IsForced]
_ Type
t Term
u [Elim]
es [Elim]
es'  -> ((Type, Term), ([Elim], [Elim])) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' ((Type
t, Term
u), ([Elim]
es, [Elim]
es'))
      TelCmp Type
_ Type
_ Comparison
_ Telescope
tel Telescope
tel' -> (Telescope, Telescope) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Telescope
tel, Telescope
tel')
      SortCmp Comparison
_ Sort
s Sort
s'        -> (Sort, Sort) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Sort
s, Sort
s')
      LevelCmp Comparison
_ Level
l Level
l'       -> (Level, Level) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Level
l, Level
l')
      UnBlock MetaId
_             -> FreeM a c
forall a. Monoid a => a
mempty
      Guarded Constraint
c ProblemId
_           -> Constraint -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Constraint
c
      IsEmpty Range
_ Type
t           -> Type -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Type
t
      CheckSizeLtSat Term
u      -> Term -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Term
u
      FindInstance MetaId
_ Maybe MetaId
_ Maybe [Candidate]
cs   -> Maybe [Candidate] -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Maybe [Candidate]
cs
      CheckFunDef Delayed
_ DefInfo
_ QName
_ [Clause]
_   -> FreeM a c
forall a. Monoid a => a
mempty
      HasBiggerSort Sort
s       -> Sort -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Sort
s
      HasPTSRule Dom Type
a Abs Sort
s        -> (Dom Type, Abs Sort) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Dom Type
a , Abs Sort
s)
      UnquoteTactic Maybe MetaId
_ Term
t Term
h Type
g -> (Term, (Term, Type)) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Term
t, (Term
h, Type
g))
      CheckMetaInst MetaId
m       -> FreeM a c
forall a. Monoid a => a
mempty

instance TermLike Constraint where
  foldTerm :: (Term -> m) -> Constraint -> m
foldTerm Term -> m
f = \case
      ValueCmp Comparison
_ CompareAs
t Term
u Term
v       -> (Term -> m) -> (CompareAs, Term, Term) -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f (CompareAs
t, Term
u, Term
v)
      ValueCmpOnFace Comparison
_ Term
p Type
t Term
u Term
v -> (Term -> m) -> (Term, Type, Term, Term) -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f (Term
p, Type
t, Term
u, Term
v)
      ElimCmp [Polarity]
_ [IsForced]
_ Type
t Term
u [Elim]
es [Elim]
es' -> (Term -> m) -> (Type, Term, [Elim], [Elim]) -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f (Type
t, Term
u, [Elim]
es, [Elim]
es')
      LevelCmp Comparison
_ Level
l Level
l'        -> (Term -> m) -> (Term, Term) -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f (Level -> Term
Level Level
l, Level -> Term
Level Level
l')
      IsEmpty Range
_ Type
t            -> (Term -> m) -> Type -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f Type
t
      CheckSizeLtSat Term
u       -> (Term -> m) -> Term -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f Term
u
      UnquoteTactic Maybe MetaId
_ Term
t Term
h Type
g  -> (Term -> m) -> (Term, Term, Type) -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f (Term
t, Term
h, Type
g)
      Guarded Constraint
c ProblemId
_            -> (Term -> m) -> Constraint -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f Constraint
c
      TelCmp Type
_ Type
_ Comparison
_ Telescope
tel1 Telescope
tel2 -> (Term -> m) -> (Telescope, Telescope) -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f (Telescope
tel1, Telescope
tel2)
      SortCmp Comparison
_ Sort
s1 Sort
s2        -> (Term -> m) -> (Term, Term) -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f (Sort -> Term
Sort Sort
s1, Sort -> Term
Sort Sort
s2)
      UnBlock MetaId
_              -> m
forall a. Monoid a => a
mempty
      FindInstance MetaId
_ Maybe MetaId
_ Maybe [Candidate]
_     -> m
forall a. Monoid a => a
mempty
      CheckFunDef Delayed
_ DefInfo
_ QName
_ [Clause]
_    -> m
forall a. Monoid a => a
mempty
      HasBiggerSort Sort
s        -> (Term -> m) -> Sort -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f Sort
s
      HasPTSRule Dom Type
a Abs Sort
s         -> (Term -> m) -> (Dom Type, Abs Term) -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f (Dom Type
a, Sort -> Term
Sort (Sort -> Term) -> Abs Sort -> Abs Term
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Abs Sort
s)
      CheckMetaInst MetaId
m        -> m
forall a. Monoid a => a
mempty
  traverseTermM :: (Term -> m Term) -> Constraint -> m Constraint
traverseTermM Term -> m Term
f Constraint
c = m Constraint
forall a. HasCallStack => a
__IMPOSSIBLE__ -- Not yet implemented


data Comparison = CmpEq | CmpLeq
  deriving (Comparison -> Comparison -> Bool
(Comparison -> Comparison -> Bool)
-> (Comparison -> Comparison -> Bool) -> Eq Comparison
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Comparison -> Comparison -> Bool
$c/= :: Comparison -> Comparison -> Bool
== :: Comparison -> Comparison -> Bool
$c== :: Comparison -> Comparison -> Bool
Eq, Typeable Comparison
DataType
Constr
Typeable Comparison
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Comparison -> c Comparison)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Comparison)
-> (Comparison -> Constr)
-> (Comparison -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Comparison))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Comparison))
-> ((forall b. Data b => b -> b) -> Comparison -> Comparison)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Comparison -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Comparison -> r)
-> (forall u. (forall d. Data d => d -> u) -> Comparison -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Comparison -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Comparison -> m Comparison)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Comparison -> m Comparison)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Comparison -> m Comparison)
-> Data Comparison
Comparison -> DataType
Comparison -> Constr
(forall b. Data b => b -> b) -> Comparison -> Comparison
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Comparison -> c Comparison
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Comparison
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) -> Comparison -> u
forall u. (forall d. Data d => d -> u) -> Comparison -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Comparison -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Comparison -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Comparison -> m Comparison
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Comparison -> m Comparison
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Comparison
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Comparison -> c Comparison
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Comparison)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Comparison)
$cCmpLeq :: Constr
$cCmpEq :: Constr
$tComparison :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Comparison -> m Comparison
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Comparison -> m Comparison
gmapMp :: (forall d. Data d => d -> m d) -> Comparison -> m Comparison
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Comparison -> m Comparison
gmapM :: (forall d. Data d => d -> m d) -> Comparison -> m Comparison
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Comparison -> m Comparison
gmapQi :: Int -> (forall d. Data d => d -> u) -> Comparison -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Comparison -> u
gmapQ :: (forall d. Data d => d -> u) -> Comparison -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Comparison -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Comparison -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Comparison -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Comparison -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Comparison -> r
gmapT :: (forall b. Data b => b -> b) -> Comparison -> Comparison
$cgmapT :: (forall b. Data b => b -> b) -> Comparison -> Comparison
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Comparison)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Comparison)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Comparison)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Comparison)
dataTypeOf :: Comparison -> DataType
$cdataTypeOf :: Comparison -> DataType
toConstr :: Comparison -> Constr
$ctoConstr :: Comparison -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Comparison
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Comparison
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Comparison -> c Comparison
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Comparison -> c Comparison
$cp1Data :: Typeable Comparison
Data, Int -> Comparison -> ShowS
[Comparison] -> ShowS
Comparison -> String
(Int -> Comparison -> ShowS)
-> (Comparison -> String)
-> ([Comparison] -> ShowS)
-> Show Comparison
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Comparison] -> ShowS
$cshowList :: [Comparison] -> ShowS
show :: Comparison -> String
$cshow :: Comparison -> String
showsPrec :: Int -> Comparison -> ShowS
$cshowsPrec :: Int -> Comparison -> ShowS
Show)

instance Pretty Comparison where
  pretty :: Comparison -> Doc
pretty Comparison
CmpEq  = Doc
"="
  pretty Comparison
CmpLeq = Doc
"=<"

-- | An extension of 'Comparison' to @>=@.
data CompareDirection = DirEq | DirLeq | DirGeq
  deriving (CompareDirection -> CompareDirection -> Bool
(CompareDirection -> CompareDirection -> Bool)
-> (CompareDirection -> CompareDirection -> Bool)
-> Eq CompareDirection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompareDirection -> CompareDirection -> Bool
$c/= :: CompareDirection -> CompareDirection -> Bool
== :: CompareDirection -> CompareDirection -> Bool
$c== :: CompareDirection -> CompareDirection -> Bool
Eq, Int -> CompareDirection -> ShowS
[CompareDirection] -> ShowS
CompareDirection -> String
(Int -> CompareDirection -> ShowS)
-> (CompareDirection -> String)
-> ([CompareDirection] -> ShowS)
-> Show CompareDirection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompareDirection] -> ShowS
$cshowList :: [CompareDirection] -> ShowS
show :: CompareDirection -> String
$cshow :: CompareDirection -> String
showsPrec :: Int -> CompareDirection -> ShowS
$cshowsPrec :: Int -> CompareDirection -> ShowS
Show)

instance Pretty CompareDirection where
  pretty :: CompareDirection -> Doc
pretty = String -> Doc
text (String -> Doc)
-> (CompareDirection -> String) -> CompareDirection -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
    CompareDirection
DirEq  -> String
"="
    CompareDirection
DirLeq -> String
"=<"
    CompareDirection
DirGeq -> String
">="

-- | Embed 'Comparison' into 'CompareDirection'.
fromCmp :: Comparison -> CompareDirection
fromCmp :: Comparison -> CompareDirection
fromCmp Comparison
CmpEq  = CompareDirection
DirEq
fromCmp Comparison
CmpLeq = CompareDirection
DirLeq

-- | Flip the direction of comparison.
flipCmp :: CompareDirection -> CompareDirection
flipCmp :: CompareDirection -> CompareDirection
flipCmp CompareDirection
DirEq  = CompareDirection
DirEq
flipCmp CompareDirection
DirLeq = CompareDirection
DirGeq
flipCmp CompareDirection
DirGeq = CompareDirection
DirLeq

-- | Turn a 'Comparison' function into a 'CompareDirection' function.
--
--   Property: @dirToCmp f (fromCmp cmp) = f cmp@
dirToCmp :: (Comparison -> a -> a -> c) -> CompareDirection -> a -> a -> c
dirToCmp :: (Comparison -> a -> a -> c) -> CompareDirection -> a -> a -> c
dirToCmp Comparison -> a -> a -> c
cont CompareDirection
DirEq  = Comparison -> a -> a -> c
cont Comparison
CmpEq
dirToCmp Comparison -> a -> a -> c
cont CompareDirection
DirLeq = Comparison -> a -> a -> c
cont Comparison
CmpLeq
dirToCmp Comparison -> a -> a -> c
cont CompareDirection
DirGeq = (a -> a -> c) -> a -> a -> c
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((a -> a -> c) -> a -> a -> c) -> (a -> a -> c) -> a -> a -> c
forall a b. (a -> b) -> a -> b
$ Comparison -> a -> a -> c
cont Comparison
CmpLeq

-- | We can either compare two terms at a given type, or compare two
--   types without knowing (or caring about) their sorts.
data CompareAs
  = AsTermsOf Type -- ^ @Type@ should not be @Size@.
                   --   But currently, we do not rely on this invariant.
  | AsSizes        -- ^ Replaces @AsTermsOf Size@.
  | AsTypes
  deriving (Typeable CompareAs
DataType
Constr
Typeable CompareAs
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CompareAs -> c CompareAs)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CompareAs)
-> (CompareAs -> Constr)
-> (CompareAs -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CompareAs))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CompareAs))
-> ((forall b. Data b => b -> b) -> CompareAs -> CompareAs)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CompareAs -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CompareAs -> r)
-> (forall u. (forall d. Data d => d -> u) -> CompareAs -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CompareAs -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CompareAs -> m CompareAs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CompareAs -> m CompareAs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CompareAs -> m CompareAs)
-> Data CompareAs
CompareAs -> DataType
CompareAs -> Constr
(forall b. Data b => b -> b) -> CompareAs -> CompareAs
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompareAs -> c CompareAs
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompareAs
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) -> CompareAs -> u
forall u. (forall d. Data d => d -> u) -> CompareAs -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CompareAs -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CompareAs -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CompareAs -> m CompareAs
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CompareAs -> m CompareAs
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompareAs
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompareAs -> c CompareAs
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CompareAs)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CompareAs)
$cAsTypes :: Constr
$cAsSizes :: Constr
$cAsTermsOf :: Constr
$tCompareAs :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> CompareAs -> m CompareAs
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CompareAs -> m CompareAs
gmapMp :: (forall d. Data d => d -> m d) -> CompareAs -> m CompareAs
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CompareAs -> m CompareAs
gmapM :: (forall d. Data d => d -> m d) -> CompareAs -> m CompareAs
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CompareAs -> m CompareAs
gmapQi :: Int -> (forall d. Data d => d -> u) -> CompareAs -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CompareAs -> u
gmapQ :: (forall d. Data d => d -> u) -> CompareAs -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CompareAs -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CompareAs -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CompareAs -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CompareAs -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CompareAs -> r
gmapT :: (forall b. Data b => b -> b) -> CompareAs -> CompareAs
$cgmapT :: (forall b. Data b => b -> b) -> CompareAs -> CompareAs
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CompareAs)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CompareAs)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CompareAs)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CompareAs)
dataTypeOf :: CompareAs -> DataType
$cdataTypeOf :: CompareAs -> DataType
toConstr :: CompareAs -> Constr
$ctoConstr :: CompareAs -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompareAs
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompareAs
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompareAs -> c CompareAs
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompareAs -> c CompareAs
$cp1Data :: Typeable CompareAs
Data, Int -> CompareAs -> ShowS
[CompareAs] -> ShowS
CompareAs -> String
(Int -> CompareAs -> ShowS)
-> (CompareAs -> String)
-> ([CompareAs] -> ShowS)
-> Show CompareAs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompareAs] -> ShowS
$cshowList :: [CompareAs] -> ShowS
show :: CompareAs -> String
$cshow :: CompareAs -> String
showsPrec :: Int -> CompareAs -> ShowS
$cshowsPrec :: Int -> CompareAs -> ShowS
Show)

instance Free CompareAs where
  freeVars' :: CompareAs -> FreeM a c
freeVars' (AsTermsOf Type
a) = Type -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Type
a
  freeVars' CompareAs
AsSizes       = FreeM a c
forall a. Monoid a => a
mempty
  freeVars' CompareAs
AsTypes       = FreeM a c
forall a. Monoid a => a
mempty

instance TermLike CompareAs where
  foldTerm :: (Term -> m) -> CompareAs -> m
foldTerm Term -> m
f (AsTermsOf Type
a) = (Term -> m) -> Type -> m
forall a m. (TermLike a, Monoid m) => (Term -> m) -> a -> m
foldTerm Term -> m
f Type
a
  foldTerm Term -> m
f CompareAs
AsSizes       = m
forall a. Monoid a => a
mempty
  foldTerm Term -> m
f CompareAs
AsTypes       = m
forall a. Monoid a => a
mempty

  traverseTermM :: (Term -> m Term) -> CompareAs -> m CompareAs
traverseTermM Term -> m Term
f = \case
    AsTermsOf Type
a -> Type -> CompareAs
AsTermsOf (Type -> CompareAs) -> m Type -> m CompareAs
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Term -> m Term) -> Type -> m Type
forall a (m :: * -> *).
(TermLike a, Monad m) =>
(Term -> m Term) -> a -> m a
traverseTermM Term -> m Term
f Type
a
    CompareAs
AsSizes     -> CompareAs -> m CompareAs
forall (m :: * -> *) a. Monad m => a -> m a
return CompareAs
AsSizes
    CompareAs
AsTypes     -> CompareAs -> m CompareAs
forall (m :: * -> *) a. Monad m => a -> m a
return CompareAs
AsTypes

---------------------------------------------------------------------------
-- * Open things
---------------------------------------------------------------------------

-- | A thing tagged with the context it came from.
data Open a = OpenThing { Open a -> CheckpointId
openThingCheckpoint :: CheckpointId, Open a -> a
openThing :: a }
    deriving (Typeable (Open a)
DataType
Constr
Typeable (Open a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Open a -> c (Open a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Open a))
-> (Open a -> Constr)
-> (Open a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Open a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Open a)))
-> ((forall b. Data b => b -> b) -> Open a -> Open a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Open a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Open a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Open a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Open a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Open a -> m (Open a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Open a -> m (Open a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Open a -> m (Open a))
-> Data (Open a)
Open a -> DataType
Open a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Open a))
(forall b. Data b => b -> b) -> Open a -> Open a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Open a -> c (Open a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Open a)
forall a. Data a => Typeable (Open a)
forall a. Data a => Open a -> DataType
forall a. Data a => Open a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Open a -> Open a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Open a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Open a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Open a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Open a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Open a -> m (Open a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Open a -> m (Open a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Open a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Open a -> c (Open a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Open a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Open a))
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) -> Open a -> u
forall u. (forall d. Data d => d -> u) -> Open a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Open a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Open a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Open a -> m (Open a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Open a -> m (Open a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Open a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Open a -> c (Open a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Open a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Open a))
$cOpenThing :: Constr
$tOpen :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Open a -> m (Open a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Open a -> m (Open a)
gmapMp :: (forall d. Data d => d -> m d) -> Open a -> m (Open a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Open a -> m (Open a)
gmapM :: (forall d. Data d => d -> m d) -> Open a -> m (Open a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Open a -> m (Open a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Open a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Open a -> u
gmapQ :: (forall d. Data d => d -> u) -> Open a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Open a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Open a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Open a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Open a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Open a -> r
gmapT :: (forall b. Data b => b -> b) -> Open a -> Open a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Open a -> Open a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Open a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Open a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Open a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Open a))
dataTypeOf :: Open a -> DataType
$cdataTypeOf :: forall a. Data a => Open a -> DataType
toConstr :: Open a -> Constr
$ctoConstr :: forall a. Data a => Open a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Open a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Open a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Open a -> c (Open a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Open a -> c (Open a)
$cp1Data :: forall a. Data a => Typeable (Open a)
Data, Int -> Open a -> ShowS
[Open a] -> ShowS
Open a -> String
(Int -> Open a -> ShowS)
-> (Open a -> String) -> ([Open a] -> ShowS) -> Show (Open a)
forall a. Show a => Int -> Open a -> ShowS
forall a. Show a => [Open a] -> ShowS
forall a. Show a => Open a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Open a] -> ShowS
$cshowList :: forall a. Show a => [Open a] -> ShowS
show :: Open a -> String
$cshow :: forall a. Show a => Open a -> String
showsPrec :: Int -> Open a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Open a -> ShowS
Show, a -> Open b -> Open a
(a -> b) -> Open a -> Open b
(forall a b. (a -> b) -> Open a -> Open b)
-> (forall a b. a -> Open b -> Open a) -> Functor Open
forall a b. a -> Open b -> Open a
forall a b. (a -> b) -> Open a -> Open b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Open b -> Open a
$c<$ :: forall a b. a -> Open b -> Open a
fmap :: (a -> b) -> Open a -> Open b
$cfmap :: forall a b. (a -> b) -> Open a -> Open b
Functor, Open a -> Bool
(a -> m) -> Open a -> m
(a -> b -> b) -> b -> Open a -> b
(forall m. Monoid m => Open m -> m)
-> (forall m a. Monoid m => (a -> m) -> Open a -> m)
-> (forall m a. Monoid m => (a -> m) -> Open a -> m)
-> (forall a b. (a -> b -> b) -> b -> Open a -> b)
-> (forall a b. (a -> b -> b) -> b -> Open a -> b)
-> (forall b a. (b -> a -> b) -> b -> Open a -> b)
-> (forall b a. (b -> a -> b) -> b -> Open a -> b)
-> (forall a. (a -> a -> a) -> Open a -> a)
-> (forall a. (a -> a -> a) -> Open a -> a)
-> (forall a. Open a -> [a])
-> (forall a. Open a -> Bool)
-> (forall a. Open a -> Int)
-> (forall a. Eq a => a -> Open a -> Bool)
-> (forall a. Ord a => Open a -> a)
-> (forall a. Ord a => Open a -> a)
-> (forall a. Num a => Open a -> a)
-> (forall a. Num a => Open a -> a)
-> Foldable Open
forall a. Eq a => a -> Open a -> Bool
forall a. Num a => Open a -> a
forall a. Ord a => Open a -> a
forall m. Monoid m => Open m -> m
forall a. Open a -> Bool
forall a. Open a -> Int
forall a. Open a -> [a]
forall a. (a -> a -> a) -> Open a -> a
forall m a. Monoid m => (a -> m) -> Open a -> m
forall b a. (b -> a -> b) -> b -> Open a -> b
forall a b. (a -> b -> b) -> b -> Open 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 :: Open a -> a
$cproduct :: forall a. Num a => Open a -> a
sum :: Open a -> a
$csum :: forall a. Num a => Open a -> a
minimum :: Open a -> a
$cminimum :: forall a. Ord a => Open a -> a
maximum :: Open a -> a
$cmaximum :: forall a. Ord a => Open a -> a
elem :: a -> Open a -> Bool
$celem :: forall a. Eq a => a -> Open a -> Bool
length :: Open a -> Int
$clength :: forall a. Open a -> Int
null :: Open a -> Bool
$cnull :: forall a. Open a -> Bool
toList :: Open a -> [a]
$ctoList :: forall a. Open a -> [a]
foldl1 :: (a -> a -> a) -> Open a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Open a -> a
foldr1 :: (a -> a -> a) -> Open a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Open a -> a
foldl' :: (b -> a -> b) -> b -> Open a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Open a -> b
foldl :: (b -> a -> b) -> b -> Open a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Open a -> b
foldr' :: (a -> b -> b) -> b -> Open a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Open a -> b
foldr :: (a -> b -> b) -> b -> Open a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Open a -> b
foldMap' :: (a -> m) -> Open a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Open a -> m
foldMap :: (a -> m) -> Open a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Open a -> m
fold :: Open m -> m
$cfold :: forall m. Monoid m => Open m -> m
Foldable, Functor Open
Foldable Open
Functor Open
-> Foldable Open
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Open a -> f (Open b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Open (f a) -> f (Open a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Open a -> m (Open b))
-> (forall (m :: * -> *) a. Monad m => Open (m a) -> m (Open a))
-> Traversable Open
(a -> f b) -> Open a -> f (Open 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 => Open (m a) -> m (Open a)
forall (f :: * -> *) a. Applicative f => Open (f a) -> f (Open a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Open a -> m (Open b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Open a -> f (Open b)
sequence :: Open (m a) -> m (Open a)
$csequence :: forall (m :: * -> *) a. Monad m => Open (m a) -> m (Open a)
mapM :: (a -> m b) -> Open a -> m (Open b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Open a -> m (Open b)
sequenceA :: Open (f a) -> f (Open a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Open (f a) -> f (Open a)
traverse :: (a -> f b) -> Open a -> f (Open b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Open a -> f (Open b)
$cp2Traversable :: Foldable Open
$cp1Traversable :: Functor Open
Traversable)

instance Decoration Open where
  traverseF :: (a -> m b) -> Open a -> m (Open b)
traverseF a -> m b
f (OpenThing CheckpointId
cp a
x) = CheckpointId -> b -> Open b
forall a. CheckpointId -> a -> Open a
OpenThing CheckpointId
cp (b -> Open b) -> m b -> m (Open b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> m b
f a
x

---------------------------------------------------------------------------
-- * Judgements
--
-- Used exclusively for typing of meta variables.
---------------------------------------------------------------------------

-- | Parametrized since it is used without MetaId when creating a new meta.
data Judgement a
  = HasType
    { Judgement a -> a
jMetaId     :: a
    , Judgement a -> Comparison
jComparison :: Comparison -- ^ are we checking (@CmpLeq@) or inferring (@CmpEq@) the type?
    , Judgement a -> Type
jMetaType   :: Type
    }
  | IsSort
    { jMetaId   :: a
    , jMetaType :: Type -- Andreas, 2011-04-26: type needed for higher-order sort metas
    }

instance Show a => Show (Judgement a) where
    show :: Judgement a -> String
show (HasType a
a Comparison
cmp Type
t) = a -> String
forall a. Show a => a -> String
show a
a String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" : " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Type -> String
forall a. Show a => a -> String
show Type
t
    show (IsSort  a
a Type
t) = a -> String
forall a. Show a => a -> String
show a
a String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" :sort " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Type -> String
forall a. Show a => a -> String
show Type
t

-----------------------------------------------------------------------------
-- ** Generalizable variables
-----------------------------------------------------------------------------

data DoGeneralize = YesGeneralize | NoGeneralize
  deriving (DoGeneralize -> DoGeneralize -> Bool
(DoGeneralize -> DoGeneralize -> Bool)
-> (DoGeneralize -> DoGeneralize -> Bool) -> Eq DoGeneralize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DoGeneralize -> DoGeneralize -> Bool
$c/= :: DoGeneralize -> DoGeneralize -> Bool
== :: DoGeneralize -> DoGeneralize -> Bool
$c== :: DoGeneralize -> DoGeneralize -> Bool
Eq, Eq DoGeneralize
Eq DoGeneralize
-> (DoGeneralize -> DoGeneralize -> Ordering)
-> (DoGeneralize -> DoGeneralize -> Bool)
-> (DoGeneralize -> DoGeneralize -> Bool)
-> (DoGeneralize -> DoGeneralize -> Bool)
-> (DoGeneralize -> DoGeneralize -> Bool)
-> (DoGeneralize -> DoGeneralize -> DoGeneralize)
-> (DoGeneralize -> DoGeneralize -> DoGeneralize)
-> Ord DoGeneralize
DoGeneralize -> DoGeneralize -> Bool
DoGeneralize -> DoGeneralize -> Ordering
DoGeneralize -> DoGeneralize -> DoGeneralize
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 :: DoGeneralize -> DoGeneralize -> DoGeneralize
$cmin :: DoGeneralize -> DoGeneralize -> DoGeneralize
max :: DoGeneralize -> DoGeneralize -> DoGeneralize
$cmax :: DoGeneralize -> DoGeneralize -> DoGeneralize
>= :: DoGeneralize -> DoGeneralize -> Bool
$c>= :: DoGeneralize -> DoGeneralize -> Bool
> :: DoGeneralize -> DoGeneralize -> Bool
$c> :: DoGeneralize -> DoGeneralize -> Bool
<= :: DoGeneralize -> DoGeneralize -> Bool
$c<= :: DoGeneralize -> DoGeneralize -> Bool
< :: DoGeneralize -> DoGeneralize -> Bool
$c< :: DoGeneralize -> DoGeneralize -> Bool
compare :: DoGeneralize -> DoGeneralize -> Ordering
$ccompare :: DoGeneralize -> DoGeneralize -> Ordering
$cp1Ord :: Eq DoGeneralize
Ord, Int -> DoGeneralize -> ShowS
[DoGeneralize] -> ShowS
DoGeneralize -> String
(Int -> DoGeneralize -> ShowS)
-> (DoGeneralize -> String)
-> ([DoGeneralize] -> ShowS)
-> Show DoGeneralize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DoGeneralize] -> ShowS
$cshowList :: [DoGeneralize] -> ShowS
show :: DoGeneralize -> String
$cshow :: DoGeneralize -> String
showsPrec :: Int -> DoGeneralize -> ShowS
$cshowsPrec :: Int -> DoGeneralize -> ShowS
Show, Typeable DoGeneralize
DataType
Constr
Typeable DoGeneralize
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> DoGeneralize -> c DoGeneralize)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DoGeneralize)
-> (DoGeneralize -> Constr)
-> (DoGeneralize -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DoGeneralize))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c DoGeneralize))
-> ((forall b. Data b => b -> b) -> DoGeneralize -> DoGeneralize)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DoGeneralize -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DoGeneralize -> r)
-> (forall u. (forall d. Data d => d -> u) -> DoGeneralize -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DoGeneralize -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize)
-> Data DoGeneralize
DoGeneralize -> DataType
DoGeneralize -> Constr
(forall b. Data b => b -> b) -> DoGeneralize -> DoGeneralize
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DoGeneralize -> c DoGeneralize
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DoGeneralize
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) -> DoGeneralize -> u
forall u. (forall d. Data d => d -> u) -> DoGeneralize -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DoGeneralize -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DoGeneralize -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DoGeneralize
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DoGeneralize -> c DoGeneralize
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DoGeneralize)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DoGeneralize)
$cNoGeneralize :: Constr
$cYesGeneralize :: Constr
$tDoGeneralize :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize
gmapMp :: (forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize
gmapM :: (forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DoGeneralize -> m DoGeneralize
gmapQi :: Int -> (forall d. Data d => d -> u) -> DoGeneralize -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DoGeneralize -> u
gmapQ :: (forall d. Data d => d -> u) -> DoGeneralize -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DoGeneralize -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DoGeneralize -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DoGeneralize -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DoGeneralize -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DoGeneralize -> r
gmapT :: (forall b. Data b => b -> b) -> DoGeneralize -> DoGeneralize
$cgmapT :: (forall b. Data b => b -> b) -> DoGeneralize -> DoGeneralize
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DoGeneralize)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DoGeneralize)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c DoGeneralize)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DoGeneralize)
dataTypeOf :: DoGeneralize -> DataType
$cdataTypeOf :: DoGeneralize -> DataType
toConstr :: DoGeneralize -> Constr
$ctoConstr :: DoGeneralize -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DoGeneralize
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DoGeneralize
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DoGeneralize -> c DoGeneralize
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DoGeneralize -> c DoGeneralize
$cp1Data :: Typeable DoGeneralize
Data)

-- | The value of a generalizable variable. This is created to be a
--   generalizable meta before checking the type to be generalized.
data GeneralizedValue = GeneralizedValue
  { GeneralizedValue -> CheckpointId
genvalCheckpoint :: CheckpointId
  , GeneralizedValue -> Term
genvalTerm       :: Term
  , GeneralizedValue -> Type
genvalType       :: Type
  } deriving (Int -> GeneralizedValue -> ShowS
[GeneralizedValue] -> ShowS
GeneralizedValue -> String
(Int -> GeneralizedValue -> ShowS)
-> (GeneralizedValue -> String)
-> ([GeneralizedValue] -> ShowS)
-> Show GeneralizedValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeneralizedValue] -> ShowS
$cshowList :: [GeneralizedValue] -> ShowS
show :: GeneralizedValue -> String
$cshow :: GeneralizedValue -> String
showsPrec :: Int -> GeneralizedValue -> ShowS
$cshowsPrec :: Int -> GeneralizedValue -> ShowS
Show, Typeable GeneralizedValue
DataType
Constr
Typeable GeneralizedValue
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> GeneralizedValue -> c GeneralizedValue)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c GeneralizedValue)
-> (GeneralizedValue -> Constr)
-> (GeneralizedValue -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c GeneralizedValue))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c GeneralizedValue))
-> ((forall b. Data b => b -> b)
    -> GeneralizedValue -> GeneralizedValue)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> GeneralizedValue -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> GeneralizedValue -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> GeneralizedValue -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> GeneralizedValue -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> GeneralizedValue -> m GeneralizedValue)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> GeneralizedValue -> m GeneralizedValue)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> GeneralizedValue -> m GeneralizedValue)
-> Data GeneralizedValue
GeneralizedValue -> DataType
GeneralizedValue -> Constr
(forall b. Data b => b -> b)
-> GeneralizedValue -> GeneralizedValue
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GeneralizedValue -> c GeneralizedValue
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c GeneralizedValue
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) -> GeneralizedValue -> u
forall u. (forall d. Data d => d -> u) -> GeneralizedValue -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GeneralizedValue -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GeneralizedValue -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> GeneralizedValue -> m GeneralizedValue
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> GeneralizedValue -> m GeneralizedValue
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c GeneralizedValue
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GeneralizedValue -> c GeneralizedValue
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c GeneralizedValue)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c GeneralizedValue)
$cGeneralizedValue :: Constr
$tGeneralizedValue :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> GeneralizedValue -> m GeneralizedValue
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> GeneralizedValue -> m GeneralizedValue
gmapMp :: (forall d. Data d => d -> m d)
-> GeneralizedValue -> m GeneralizedValue
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> GeneralizedValue -> m GeneralizedValue
gmapM :: (forall d. Data d => d -> m d)
-> GeneralizedValue -> m GeneralizedValue
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> GeneralizedValue -> m GeneralizedValue
gmapQi :: Int -> (forall d. Data d => d -> u) -> GeneralizedValue -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> GeneralizedValue -> u
gmapQ :: (forall d. Data d => d -> u) -> GeneralizedValue -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> GeneralizedValue -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GeneralizedValue -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GeneralizedValue -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GeneralizedValue -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GeneralizedValue -> r
gmapT :: (forall b. Data b => b -> b)
-> GeneralizedValue -> GeneralizedValue
$cgmapT :: (forall b. Data b => b -> b)
-> GeneralizedValue -> GeneralizedValue
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c GeneralizedValue)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c GeneralizedValue)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c GeneralizedValue)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c GeneralizedValue)
dataTypeOf :: GeneralizedValue -> DataType
$cdataTypeOf :: GeneralizedValue -> DataType
toConstr :: GeneralizedValue -> Constr
$ctoConstr :: GeneralizedValue -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c GeneralizedValue
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c GeneralizedValue
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GeneralizedValue -> c GeneralizedValue
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GeneralizedValue -> c GeneralizedValue
$cp1Data :: Typeable GeneralizedValue
Data)

---------------------------------------------------------------------------
-- ** Meta variables
---------------------------------------------------------------------------

data MetaVariable =
        MetaVar { MetaVariable -> MetaInfo
mvInfo          :: MetaInfo
                , MetaVariable -> MetaPriority
mvPriority      :: MetaPriority -- ^ some metavariables are more eager to be instantiated
                , MetaVariable -> Permutation
mvPermutation   :: Permutation
                  -- ^ a metavariable doesn't have to depend on all variables
                  --   in the context, this "permutation" will throw away the
                  --   ones it does not depend on
                , MetaVariable -> Judgement MetaId
mvJudgement     :: Judgement MetaId
                , MetaVariable -> MetaInstantiation
mvInstantiation :: MetaInstantiation
                , MetaVariable -> Set Listener
mvListeners     :: Set Listener -- ^ meta variables scheduled for eta-expansion but blocked by this one
                , MetaVariable -> Frozen
mvFrozen        :: Frozen -- ^ are we past the point where we can instantiate this meta variable?
                , MetaVariable -> Maybe MetaId
mvTwin          :: Maybe MetaId -- ^ @Just m@ means this meta will be equated to @m@ when the latter is unblocked. See @blockedTermOnProblem@.
                }

data Listener = EtaExpand MetaId
              | CheckConstraint Nat ProblemConstraint

instance Eq Listener where
  EtaExpand       MetaId
x   == :: Listener -> Listener -> Bool
== EtaExpand       MetaId
y   = MetaId
x MetaId -> MetaId -> Bool
forall a. Eq a => a -> a -> Bool
== MetaId
y
  CheckConstraint Int
x ProblemConstraint
_ == CheckConstraint Int
y ProblemConstraint
_ = Int
x Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
y
  Listener
_ == Listener
_ = Bool
False

instance Ord Listener where
  EtaExpand       MetaId
x   compare :: Listener -> Listener -> Ordering
`compare` EtaExpand       MetaId
y   = MetaId
x MetaId -> MetaId -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` MetaId
y
  CheckConstraint Int
x ProblemConstraint
_ `compare` CheckConstraint Int
y ProblemConstraint
_ = Int
x Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` Int
y
  EtaExpand{} `compare` CheckConstraint{} = Ordering
LT
  CheckConstraint{} `compare` EtaExpand{} = Ordering
GT

-- | Frozen meta variable cannot be instantiated by unification.
--   This serves to prevent the completion of a definition by its use
--   outside of the current block.
--   (See issues 118, 288, 399).
data Frozen
  = Frozen        -- ^ Do not instantiate.
  | Instantiable
    deriving (Frozen -> Frozen -> Bool
(Frozen -> Frozen -> Bool)
-> (Frozen -> Frozen -> Bool) -> Eq Frozen
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Frozen -> Frozen -> Bool
$c/= :: Frozen -> Frozen -> Bool
== :: Frozen -> Frozen -> Bool
$c== :: Frozen -> Frozen -> Bool
Eq, Int -> Frozen -> ShowS
[Frozen] -> ShowS
Frozen -> String
(Int -> Frozen -> ShowS)
-> (Frozen -> String) -> ([Frozen] -> ShowS) -> Show Frozen
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Frozen] -> ShowS
$cshowList :: [Frozen] -> ShowS
show :: Frozen -> String
$cshow :: Frozen -> String
showsPrec :: Int -> Frozen -> ShowS
$cshowsPrec :: Int -> Frozen -> ShowS
Show)

data MetaInstantiation
        = InstV [Arg String] Term -- ^ solved by term (abstracted over some free variables)
        | Open               -- ^ unsolved
        | OpenInstance       -- ^ open, to be instantiated by instance search
        | BlockedConst Term  -- ^ solution blocked by unsolved constraints
        | PostponedTypeCheckingProblem (Closure TypeCheckingProblem) (TCM Bool)

-- | Solving a 'CheckArgs' constraint may or may not check the target type. If
--   it did, it returns a handle to any unsolved constraints.
data CheckedTarget = CheckedTarget (Maybe ProblemId)
                   | NotCheckedTarget

data TypeCheckingProblem
  = CheckExpr Comparison A.Expr Type
  | CheckArgs ExpandHidden Range [NamedArg A.Expr] Type Type ([Maybe Range] -> Elims -> Type -> CheckedTarget -> TCM Term)
  | CheckProjAppToKnownPrincipalArg Comparison A.Expr ProjOrigin (NonEmpty QName) A.Args Type Int Term Type
  | CheckLambda Comparison (Arg ([WithHiding Name], Maybe Type)) A.Expr Type
    -- ^ @(λ (xs : t₀) → e) : t@
    --   This is not an instance of 'CheckExpr' as the domain type
    --   has already been checked.
    --   For example, when checking
    --     @(λ (x y : Fin _) → e) : (x : Fin n) → ?@
    --   we want to postpone @(λ (y : Fin n) → e) : ?@ where @Fin n@
    --   is a 'Type' rather than an 'A.Expr'.
  | DoQuoteTerm Comparison Term Type -- ^ Quote the given term and check type against `Term`

instance Show MetaInstantiation where
  show :: MetaInstantiation -> String
show (InstV [Arg String]
tel Term
t) = String
"InstV " String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Arg String] -> String
forall a. Show a => a -> String
show [Arg String]
tel String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Term -> String
forall a. Show a => a -> String
show Term
t String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
  show MetaInstantiation
Open      = String
"Open"
  show MetaInstantiation
OpenInstance = String
"OpenInstance"
  show (BlockedConst Term
t) = String
"BlockedConst (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Term -> String
forall a. Show a => a -> String
show Term
t String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
  show (PostponedTypeCheckingProblem{}) = String
"PostponedTypeCheckingProblem (...)"

-- | Meta variable priority:
--   When we have an equation between meta-variables, which one
--   should be instantiated?
--
--   Higher value means higher priority to be instantiated.
newtype MetaPriority = MetaPriority Int
    deriving (MetaPriority -> MetaPriority -> Bool
(MetaPriority -> MetaPriority -> Bool)
-> (MetaPriority -> MetaPriority -> Bool) -> Eq MetaPriority
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetaPriority -> MetaPriority -> Bool
$c/= :: MetaPriority -> MetaPriority -> Bool
== :: MetaPriority -> MetaPriority -> Bool
$c== :: MetaPriority -> MetaPriority -> Bool
Eq , Eq MetaPriority
Eq MetaPriority
-> (MetaPriority -> MetaPriority -> Ordering)
-> (MetaPriority -> MetaPriority -> Bool)
-> (MetaPriority -> MetaPriority -> Bool)
-> (MetaPriority -> MetaPriority -> Bool)
-> (MetaPriority -> MetaPriority -> Bool)
-> (MetaPriority -> MetaPriority -> MetaPriority)
-> (MetaPriority -> MetaPriority -> MetaPriority)
-> Ord MetaPriority
MetaPriority -> MetaPriority -> Bool
MetaPriority -> MetaPriority -> Ordering
MetaPriority -> MetaPriority -> MetaPriority
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 :: MetaPriority -> MetaPriority -> MetaPriority
$cmin :: MetaPriority -> MetaPriority -> MetaPriority
max :: MetaPriority -> MetaPriority -> MetaPriority
$cmax :: MetaPriority -> MetaPriority -> MetaPriority
>= :: MetaPriority -> MetaPriority -> Bool
$c>= :: MetaPriority -> MetaPriority -> Bool
> :: MetaPriority -> MetaPriority -> Bool
$c> :: MetaPriority -> MetaPriority -> Bool
<= :: MetaPriority -> MetaPriority -> Bool
$c<= :: MetaPriority -> MetaPriority -> Bool
< :: MetaPriority -> MetaPriority -> Bool
$c< :: MetaPriority -> MetaPriority -> Bool
compare :: MetaPriority -> MetaPriority -> Ordering
$ccompare :: MetaPriority -> MetaPriority -> Ordering
$cp1Ord :: Eq MetaPriority
Ord , Int -> MetaPriority -> ShowS
[MetaPriority] -> ShowS
MetaPriority -> String
(Int -> MetaPriority -> ShowS)
-> (MetaPriority -> String)
-> ([MetaPriority] -> ShowS)
-> Show MetaPriority
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetaPriority] -> ShowS
$cshowList :: [MetaPriority] -> ShowS
show :: MetaPriority -> String
$cshow :: MetaPriority -> String
showsPrec :: Int -> MetaPriority -> ShowS
$cshowsPrec :: Int -> MetaPriority -> ShowS
Show)

data RunMetaOccursCheck
  = RunMetaOccursCheck
  | DontRunMetaOccursCheck
  deriving (RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
(RunMetaOccursCheck -> RunMetaOccursCheck -> Bool)
-> (RunMetaOccursCheck -> RunMetaOccursCheck -> Bool)
-> Eq RunMetaOccursCheck
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
$c/= :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
== :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
$c== :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
Eq , Eq RunMetaOccursCheck
Eq RunMetaOccursCheck
-> (RunMetaOccursCheck -> RunMetaOccursCheck -> Ordering)
-> (RunMetaOccursCheck -> RunMetaOccursCheck -> Bool)
-> (RunMetaOccursCheck -> RunMetaOccursCheck -> Bool)
-> (RunMetaOccursCheck -> RunMetaOccursCheck -> Bool)
-> (RunMetaOccursCheck -> RunMetaOccursCheck -> Bool)
-> (RunMetaOccursCheck -> RunMetaOccursCheck -> RunMetaOccursCheck)
-> (RunMetaOccursCheck -> RunMetaOccursCheck -> RunMetaOccursCheck)
-> Ord RunMetaOccursCheck
RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
RunMetaOccursCheck -> RunMetaOccursCheck -> Ordering
RunMetaOccursCheck -> RunMetaOccursCheck -> RunMetaOccursCheck
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 :: RunMetaOccursCheck -> RunMetaOccursCheck -> RunMetaOccursCheck
$cmin :: RunMetaOccursCheck -> RunMetaOccursCheck -> RunMetaOccursCheck
max :: RunMetaOccursCheck -> RunMetaOccursCheck -> RunMetaOccursCheck
$cmax :: RunMetaOccursCheck -> RunMetaOccursCheck -> RunMetaOccursCheck
>= :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
$c>= :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
> :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
$c> :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
<= :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
$c<= :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
< :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
$c< :: RunMetaOccursCheck -> RunMetaOccursCheck -> Bool
compare :: RunMetaOccursCheck -> RunMetaOccursCheck -> Ordering
$ccompare :: RunMetaOccursCheck -> RunMetaOccursCheck -> Ordering
$cp1Ord :: Eq RunMetaOccursCheck
Ord , Int -> RunMetaOccursCheck -> ShowS
[RunMetaOccursCheck] -> ShowS
RunMetaOccursCheck -> String
(Int -> RunMetaOccursCheck -> ShowS)
-> (RunMetaOccursCheck -> String)
-> ([RunMetaOccursCheck] -> ShowS)
-> Show RunMetaOccursCheck
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RunMetaOccursCheck] -> ShowS
$cshowList :: [RunMetaOccursCheck] -> ShowS
show :: RunMetaOccursCheck -> String
$cshow :: RunMetaOccursCheck -> String
showsPrec :: Int -> RunMetaOccursCheck -> ShowS
$cshowsPrec :: Int -> RunMetaOccursCheck -> ShowS
Show)

-- | @MetaInfo@ is cloned from one meta to the next during pruning.
data MetaInfo = MetaInfo
  { MetaInfo -> Closure Range
miClosRange       :: Closure Range -- TODO: Not so nice. But we want both to have the environment of the meta (Closure) and its range.
--  , miRelevance       :: Relevance          -- ^ Created in irrelevant position?
  , MetaInfo -> RunMetaOccursCheck
miMetaOccursCheck :: RunMetaOccursCheck -- ^ Run the extended occurs check that goes in definitions?
  , MetaInfo -> String
miNameSuggestion  :: MetaNameSuggestion
    -- ^ Used for printing.
    --   @Just x@ if meta-variable comes from omitted argument with name @x@.
  , MetaInfo -> Arg DoGeneralize
miGeneralizable   :: Arg DoGeneralize
    -- ^ Should this meta be generalized if unsolved? If so, at what ArgInfo?
  }

-- | Name suggestion for meta variable.  Empty string means no suggestion.
type MetaNameSuggestion = String

-- | For printing, we couple a meta with its name suggestion.
data NamedMeta = NamedMeta
  { NamedMeta -> String
nmSuggestion :: MetaNameSuggestion
  , NamedMeta -> MetaId
nmid         :: MetaId
  }

instance Pretty NamedMeta where
  pretty :: NamedMeta -> Doc
pretty (NamedMeta String
"" MetaId
x) = MetaId -> Doc
forall a. Pretty a => a -> Doc
pretty MetaId
x
  pretty (NamedMeta String
"_" MetaId
x) = MetaId -> Doc
forall a. Pretty a => a -> Doc
pretty MetaId
x
  pretty (NamedMeta String
s  MetaId
x) = String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ String
"_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ MetaId -> String
forall a. Pretty a => a -> String
prettyShow MetaId
x

type MetaStore = IntMap MetaVariable

instance HasRange MetaInfo where
  getRange :: MetaInfo -> Range
getRange = Closure Range -> Range
forall a. Closure a -> a
clValue (Closure Range -> Range)
-> (MetaInfo -> Closure Range) -> MetaInfo -> Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetaInfo -> Closure Range
miClosRange

instance HasRange MetaVariable where
    getRange :: MetaVariable -> Range
getRange MetaVariable
m = Closure Range -> Range
forall t. HasRange t => t -> Range
getRange (Closure Range -> Range) -> Closure Range -> Range
forall a b. (a -> b) -> a -> b
$ MetaVariable -> Closure Range
getMetaInfo MetaVariable
m

instance SetRange MetaInfo where
  setRange :: Range -> MetaInfo -> MetaInfo
setRange Range
r MetaInfo
m = MetaInfo
m { miClosRange :: Closure Range
miClosRange = (MetaInfo -> Closure Range
miClosRange MetaInfo
m) { clValue :: Range
clValue = Range
r }}

instance SetRange MetaVariable where
  setRange :: Range -> MetaVariable -> MetaVariable
setRange Range
r MetaVariable
m = MetaVariable
m { mvInfo :: MetaInfo
mvInfo = Range -> MetaInfo -> MetaInfo
forall t. SetRange t => Range -> t -> t
setRange Range
r (MetaVariable -> MetaInfo
mvInfo MetaVariable
m) }

normalMetaPriority :: MetaPriority
normalMetaPriority :: MetaPriority
normalMetaPriority = Int -> MetaPriority
MetaPriority Int
0

lowMetaPriority :: MetaPriority
lowMetaPriority :: MetaPriority
lowMetaPriority = Int -> MetaPriority
MetaPriority (-Int
10)

highMetaPriority :: MetaPriority
highMetaPriority :: MetaPriority
highMetaPriority = Int -> MetaPriority
MetaPriority Int
10

getMetaInfo :: MetaVariable -> Closure Range
getMetaInfo :: MetaVariable -> Closure Range
getMetaInfo = MetaInfo -> Closure Range
miClosRange (MetaInfo -> Closure Range)
-> (MetaVariable -> MetaInfo) -> MetaVariable -> Closure Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetaVariable -> MetaInfo
mvInfo

getMetaScope :: MetaVariable -> ScopeInfo
getMetaScope :: MetaVariable -> ScopeInfo
getMetaScope MetaVariable
m = Closure Range -> ScopeInfo
forall a. Closure a -> ScopeInfo
clScope (Closure Range -> ScopeInfo) -> Closure Range -> ScopeInfo
forall a b. (a -> b) -> a -> b
$ MetaVariable -> Closure Range
getMetaInfo MetaVariable
m

getMetaEnv :: MetaVariable -> TCEnv
getMetaEnv :: MetaVariable -> TCEnv
getMetaEnv MetaVariable
m = Closure Range -> TCEnv
forall a. Closure a -> TCEnv
clEnv (Closure Range -> TCEnv) -> Closure Range -> TCEnv
forall a b. (a -> b) -> a -> b
$ MetaVariable -> Closure Range
getMetaInfo MetaVariable
m

getMetaSig :: MetaVariable -> Signature
getMetaSig :: MetaVariable -> Signature
getMetaSig MetaVariable
m = Closure Range -> Signature
forall a. Closure a -> Signature
clSignature (Closure Range -> Signature) -> Closure Range -> Signature
forall a b. (a -> b) -> a -> b
$ MetaVariable -> Closure Range
getMetaInfo MetaVariable
m

getMetaRelevance :: MetaVariable -> Relevance
getMetaRelevance :: MetaVariable -> Relevance
getMetaRelevance = TCEnv -> Relevance
forall a. LensRelevance a => a -> Relevance
getRelevance (TCEnv -> Relevance)
-> (MetaVariable -> TCEnv) -> MetaVariable -> Relevance
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetaVariable -> TCEnv
getMetaEnv

getMetaModality :: MetaVariable -> Modality
-- Andrea 23/02/2020: use getModality to enforce invariants of the
--                    envModality field.
getMetaModality :: MetaVariable -> Modality
getMetaModality = TCEnv -> Modality
forall a. LensModality a => a -> Modality
getModality (TCEnv -> Modality)
-> (MetaVariable -> TCEnv) -> MetaVariable -> Modality
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetaVariable -> TCEnv
getMetaEnv

-- Lenses

metaFrozen :: Lens' Frozen MetaVariable
metaFrozen :: (Frozen -> f Frozen) -> MetaVariable -> f MetaVariable
metaFrozen Frozen -> f Frozen
f MetaVariable
mv = Frozen -> f Frozen
f (MetaVariable -> Frozen
mvFrozen MetaVariable
mv) f Frozen -> (Frozen -> MetaVariable) -> f MetaVariable
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Frozen
x -> MetaVariable
mv { mvFrozen :: Frozen
mvFrozen = Frozen
x }

_mvInfo :: Lens' MetaInfo MetaVariable
_mvInfo :: (MetaInfo -> f MetaInfo) -> MetaVariable -> f MetaVariable
_mvInfo MetaInfo -> f MetaInfo
f MetaVariable
mv = (MetaInfo -> f MetaInfo
f (MetaInfo -> f MetaInfo) -> MetaInfo -> f MetaInfo
forall a b. (a -> b) -> a -> b
$! MetaVariable -> MetaInfo
mvInfo MetaVariable
mv) f MetaInfo -> (MetaInfo -> MetaVariable) -> f MetaVariable
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ MetaInfo
mi -> MetaVariable
mv { mvInfo :: MetaInfo
mvInfo = MetaInfo
mi }

-- Lenses onto Closure Range

instance LensClosure Range MetaInfo where
  lensClosure :: (Closure Range -> f (Closure Range)) -> MetaInfo -> f MetaInfo
lensClosure Closure Range -> f (Closure Range)
f MetaInfo
mi = (Closure Range -> f (Closure Range)
f (Closure Range -> f (Closure Range))
-> Closure Range -> f (Closure Range)
forall a b. (a -> b) -> a -> b
$! MetaInfo -> Closure Range
miClosRange MetaInfo
mi) f (Closure Range) -> (Closure Range -> MetaInfo) -> f MetaInfo
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Closure Range
cl -> MetaInfo
mi { miClosRange :: Closure Range
miClosRange = Closure Range
cl }

instance LensClosure Range MetaVariable where
  lensClosure :: (Closure Range -> f (Closure Range))
-> MetaVariable -> f MetaVariable
lensClosure = (MetaInfo -> f MetaInfo) -> MetaVariable -> f MetaVariable
Lens' MetaInfo MetaVariable
_mvInfo ((MetaInfo -> f MetaInfo) -> MetaVariable -> f MetaVariable)
-> ((Closure Range -> f (Closure Range)) -> MetaInfo -> f MetaInfo)
-> (Closure Range -> f (Closure Range))
-> MetaVariable
-> f MetaVariable
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Closure Range -> f (Closure Range)) -> MetaInfo -> f MetaInfo
forall a b. LensClosure a b => Lens' (Closure a) b
lensClosure

-- Lenses onto IsAbstract

instance LensIsAbstract TCEnv where
  lensIsAbstract :: (IsAbstract -> f IsAbstract) -> TCEnv -> f TCEnv
lensIsAbstract IsAbstract -> f IsAbstract
f TCEnv
env =
     -- Andreas, 2019-08-19
     -- Using $! to prevent space leaks like #1829.
     -- This can crash when trying to get IsAbstract from IgnoreAbstractMode.
    (IsAbstract -> f IsAbstract
f (IsAbstract -> f IsAbstract) -> IsAbstract -> f IsAbstract
forall a b. (a -> b) -> a -> b
$! IsAbstract -> Maybe IsAbstract -> IsAbstract
forall a. a -> Maybe a -> a
fromMaybe IsAbstract
forall a. HasCallStack => a
__IMPOSSIBLE__ (AbstractMode -> Maybe IsAbstract
aModeToDef (AbstractMode -> Maybe IsAbstract)
-> AbstractMode -> Maybe IsAbstract
forall a b. (a -> b) -> a -> b
$ TCEnv -> AbstractMode
envAbstractMode TCEnv
env))
    f IsAbstract -> (IsAbstract -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ IsAbstract
a -> TCEnv
env { envAbstractMode :: AbstractMode
envAbstractMode = IsAbstract -> AbstractMode
aDefToMode IsAbstract
a }

instance LensIsAbstract (Closure a) where
  lensIsAbstract :: (IsAbstract -> f IsAbstract) -> Closure a -> f (Closure a)
lensIsAbstract = (TCEnv -> f TCEnv) -> Closure a -> f (Closure a)
forall a. LensTCEnv a => Lens' TCEnv a
lensTCEnv ((TCEnv -> f TCEnv) -> Closure a -> f (Closure a))
-> ((IsAbstract -> f IsAbstract) -> TCEnv -> f TCEnv)
-> (IsAbstract -> f IsAbstract)
-> Closure a
-> f (Closure a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IsAbstract -> f IsAbstract) -> TCEnv -> f TCEnv
forall a. LensIsAbstract a => Lens' IsAbstract a
lensIsAbstract

instance LensIsAbstract MetaInfo where
  lensIsAbstract :: (IsAbstract -> f IsAbstract) -> MetaInfo -> f MetaInfo
lensIsAbstract = (Closure Range -> f (Closure Range)) -> MetaInfo -> f MetaInfo
forall a b. LensClosure a b => Lens' (Closure a) b
lensClosure ((Closure Range -> f (Closure Range)) -> MetaInfo -> f MetaInfo)
-> ((IsAbstract -> f IsAbstract)
    -> Closure Range -> f (Closure Range))
-> (IsAbstract -> f IsAbstract)
-> MetaInfo
-> f MetaInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IsAbstract -> f IsAbstract) -> Closure Range -> f (Closure Range)
forall a. LensIsAbstract a => Lens' IsAbstract a
lensIsAbstract

---------------------------------------------------------------------------
-- ** Interaction meta variables
---------------------------------------------------------------------------

-- | Interaction points are created by the scope checker who sets the range.
--   The meta variable is created by the type checker and then hooked up to the
--   interaction point.
data InteractionPoint = InteractionPoint
  { InteractionPoint -> Range
ipRange :: Range        -- ^ The position of the interaction point.
  , InteractionPoint -> Maybe MetaId
ipMeta  :: Maybe MetaId -- ^ The meta variable, if any, holding the type etc.
  , InteractionPoint -> Bool
ipSolved:: Bool         -- ^ Has this interaction point already been solved?
  , InteractionPoint -> IPClause
ipClause:: IPClause
      -- ^ The clause of the interaction point (if any).
      --   Used for case splitting.
  }

instance Eq InteractionPoint where == :: InteractionPoint -> InteractionPoint -> Bool
(==) = Maybe MetaId -> Maybe MetaId -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Maybe MetaId -> Maybe MetaId -> Bool)
-> (InteractionPoint -> Maybe MetaId)
-> InteractionPoint
-> InteractionPoint
-> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` InteractionPoint -> Maybe MetaId
ipMeta

-- | Data structure managing the interaction points.
--
--   We never remove interaction points from this map, only set their
--   'ipSolved' to @True@.  (Issue #2368)
type InteractionPoints = Map InteractionId InteractionPoint


-- | Flag to indicate whether the meta is overapplied in the
--   constraint.  A meta is overapplied if it has more arguments than
--   the size of the telescope in its creation environment
--   (as stored in MetaInfo).
data Overapplied = Overapplied | NotOverapplied deriving (Overapplied -> Overapplied -> Bool
(Overapplied -> Overapplied -> Bool)
-> (Overapplied -> Overapplied -> Bool) -> Eq Overapplied
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Overapplied -> Overapplied -> Bool
$c/= :: Overapplied -> Overapplied -> Bool
== :: Overapplied -> Overapplied -> Bool
$c== :: Overapplied -> Overapplied -> Bool
Eq, Int -> Overapplied -> ShowS
[Overapplied] -> ShowS
Overapplied -> String
(Int -> Overapplied -> ShowS)
-> (Overapplied -> String)
-> ([Overapplied] -> ShowS)
-> Show Overapplied
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Overapplied] -> ShowS
$cshowList :: [Overapplied] -> ShowS
show :: Overapplied -> String
$cshow :: Overapplied -> String
showsPrec :: Int -> Overapplied -> ShowS
$cshowsPrec :: Int -> Overapplied -> ShowS
Show, Typeable Overapplied
DataType
Constr
Typeable Overapplied
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Overapplied -> c Overapplied)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Overapplied)
-> (Overapplied -> Constr)
-> (Overapplied -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Overapplied))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Overapplied))
-> ((forall b. Data b => b -> b) -> Overapplied -> Overapplied)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Overapplied -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Overapplied -> r)
-> (forall u. (forall d. Data d => d -> u) -> Overapplied -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Overapplied -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Overapplied -> m Overapplied)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Overapplied -> m Overapplied)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Overapplied -> m Overapplied)
-> Data Overapplied
Overapplied -> DataType
Overapplied -> Constr
(forall b. Data b => b -> b) -> Overapplied -> Overapplied
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Overapplied -> c Overapplied
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Overapplied
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) -> Overapplied -> u
forall u. (forall d. Data d => d -> u) -> Overapplied -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Overapplied -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Overapplied -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Overapplied -> m Overapplied
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Overapplied -> m Overapplied
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Overapplied
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Overapplied -> c Overapplied
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Overapplied)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c Overapplied)
$cNotOverapplied :: Constr
$cOverapplied :: Constr
$tOverapplied :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Overapplied -> m Overapplied
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Overapplied -> m Overapplied
gmapMp :: (forall d. Data d => d -> m d) -> Overapplied -> m Overapplied
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Overapplied -> m Overapplied
gmapM :: (forall d. Data d => d -> m d) -> Overapplied -> m Overapplied
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Overapplied -> m Overapplied
gmapQi :: Int -> (forall d. Data d => d -> u) -> Overapplied -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Overapplied -> u
gmapQ :: (forall d. Data d => d -> u) -> Overapplied -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Overapplied -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Overapplied -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Overapplied -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Overapplied -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Overapplied -> r
gmapT :: (forall b. Data b => b -> b) -> Overapplied -> Overapplied
$cgmapT :: (forall b. Data b => b -> b) -> Overapplied -> Overapplied
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c Overapplied)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c Overapplied)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Overapplied)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Overapplied)
dataTypeOf :: Overapplied -> DataType
$cdataTypeOf :: Overapplied -> DataType
toConstr :: Overapplied -> Constr
$ctoConstr :: Overapplied -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Overapplied
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Overapplied
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Overapplied -> c Overapplied
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Overapplied -> c Overapplied
$cp1Data :: Typeable Overapplied
Data)

-- | Datatype representing a single boundary condition:
--   x_0 = u_0, ... ,x_n = u_n ⊢ t = ?n es
data IPBoundary' t = IPBoundary
  { IPBoundary' t -> [(t, t)]
ipbEquations :: [(t,t)] -- ^ [x_0 = u_0, ... ,x_n = u_n]
  , IPBoundary' t -> t
ipbValue     :: t          -- ^ @t@
  , IPBoundary' t -> t
ipbMetaApp   :: t          -- ^ @?n es@
  , IPBoundary' t -> Overapplied
ipbOverapplied :: Overapplied -- ^ Is @?n@ overapplied in @?n es@ ?
  }
  deriving (Int -> IPBoundary' t -> ShowS
[IPBoundary' t] -> ShowS
IPBoundary' t -> String
(Int -> IPBoundary' t -> ShowS)
-> (IPBoundary' t -> String)
-> ([IPBoundary' t] -> ShowS)
-> Show (IPBoundary' t)
forall t. Show t => Int -> IPBoundary' t -> ShowS
forall t. Show t => [IPBoundary' t] -> ShowS
forall t. Show t => IPBoundary' t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IPBoundary' t] -> ShowS
$cshowList :: forall t. Show t => [IPBoundary' t] -> ShowS
show :: IPBoundary' t -> String
$cshow :: forall t. Show t => IPBoundary' t -> String
showsPrec :: Int -> IPBoundary' t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> IPBoundary' t -> ShowS
Show, Typeable (IPBoundary' t)
DataType
Constr
Typeable (IPBoundary' t)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> IPBoundary' t -> c (IPBoundary' t))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (IPBoundary' t))
-> (IPBoundary' t -> Constr)
-> (IPBoundary' t -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (IPBoundary' t)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (IPBoundary' t)))
-> ((forall b. Data b => b -> b) -> IPBoundary' t -> IPBoundary' t)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r)
-> (forall u. (forall d. Data d => d -> u) -> IPBoundary' t -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> IPBoundary' t -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> IPBoundary' t -> m (IPBoundary' t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> IPBoundary' t -> m (IPBoundary' t))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> IPBoundary' t -> m (IPBoundary' t))
-> Data (IPBoundary' t)
IPBoundary' t -> DataType
IPBoundary' t -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (IPBoundary' t))
(forall b. Data b => b -> b) -> IPBoundary' t -> IPBoundary' t
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IPBoundary' t -> c (IPBoundary' t)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (IPBoundary' t)
forall t. Data t => Typeable (IPBoundary' t)
forall t. Data t => IPBoundary' t -> DataType
forall t. Data t => IPBoundary' t -> Constr
forall t.
Data t =>
(forall b. Data b => b -> b) -> IPBoundary' t -> IPBoundary' t
forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> IPBoundary' t -> u
forall t u.
Data t =>
(forall d. Data d => d -> u) -> IPBoundary' t -> [u]
forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r
forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r
forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (IPBoundary' t)
forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IPBoundary' t -> c (IPBoundary' t)
forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (IPBoundary' t))
forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (IPBoundary' t))
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) -> IPBoundary' t -> u
forall u. (forall d. Data d => d -> u) -> IPBoundary' t -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (IPBoundary' t)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IPBoundary' t -> c (IPBoundary' t)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (IPBoundary' t))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (IPBoundary' t))
$cIPBoundary :: Constr
$tIPBoundary' :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
$cgmapMo :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
gmapMp :: (forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
$cgmapMp :: forall t (m :: * -> *).
(Data t, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
gmapM :: (forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
$cgmapM :: forall t (m :: * -> *).
(Data t, Monad m) =>
(forall d. Data d => d -> m d)
-> IPBoundary' t -> m (IPBoundary' t)
gmapQi :: Int -> (forall d. Data d => d -> u) -> IPBoundary' t -> u
$cgmapQi :: forall t u.
Data t =>
Int -> (forall d. Data d => d -> u) -> IPBoundary' t -> u
gmapQ :: (forall d. Data d => d -> u) -> IPBoundary' t -> [u]
$cgmapQ :: forall t u.
Data t =>
(forall d. Data d => d -> u) -> IPBoundary' t -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r
$cgmapQr :: forall t r r'.
Data t =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r
$cgmapQl :: forall t r r'.
Data t =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IPBoundary' t -> r
gmapT :: (forall b. Data b => b -> b) -> IPBoundary' t -> IPBoundary' t
$cgmapT :: forall t.
Data t =>
(forall b. Data b => b -> b) -> IPBoundary' t -> IPBoundary' t
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (IPBoundary' t))
$cdataCast2 :: forall t (t :: * -> * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (IPBoundary' t))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (IPBoundary' t))
$cdataCast1 :: forall t (t :: * -> *) (c :: * -> *).
(Data t, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (IPBoundary' t))
dataTypeOf :: IPBoundary' t -> DataType
$cdataTypeOf :: forall t. Data t => IPBoundary' t -> DataType
toConstr :: IPBoundary' t -> Constr
$ctoConstr :: forall t. Data t => IPBoundary' t -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (IPBoundary' t)
$cgunfold :: forall t (c :: * -> *).
Data t =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (IPBoundary' t)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IPBoundary' t -> c (IPBoundary' t)
$cgfoldl :: forall t (c :: * -> *).
Data t =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IPBoundary' t -> c (IPBoundary' t)
$cp1Data :: forall t. Data t => Typeable (IPBoundary' t)
Data, a -> IPBoundary' b -> IPBoundary' a
(a -> b) -> IPBoundary' a -> IPBoundary' b
(forall a b. (a -> b) -> IPBoundary' a -> IPBoundary' b)
-> (forall a b. a -> IPBoundary' b -> IPBoundary' a)
-> Functor IPBoundary'
forall a b. a -> IPBoundary' b -> IPBoundary' a
forall a b. (a -> b) -> IPBoundary' a -> IPBoundary' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> IPBoundary' b -> IPBoundary' a
$c<$ :: forall a b. a -> IPBoundary' b -> IPBoundary' a
fmap :: (a -> b) -> IPBoundary' a -> IPBoundary' b
$cfmap :: forall a b. (a -> b) -> IPBoundary' a -> IPBoundary' b
Functor, IPBoundary' a -> Bool
(a -> m) -> IPBoundary' a -> m
(a -> b -> b) -> b -> IPBoundary' a -> b
(forall m. Monoid m => IPBoundary' m -> m)
-> (forall m a. Monoid m => (a -> m) -> IPBoundary' a -> m)
-> (forall m a. Monoid m => (a -> m) -> IPBoundary' a -> m)
-> (forall a b. (a -> b -> b) -> b -> IPBoundary' a -> b)
-> (forall a b. (a -> b -> b) -> b -> IPBoundary' a -> b)
-> (forall b a. (b -> a -> b) -> b -> IPBoundary' a -> b)
-> (forall b a. (b -> a -> b) -> b -> IPBoundary' a -> b)
-> (forall a. (a -> a -> a) -> IPBoundary' a -> a)
-> (forall a. (a -> a -> a) -> IPBoundary' a -> a)
-> (forall a. IPBoundary' a -> [a])
-> (forall a. IPBoundary' a -> Bool)
-> (forall a. IPBoundary' a -> Int)
-> (forall a. Eq a => a -> IPBoundary' a -> Bool)
-> (forall a. Ord a => IPBoundary' a -> a)
-> (forall a. Ord a => IPBoundary' a -> a)
-> (forall a. Num a => IPBoundary' a -> a)
-> (forall a. Num a => IPBoundary' a -> a)
-> Foldable IPBoundary'
forall a. Eq a => a -> IPBoundary' a -> Bool
forall a. Num a => IPBoundary' a -> a
forall a. Ord a => IPBoundary' a -> a
forall m. Monoid m => IPBoundary' m -> m
forall a. IPBoundary' a -> Bool
forall a. IPBoundary' a -> Int
forall a. IPBoundary' a -> [a]
forall a. (a -> a -> a) -> IPBoundary' a -> a
forall m a. Monoid m => (a -> m) -> IPBoundary' a -> m
forall b a. (b -> a -> b) -> b -> IPBoundary' a -> b
forall a b. (a -> b -> b) -> b -> IPBoundary' 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 :: IPBoundary' a -> a
$cproduct :: forall a. Num a => IPBoundary' a -> a
sum :: IPBoundary' a -> a
$csum :: forall a. Num a => IPBoundary' a -> a
minimum :: IPBoundary' a -> a
$cminimum :: forall a. Ord a => IPBoundary' a -> a
maximum :: IPBoundary' a -> a
$cmaximum :: forall a. Ord a => IPBoundary' a -> a
elem :: a -> IPBoundary' a -> Bool
$celem :: forall a. Eq a => a -> IPBoundary' a -> Bool
length :: IPBoundary' a -> Int
$clength :: forall a. IPBoundary' a -> Int
null :: IPBoundary' a -> Bool
$cnull :: forall a. IPBoundary' a -> Bool
toList :: IPBoundary' a -> [a]
$ctoList :: forall a. IPBoundary' a -> [a]
foldl1 :: (a -> a -> a) -> IPBoundary' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> IPBoundary' a -> a
foldr1 :: (a -> a -> a) -> IPBoundary' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> IPBoundary' a -> a
foldl' :: (b -> a -> b) -> b -> IPBoundary' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> IPBoundary' a -> b
foldl :: (b -> a -> b) -> b -> IPBoundary' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> IPBoundary' a -> b
foldr' :: (a -> b -> b) -> b -> IPBoundary' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> IPBoundary' a -> b
foldr :: (a -> b -> b) -> b -> IPBoundary' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> IPBoundary' a -> b
foldMap' :: (a -> m) -> IPBoundary' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> IPBoundary' a -> m
foldMap :: (a -> m) -> IPBoundary' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> IPBoundary' a -> m
fold :: IPBoundary' m -> m
$cfold :: forall m. Monoid m => IPBoundary' m -> m
Foldable, Functor IPBoundary'
Foldable IPBoundary'
Functor IPBoundary'
-> Foldable IPBoundary'
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> IPBoundary' a -> f (IPBoundary' b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    IPBoundary' (f a) -> f (IPBoundary' a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> IPBoundary' a -> m (IPBoundary' b))
-> (forall (m :: * -> *) a.
    Monad m =>
    IPBoundary' (m a) -> m (IPBoundary' a))
-> Traversable IPBoundary'
(a -> f b) -> IPBoundary' a -> f (IPBoundary' 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 =>
IPBoundary' (m a) -> m (IPBoundary' a)
forall (f :: * -> *) a.
Applicative f =>
IPBoundary' (f a) -> f (IPBoundary' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IPBoundary' a -> m (IPBoundary' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IPBoundary' a -> f (IPBoundary' b)
sequence :: IPBoundary' (m a) -> m (IPBoundary' a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
IPBoundary' (m a) -> m (IPBoundary' a)
mapM :: (a -> m b) -> IPBoundary' a -> m (IPBoundary' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IPBoundary' a -> m (IPBoundary' b)
sequenceA :: IPBoundary' (f a) -> f (IPBoundary' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
IPBoundary' (f a) -> f (IPBoundary' a)
traverse :: (a -> f b) -> IPBoundary' a -> f (IPBoundary' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IPBoundary' a -> f (IPBoundary' b)
$cp2Traversable :: Foldable IPBoundary'
$cp1Traversable :: Functor IPBoundary'
Traversable)

type IPBoundary = IPBoundary' Term

-- | Which clause is an interaction point located in?
data IPClause = IPClause
  { IPClause -> QName
ipcQName    :: QName              -- ^ The name of the function.
  , IPClause -> Int
ipcClauseNo :: Int                -- ^ The number of the clause of this function.
  , IPClause -> Type
ipcType     :: Type               -- ^ The type of the function
  , IPClause -> Maybe Substitution
ipcWithSub  :: Maybe Substitution -- ^ Module parameter substitution
  , IPClause -> SpineClause
ipcClause   :: A.SpineClause      -- ^ The original AST clause.
  , IPClause -> Closure ()
ipcClosure  :: Closure ()         -- ^ Environment for rechecking the clause.
  , IPClause -> [Closure IPBoundary]
ipcBoundary :: [Closure IPBoundary] -- ^ The boundary imposed by the LHS.
  }
  | IPNoClause -- ^ The interaction point is not in the rhs of a clause.
  deriving (Typeable IPClause
DataType
Constr
Typeable IPClause
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> IPClause -> c IPClause)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c IPClause)
-> (IPClause -> Constr)
-> (IPClause -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c IPClause))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IPClause))
-> ((forall b. Data b => b -> b) -> IPClause -> IPClause)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> IPClause -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> IPClause -> r)
-> (forall u. (forall d. Data d => d -> u) -> IPClause -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> IPClause -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> IPClause -> m IPClause)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> IPClause -> m IPClause)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> IPClause -> m IPClause)
-> Data IPClause
IPClause -> DataType
IPClause -> Constr
(forall b. Data b => b -> b) -> IPClause -> IPClause
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IPClause -> c IPClause
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IPClause
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) -> IPClause -> u
forall u. (forall d. Data d => d -> u) -> IPClause -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IPClause -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IPClause -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IPClause -> m IPClause
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IPClause -> m IPClause
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IPClause
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IPClause -> c IPClause
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IPClause)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IPClause)
$cIPNoClause :: Constr
$cIPClause :: Constr
$tIPClause :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> IPClause -> m IPClause
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IPClause -> m IPClause
gmapMp :: (forall d. Data d => d -> m d) -> IPClause -> m IPClause
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IPClause -> m IPClause
gmapM :: (forall d. Data d => d -> m d) -> IPClause -> m IPClause
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IPClause -> m IPClause
gmapQi :: Int -> (forall d. Data d => d -> u) -> IPClause -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> IPClause -> u
gmapQ :: (forall d. Data d => d -> u) -> IPClause -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> IPClause -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IPClause -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IPClause -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IPClause -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IPClause -> r
gmapT :: (forall b. Data b => b -> b) -> IPClause -> IPClause
$cgmapT :: (forall b. Data b => b -> b) -> IPClause -> IPClause
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IPClause)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IPClause)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c IPClause)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IPClause)
dataTypeOf :: IPClause -> DataType
$cdataTypeOf :: IPClause -> DataType
toConstr :: IPClause -> Constr
$ctoConstr :: IPClause -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IPClause
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IPClause
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IPClause -> c IPClause
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IPClause -> c IPClause
$cp1Data :: Typeable IPClause
Data)

instance Eq IPClause where
  IPClause
IPNoClause           == :: IPClause -> IPClause -> Bool
== IPClause
IPNoClause             = Bool
True
  IPClause QName
x Int
i Type
_ Maybe Substitution
_ SpineClause
_ Closure ()
_ [Closure IPBoundary]
_ == IPClause QName
x' Int
i' Type
_ Maybe Substitution
_ SpineClause
_ Closure ()
_ [Closure IPBoundary]
_ = QName
x QName -> QName -> Bool
forall a. Eq a => a -> a -> Bool
== QName
x' Bool -> Bool -> Bool
&& Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
i'
  IPClause
_                    == IPClause
_                      = Bool
False

---------------------------------------------------------------------------
-- ** Signature
---------------------------------------------------------------------------

data Signature = Sig
      { Signature -> Sections
_sigSections    :: Sections
      , Signature -> Definitions
_sigDefinitions :: Definitions
      , Signature -> RewriteRuleMap
_sigRewriteRules:: RewriteRuleMap  -- ^ The rewrite rules defined in this file.
      }
  deriving (Typeable Signature
DataType
Constr
Typeable Signature
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Signature -> c Signature)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Signature)
-> (Signature -> Constr)
-> (Signature -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Signature))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Signature))
-> ((forall b. Data b => b -> b) -> Signature -> Signature)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Signature -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Signature -> r)
-> (forall u. (forall d. Data d => d -> u) -> Signature -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Signature -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Signature -> m Signature)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Signature -> m Signature)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Signature -> m Signature)
-> Data Signature
Signature -> DataType
Signature -> Constr
(forall b. Data b => b -> b) -> Signature -> Signature
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Signature -> c Signature
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Signature
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) -> Signature -> u
forall u. (forall d. Data d => d -> u) -> Signature -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Signature -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Signature -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Signature -> m Signature
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Signature -> m Signature
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Signature
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Signature -> c Signature
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Signature)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Signature)
$cSig :: Constr
$tSignature :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Signature -> m Signature
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Signature -> m Signature
gmapMp :: (forall d. Data d => d -> m d) -> Signature -> m Signature
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Signature -> m Signature
gmapM :: (forall d. Data d => d -> m d) -> Signature -> m Signature
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Signature -> m Signature
gmapQi :: Int -> (forall d. Data d => d -> u) -> Signature -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Signature -> u
gmapQ :: (forall d. Data d => d -> u) -> Signature -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Signature -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Signature -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Signature -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Signature -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Signature -> r
gmapT :: (forall b. Data b => b -> b) -> Signature -> Signature
$cgmapT :: (forall b. Data b => b -> b) -> Signature -> Signature
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Signature)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Signature)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Signature)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Signature)
dataTypeOf :: Signature -> DataType
$cdataTypeOf :: Signature -> DataType
toConstr :: Signature -> Constr
$ctoConstr :: Signature -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Signature
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Signature
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Signature -> c Signature
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Signature -> c Signature
$cp1Data :: Typeable Signature
Data, Int -> Signature -> ShowS
[Signature] -> ShowS
Signature -> String
(Int -> Signature -> ShowS)
-> (Signature -> String)
-> ([Signature] -> ShowS)
-> Show Signature
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Signature] -> ShowS
$cshowList :: [Signature] -> ShowS
show :: Signature -> String
$cshow :: Signature -> String
showsPrec :: Int -> Signature -> ShowS
$cshowsPrec :: Int -> Signature -> ShowS
Show)

sigSections :: Lens' Sections Signature
sigSections :: (Sections -> f Sections) -> Signature -> f Signature
sigSections Sections -> f Sections
f Signature
s =
  Sections -> f Sections
f (Signature -> Sections
_sigSections Signature
s) f Sections -> (Sections -> Signature) -> f Signature
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Sections
x -> Signature
s {_sigSections :: Sections
_sigSections = Sections
x}

sigDefinitions :: Lens' Definitions Signature
sigDefinitions :: (Definitions -> f Definitions) -> Signature -> f Signature
sigDefinitions Definitions -> f Definitions
f Signature
s =
  Definitions -> f Definitions
f (Signature -> Definitions
_sigDefinitions Signature
s) f Definitions -> (Definitions -> Signature) -> f Signature
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Definitions
x -> Signature
s {_sigDefinitions :: Definitions
_sigDefinitions = Definitions
x}

sigRewriteRules :: Lens' RewriteRuleMap Signature
sigRewriteRules :: (RewriteRuleMap -> f RewriteRuleMap) -> Signature -> f Signature
sigRewriteRules RewriteRuleMap -> f RewriteRuleMap
f Signature
s =
  RewriteRuleMap -> f RewriteRuleMap
f (Signature -> RewriteRuleMap
_sigRewriteRules Signature
s) f RewriteRuleMap -> (RewriteRuleMap -> Signature) -> f Signature
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \RewriteRuleMap
x -> Signature
s {_sigRewriteRules :: RewriteRuleMap
_sigRewriteRules = RewriteRuleMap
x}

type Sections    = Map ModuleName Section
type Definitions = HashMap QName Definition
type RewriteRuleMap = HashMap QName RewriteRules
type DisplayForms = HashMap QName [LocalDisplayForm]

newtype Section = Section { Section -> Telescope
_secTelescope :: Telescope }
  deriving (Typeable Section
DataType
Constr
Typeable Section
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Section -> c Section)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Section)
-> (Section -> Constr)
-> (Section -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Section))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Section))
-> ((forall b. Data b => b -> b) -> Section -> Section)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Section -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Section -> r)
-> (forall u. (forall d. Data d => d -> u) -> Section -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Section -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Section -> m Section)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Section -> m Section)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Section -> m Section)
-> Data Section
Section -> DataType
Section -> Constr
(forall b. Data b => b -> b) -> Section -> Section
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Section -> c Section
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Section
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) -> Section -> u
forall u. (forall d. Data d => d -> u) -> Section -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Section -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Section -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Section -> m Section
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Section -> m Section
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Section
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Section -> c Section
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Section)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Section)
$cSection :: Constr
$tSection :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Section -> m Section
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Section -> m Section
gmapMp :: (forall d. Data d => d -> m d) -> Section -> m Section
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Section -> m Section
gmapM :: (forall d. Data d => d -> m d) -> Section -> m Section
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Section -> m Section
gmapQi :: Int -> (forall d. Data d => d -> u) -> Section -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Section -> u
gmapQ :: (forall d. Data d => d -> u) -> Section -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Section -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Section -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Section -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Section -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Section -> r
gmapT :: (forall b. Data b => b -> b) -> Section -> Section
$cgmapT :: (forall b. Data b => b -> b) -> Section -> Section
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Section)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Section)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Section)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Section)
dataTypeOf :: Section -> DataType
$cdataTypeOf :: Section -> DataType
toConstr :: Section -> Constr
$ctoConstr :: Section -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Section
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Section
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Section -> c Section
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Section -> c Section
$cp1Data :: Typeable Section
Data, Int -> Section -> ShowS
[Section] -> ShowS
Section -> String
(Int -> Section -> ShowS)
-> (Section -> String) -> ([Section] -> ShowS) -> Show Section
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Section] -> ShowS
$cshowList :: [Section] -> ShowS
show :: Section -> String
$cshow :: Section -> String
showsPrec :: Int -> Section -> ShowS
$cshowsPrec :: Int -> Section -> ShowS
Show)

instance Pretty Section where
  pretty :: Section -> Doc
pretty = Telescope -> Doc
forall a. Pretty a => a -> Doc
pretty (Telescope -> Doc) -> (Section -> Telescope) -> Section -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Section -> Telescope
_secTelescope

secTelescope :: Lens' Telescope Section
secTelescope :: (Telescope -> f Telescope) -> Section -> f Section
secTelescope Telescope -> f Telescope
f Section
s =
  Telescope -> f Telescope
f (Section -> Telescope
_secTelescope Section
s) f Telescope -> (Telescope -> Section) -> f Section
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \Telescope
x -> Section
s {_secTelescope :: Telescope
_secTelescope = Telescope
x}

emptySignature :: Signature
emptySignature :: Signature
emptySignature = Sections -> Definitions -> RewriteRuleMap -> Signature
Sig Sections
forall k a. Map k a
Map.empty Definitions
forall k v. HashMap k v
HMap.empty RewriteRuleMap
forall k v. HashMap k v
HMap.empty

-- | A @DisplayForm@ is in essence a rewrite rule
--   @
--      q ts --> dt
--   @
--   for a defined symbol (could be a constructor as well) @q@.
--   The right hand side is a 'DisplayTerm' which is used to
--   'reify' to a more readable 'Abstract.Syntax'.
--
--   The patterns @ts@ are just terms, but @var 0@ is interpreted
--   as a hole.  Each occurrence of @var 0@ is a new hole (pattern var).
--   For each *occurrence* of @var0@ the rhs @dt@ has a free variable.
--   These are instantiated when matching a display form against a
--   term @q vs@ succeeds.
data DisplayForm = Display
  { DisplayForm -> Int
dfFreeVars :: Nat
    -- ^ Number @n@ of free variables in 'dfRHS'.
  , DisplayForm -> [Elim]
dfPats     :: Elims
    -- ^ Left hand side patterns, where @var 0@ stands for a pattern
    --   variable.  There should be @n@ occurrences of @var0@ in
    --   'dfPats'.
    --   The 'ArgInfo' is ignored in these patterns.
  , DisplayForm -> DisplayTerm
dfRHS      :: DisplayTerm
    -- ^ Right hand side, with @n@ free variables.
  }
  deriving (Typeable DisplayForm
DataType
Constr
Typeable DisplayForm
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> DisplayForm -> c DisplayForm)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DisplayForm)
-> (DisplayForm -> Constr)
-> (DisplayForm -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DisplayForm))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c DisplayForm))
-> ((forall b. Data b => b -> b) -> DisplayForm -> DisplayForm)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DisplayForm -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DisplayForm -> r)
-> (forall u. (forall d. Data d => d -> u) -> DisplayForm -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DisplayForm -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm)
-> Data DisplayForm
DisplayForm -> DataType
DisplayForm -> Constr
(forall b. Data b => b -> b) -> DisplayForm -> DisplayForm
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DisplayForm -> c DisplayForm
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DisplayForm
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) -> DisplayForm -> u
forall u. (forall d. Data d => d -> u) -> DisplayForm -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayForm -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayForm -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DisplayForm
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DisplayForm -> c DisplayForm
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DisplayForm)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DisplayForm)
$cDisplay :: Constr
$tDisplayForm :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm
gmapMp :: (forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm
gmapM :: (forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DisplayForm -> m DisplayForm
gmapQi :: Int -> (forall d. Data d => d -> u) -> DisplayForm -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DisplayForm -> u
gmapQ :: (forall d. Data d => d -> u) -> DisplayForm -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DisplayForm -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayForm -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayForm -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayForm -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayForm -> r
gmapT :: (forall b. Data b => b -> b) -> DisplayForm -> DisplayForm
$cgmapT :: (forall b. Data b => b -> b) -> DisplayForm -> DisplayForm
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DisplayForm)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DisplayForm)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c DisplayForm)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DisplayForm)
dataTypeOf :: DisplayForm -> DataType
$cdataTypeOf :: DisplayForm -> DataType
toConstr :: DisplayForm -> Constr
$ctoConstr :: DisplayForm -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DisplayForm
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DisplayForm
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DisplayForm -> c DisplayForm
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DisplayForm -> c DisplayForm
$cp1Data :: Typeable DisplayForm
Data, Int -> DisplayForm -> ShowS
[DisplayForm] -> ShowS
DisplayForm -> String
(Int -> DisplayForm -> ShowS)
-> (DisplayForm -> String)
-> ([DisplayForm] -> ShowS)
-> Show DisplayForm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisplayForm] -> ShowS
$cshowList :: [DisplayForm] -> ShowS
show :: DisplayForm -> String
$cshow :: DisplayForm -> String
showsPrec :: Int -> DisplayForm -> ShowS
$cshowsPrec :: Int -> DisplayForm -> ShowS
Show)

type LocalDisplayForm = Open DisplayForm

-- | A structured presentation of a 'Term' for reification into
--   'Abstract.Syntax'.
data DisplayTerm
  = DWithApp DisplayTerm [DisplayTerm] Elims
    -- ^ @(f vs | ws) es@.
    --   The first 'DisplayTerm' is the parent function @f@ with its args @vs@.
    --   The list of 'DisplayTerm's are the with expressions @ws@.
    --   The 'Elims' are additional arguments @es@
    --   (possible in case the with-application is of function type)
    --   or projections (if it is of record type).
  | DCon ConHead ConInfo [Arg DisplayTerm]
    -- ^ @c vs@.
  | DDef QName [Elim' DisplayTerm]
    -- ^ @d vs@.
  | DDot Term
    -- ^ @.v@.
  | DTerm Term
    -- ^ @v@.
  deriving (Typeable DisplayTerm
DataType
Constr
Typeable DisplayTerm
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> DisplayTerm -> c DisplayTerm)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DisplayTerm)
-> (DisplayTerm -> Constr)
-> (DisplayTerm -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DisplayTerm))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c DisplayTerm))
-> ((forall b. Data b => b -> b) -> DisplayTerm -> DisplayTerm)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DisplayTerm -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DisplayTerm -> r)
-> (forall u. (forall d. Data d => d -> u) -> DisplayTerm -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DisplayTerm -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm)
-> Data DisplayTerm
DisplayTerm -> DataType
DisplayTerm -> Constr
(forall b. Data b => b -> b) -> DisplayTerm -> DisplayTerm
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DisplayTerm -> c DisplayTerm
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DisplayTerm
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) -> DisplayTerm -> u
forall u. (forall d. Data d => d -> u) -> DisplayTerm -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayTerm -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayTerm -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DisplayTerm
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DisplayTerm -> c DisplayTerm
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DisplayTerm)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DisplayTerm)
$cDTerm :: Constr
$cDDot :: Constr
$cDDef :: Constr
$cDCon :: Constr
$cDWithApp :: Constr
$tDisplayTerm :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm
gmapMp :: (forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm
gmapM :: (forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DisplayTerm -> m DisplayTerm
gmapQi :: Int -> (forall d. Data d => d -> u) -> DisplayTerm -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DisplayTerm -> u
gmapQ :: (forall d. Data d => d -> u) -> DisplayTerm -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DisplayTerm -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayTerm -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayTerm -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayTerm -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DisplayTerm -> r
gmapT :: (forall b. Data b => b -> b) -> DisplayTerm -> DisplayTerm
$cgmapT :: (forall b. Data b => b -> b) -> DisplayTerm -> DisplayTerm
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DisplayTerm)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DisplayTerm)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c DisplayTerm)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DisplayTerm)
dataTypeOf :: DisplayTerm -> DataType
$cdataTypeOf :: DisplayTerm -> DataType
toConstr :: DisplayTerm -> Constr
$ctoConstr :: DisplayTerm -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DisplayTerm
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DisplayTerm
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DisplayTerm -> c DisplayTerm
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DisplayTerm -> c DisplayTerm
$cp1Data :: Typeable DisplayTerm
Data, Int -> DisplayTerm -> ShowS
[DisplayTerm] -> ShowS
DisplayTerm -> String
(Int -> DisplayTerm -> ShowS)
-> (DisplayTerm -> String)
-> ([DisplayTerm] -> ShowS)
-> Show DisplayTerm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisplayTerm] -> ShowS
$cshowList :: [DisplayTerm] -> ShowS
show :: DisplayTerm -> String
$cshow :: DisplayTerm -> String
showsPrec :: Int -> DisplayTerm -> ShowS
$cshowsPrec :: Int -> DisplayTerm -> ShowS
Show)

instance Free DisplayForm where
  freeVars' :: DisplayForm -> FreeM a c
freeVars' (Display Int
n [Elim]
ps DisplayTerm
t) = FreeM a c -> FreeM a c
forall a b c (m :: * -> *) z.
MonadReader (FreeEnv' a b c) m =>
m z -> m z
underBinder ([Elim] -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' [Elim]
ps) FreeM a c -> FreeM a c -> FreeM a c
forall a. Monoid a => a -> a -> a
`mappend` Int -> FreeM a c -> FreeM a c
forall a b c (m :: * -> *) z.
MonadReader (FreeEnv' a b c) m =>
Int -> m z -> m z
underBinder' Int
n (DisplayTerm -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' DisplayTerm
t)

instance Free DisplayTerm where
  freeVars' :: DisplayTerm -> FreeM a c
freeVars' (DWithApp DisplayTerm
t [DisplayTerm]
ws [Elim]
es) = (DisplayTerm, ([DisplayTerm], [Elim])) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (DisplayTerm
t, ([DisplayTerm]
ws, [Elim]
es))
  freeVars' (DCon ConHead
_ ConInfo
_ [Arg DisplayTerm]
vs)      = [Arg DisplayTerm] -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' [Arg DisplayTerm]
vs
  freeVars' (DDef QName
_ [Elim' DisplayTerm]
es)        = [Elim' DisplayTerm] -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' [Elim' DisplayTerm]
es
  freeVars' (DDot Term
v)           = Term -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Term
v
  freeVars' (DTerm Term
v)          = Term -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' Term
v

instance Pretty DisplayTerm where
  prettyPrec :: Int -> DisplayTerm -> Doc
prettyPrec Int
p DisplayTerm
v =
    case DisplayTerm
v of
      DTerm Term
v          -> Int -> Term -> Doc
forall a. Pretty a => Int -> a -> Doc
prettyPrec Int
p Term
v
      DDot Term
v           -> Doc
"." Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Int -> Term -> Doc
forall a. Pretty a => Int -> a -> Doc
prettyPrec Int
10 Term
v
      DDef QName
f [Elim' DisplayTerm]
es        -> QName -> Doc
forall a. Pretty a => a -> Doc
pretty QName
f Doc -> [Elim' DisplayTerm] -> Doc
forall el. Pretty el => Doc -> [el] -> Doc
`pApp` [Elim' DisplayTerm]
es
      DCon ConHead
c ConInfo
_ [Arg DisplayTerm]
vs      -> QName -> Doc
forall a. Pretty a => a -> Doc
pretty (ConHead -> QName
conName ConHead
c) Doc -> [Elim' DisplayTerm] -> Doc
forall el. Pretty el => Doc -> [el] -> Doc
`pApp` (Arg DisplayTerm -> Elim' DisplayTerm)
-> [Arg DisplayTerm] -> [Elim' DisplayTerm]
forall a b. (a -> b) -> [a] -> [b]
map Arg DisplayTerm -> Elim' DisplayTerm
forall a. Arg a -> Elim' a
Apply [Arg DisplayTerm]
vs
      DWithApp DisplayTerm
h [DisplayTerm]
ws [Elim]
es ->
        Bool -> Doc -> Doc
mparens (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
          ([Doc] -> Doc
sep [ DisplayTerm -> Doc
forall a. Pretty a => a -> Doc
pretty DisplayTerm
h
              , Int -> Doc -> Doc
nest Int
2 (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ [Doc] -> Doc
fsep [ Doc
"|" Doc -> Doc -> Doc
<+> DisplayTerm -> Doc
forall a. Pretty a => a -> Doc
pretty DisplayTerm
w | DisplayTerm
w <- [DisplayTerm]
ws ] ])
        Doc -> [Elim] -> Doc
forall el. Pretty el => Doc -> [el] -> Doc
`pApp` [Elim]
es
    where
      pApp :: Pretty el => Doc -> [el] -> Doc
      pApp :: Doc -> [el] -> Doc
pApp Doc
d [el]
els = Bool -> Doc -> Doc
mparens (Bool -> Bool
not ([el] -> Bool
forall a. Null a => a -> Bool
null [el]
els) Bool -> Bool -> Bool
&& Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
9) (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$
                   [Doc] -> Doc
sep [Doc
d, Int -> Doc -> Doc
nest Int
2 (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ [Doc] -> Doc
fsep ((el -> Doc) -> [el] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> el -> Doc
forall a. Pretty a => Int -> a -> Doc
prettyPrec Int
10) [el]
els)]

-- | By default, we have no display form.
defaultDisplayForm :: QName -> [LocalDisplayForm]
defaultDisplayForm :: QName -> [LocalDisplayForm]
defaultDisplayForm QName
c = []

-- | Non-linear (non-constructor) first-order pattern.
data NLPat
  = PVar !Int [Arg Int]
    -- ^ Matches anything (modulo non-linearity) that only contains bound
    --   variables that occur in the given arguments.
  | PDef QName PElims
    -- ^ Matches @f es@
  | PLam ArgInfo (Abs NLPat)
    -- ^ Matches @λ x → t@
  | PPi (Dom NLPType) (Abs NLPType)
    -- ^ Matches @(x : A) → B@
  | PSort NLPSort
    -- ^ Matches a sort of the given shape.
  | PBoundVar {-# UNPACK #-} !Int PElims
    -- ^ Matches @x es@ where x is a lambda-bound variable
  | PTerm Term
    -- ^ Matches the term modulo β (ideally βη).
  deriving (Typeable NLPat
DataType
Constr
Typeable NLPat
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NLPat -> c NLPat)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c NLPat)
-> (NLPat -> Constr)
-> (NLPat -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c NLPat))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPat))
-> ((forall b. Data b => b -> b) -> NLPat -> NLPat)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NLPat -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NLPat -> r)
-> (forall u. (forall d. Data d => d -> u) -> NLPat -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> NLPat -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> NLPat -> m NLPat)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NLPat -> m NLPat)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NLPat -> m NLPat)
-> Data NLPat
NLPat -> DataType
NLPat -> Constr
(forall b. Data b => b -> b) -> NLPat -> NLPat
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPat -> c NLPat
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPat
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) -> NLPat -> u
forall u. (forall d. Data d => d -> u) -> NLPat -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NLPat -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NLPat -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NLPat -> m NLPat
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NLPat -> m NLPat
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPat
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPat -> c NLPat
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NLPat)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPat)
$cPTerm :: Constr
$cPBoundVar :: Constr
$cPSort :: Constr
$cPPi :: Constr
$cPLam :: Constr
$cPDef :: Constr
$cPVar :: Constr
$tNLPat :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> NLPat -> m NLPat
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NLPat -> m NLPat
gmapMp :: (forall d. Data d => d -> m d) -> NLPat -> m NLPat
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NLPat -> m NLPat
gmapM :: (forall d. Data d => d -> m d) -> NLPat -> m NLPat
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NLPat -> m NLPat
gmapQi :: Int -> (forall d. Data d => d -> u) -> NLPat -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NLPat -> u
gmapQ :: (forall d. Data d => d -> u) -> NLPat -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NLPat -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NLPat -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NLPat -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NLPat -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NLPat -> r
gmapT :: (forall b. Data b => b -> b) -> NLPat -> NLPat
$cgmapT :: (forall b. Data b => b -> b) -> NLPat -> NLPat
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPat)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPat)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NLPat)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NLPat)
dataTypeOf :: NLPat -> DataType
$cdataTypeOf :: NLPat -> DataType
toConstr :: NLPat -> Constr
$ctoConstr :: NLPat -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPat
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPat
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPat -> c NLPat
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPat -> c NLPat
$cp1Data :: Typeable NLPat
Data, Int -> NLPat -> ShowS
[NLPat] -> ShowS
NLPat -> String
(Int -> NLPat -> ShowS)
-> (NLPat -> String) -> ([NLPat] -> ShowS) -> Show NLPat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NLPat] -> ShowS
$cshowList :: [NLPat] -> ShowS
show :: NLPat -> String
$cshow :: NLPat -> String
showsPrec :: Int -> NLPat -> ShowS
$cshowsPrec :: Int -> NLPat -> ShowS
Show)
type PElims = [Elim' NLPat]

data NLPType = NLPType
  { NLPType -> NLPSort
nlpTypeSort :: NLPSort
  , NLPType -> NLPat
nlpTypeUnEl :: NLPat
  } deriving (Typeable NLPType
DataType
Constr
Typeable NLPType
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NLPType -> c NLPType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c NLPType)
-> (NLPType -> Constr)
-> (NLPType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c NLPType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPType))
-> ((forall b. Data b => b -> b) -> NLPType -> NLPType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NLPType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NLPType -> r)
-> (forall u. (forall d. Data d => d -> u) -> NLPType -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> NLPType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> NLPType -> m NLPType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NLPType -> m NLPType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NLPType -> m NLPType)
-> Data NLPType
NLPType -> DataType
NLPType -> Constr
(forall b. Data b => b -> b) -> NLPType -> NLPType
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPType -> c NLPType
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPType
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) -> NLPType -> u
forall u. (forall d. Data d => d -> u) -> NLPType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NLPType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NLPType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NLPType -> m NLPType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NLPType -> m NLPType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPType -> c NLPType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NLPType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPType)
$cNLPType :: Constr
$tNLPType :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> NLPType -> m NLPType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NLPType -> m NLPType
gmapMp :: (forall d. Data d => d -> m d) -> NLPType -> m NLPType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NLPType -> m NLPType
gmapM :: (forall d. Data d => d -> m d) -> NLPType -> m NLPType
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NLPType -> m NLPType
gmapQi :: Int -> (forall d. Data d => d -> u) -> NLPType -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NLPType -> u
gmapQ :: (forall d. Data d => d -> u) -> NLPType -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NLPType -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NLPType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NLPType -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NLPType -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NLPType -> r
gmapT :: (forall b. Data b => b -> b) -> NLPType -> NLPType
$cgmapT :: (forall b. Data b => b -> b) -> NLPType -> NLPType
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPType)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NLPType)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NLPType)
dataTypeOf :: NLPType -> DataType
$cdataTypeOf :: NLPType -> DataType
toConstr :: NLPType -> Constr
$ctoConstr :: NLPType -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPType
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPType -> c NLPType
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPType -> c NLPType
$cp1Data :: Typeable NLPType
Data, Int -> NLPType -> ShowS
[NLPType] -> ShowS
NLPType -> String
(Int -> NLPType -> ShowS)
-> (NLPType -> String) -> ([NLPType] -> ShowS) -> Show NLPType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NLPType] -> ShowS
$cshowList :: [NLPType] -> ShowS
show :: NLPType -> String
$cshow :: NLPType -> String
showsPrec :: Int -> NLPType -> ShowS
$cshowsPrec :: Int -> NLPType -> ShowS
Show)

data NLPSort
  = PType NLPat
  | PProp NLPat
  | PInf
  | PSizeUniv
  deriving (Typeable NLPSort
DataType
Constr
Typeable NLPSort
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NLPSort -> c NLPSort)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c NLPSort)
-> (NLPSort -> Constr)
-> (NLPSort -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c NLPSort))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPSort))
-> ((forall b. Data b => b -> b) -> NLPSort -> NLPSort)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NLPSort -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NLPSort -> r)
-> (forall u. (forall d. Data d => d -> u) -> NLPSort -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> NLPSort -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> NLPSort -> m NLPSort)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NLPSort -> m NLPSort)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NLPSort -> m NLPSort)
-> Data NLPSort
NLPSort -> DataType
NLPSort -> Constr
(forall b. Data b => b -> b) -> NLPSort -> NLPSort
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPSort -> c NLPSort
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPSort
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) -> NLPSort -> u
forall u. (forall d. Data d => d -> u) -> NLPSort -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NLPSort -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NLPSort -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NLPSort -> m NLPSort
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NLPSort -> m NLPSort
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPSort
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPSort -> c NLPSort
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NLPSort)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPSort)
$cPSizeUniv :: Constr
$cPInf :: Constr
$cPProp :: Constr
$cPType :: Constr
$tNLPSort :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> NLPSort -> m NLPSort
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NLPSort -> m NLPSort
gmapMp :: (forall d. Data d => d -> m d) -> NLPSort -> m NLPSort
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NLPSort -> m NLPSort
gmapM :: (forall d. Data d => d -> m d) -> NLPSort -> m NLPSort
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NLPSort -> m NLPSort
gmapQi :: Int -> (forall d. Data d => d -> u) -> NLPSort -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NLPSort -> u
gmapQ :: (forall d. Data d => d -> u) -> NLPSort -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NLPSort -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NLPSort -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NLPSort -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NLPSort -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NLPSort -> r
gmapT :: (forall b. Data b => b -> b) -> NLPSort -> NLPSort
$cgmapT :: (forall b. Data b => b -> b) -> NLPSort -> NLPSort
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPSort)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NLPSort)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NLPSort)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NLPSort)
dataTypeOf :: NLPSort -> DataType
$cdataTypeOf :: NLPSort -> DataType
toConstr :: NLPSort -> Constr
$ctoConstr :: NLPSort -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPSort
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NLPSort
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPSort -> c NLPSort
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NLPSort -> c NLPSort
$cp1Data :: Typeable NLPSort
Data, Int -> NLPSort -> ShowS
[NLPSort] -> ShowS
NLPSort -> String
(Int -> NLPSort -> ShowS)
-> (NLPSort -> String) -> ([NLPSort] -> ShowS) -> Show NLPSort
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NLPSort] -> ShowS
$cshowList :: [NLPSort] -> ShowS
show :: NLPSort -> String
$cshow :: NLPSort -> String
showsPrec :: Int -> NLPSort -> ShowS
$cshowsPrec :: Int -> NLPSort -> ShowS
Show)

type RewriteRules = [RewriteRule]

-- | Rewrite rules can be added independently from function clauses.
data RewriteRule = RewriteRule
  { RewriteRule -> QName
rewName    :: QName      -- ^ Name of rewrite rule @q : Γ → f ps ≡ rhs@
                             --   where @≡@ is the rewrite relation.
  , RewriteRule -> Telescope
rewContext :: Telescope  -- ^ @Γ@.
  , RewriteRule -> QName
rewHead    :: QName      -- ^ @f@.
  , RewriteRule -> PElims
rewPats    :: PElims     -- ^ @Γ ⊢ f ps : t@.
  , RewriteRule -> Term
rewRHS     :: Term       -- ^ @Γ ⊢ rhs : t@.
  , RewriteRule -> Type
rewType    :: Type       -- ^ @Γ ⊢ t@.
  }
    deriving (Typeable RewriteRule
DataType
Constr
Typeable RewriteRule
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> RewriteRule -> c RewriteRule)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RewriteRule)
-> (RewriteRule -> Constr)
-> (RewriteRule -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RewriteRule))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c RewriteRule))
-> ((forall b. Data b => b -> b) -> RewriteRule -> RewriteRule)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RewriteRule -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RewriteRule -> r)
-> (forall u. (forall d. Data d => d -> u) -> RewriteRule -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RewriteRule -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule)
-> Data RewriteRule
RewriteRule -> DataType
RewriteRule -> Constr
(forall b. Data b => b -> b) -> RewriteRule -> RewriteRule
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RewriteRule -> c RewriteRule
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RewriteRule
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) -> RewriteRule -> u
forall u. (forall d. Data d => d -> u) -> RewriteRule -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RewriteRule -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RewriteRule -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RewriteRule
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RewriteRule -> c RewriteRule
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RewriteRule)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RewriteRule)
$cRewriteRule :: Constr
$tRewriteRule :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule
gmapMp :: (forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule
gmapM :: (forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RewriteRule -> m RewriteRule
gmapQi :: Int -> (forall d. Data d => d -> u) -> RewriteRule -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RewriteRule -> u
gmapQ :: (forall d. Data d => d -> u) -> RewriteRule -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RewriteRule -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RewriteRule -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RewriteRule -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RewriteRule -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RewriteRule -> r
gmapT :: (forall b. Data b => b -> b) -> RewriteRule -> RewriteRule
$cgmapT :: (forall b. Data b => b -> b) -> RewriteRule -> RewriteRule
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RewriteRule)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RewriteRule)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c RewriteRule)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RewriteRule)
dataTypeOf :: RewriteRule -> DataType
$cdataTypeOf :: RewriteRule -> DataType
toConstr :: RewriteRule -> Constr
$ctoConstr :: RewriteRule -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RewriteRule
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RewriteRule
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RewriteRule -> c RewriteRule
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RewriteRule -> c RewriteRule
$cp1Data :: Typeable RewriteRule
Data, Int -> RewriteRule -> ShowS
[RewriteRule] -> ShowS
RewriteRule -> String
(Int -> RewriteRule -> ShowS)
-> (RewriteRule -> String)
-> ([RewriteRule] -> ShowS)
-> Show RewriteRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RewriteRule] -> ShowS
$cshowList :: [RewriteRule] -> ShowS
show :: RewriteRule -> String
$cshow :: RewriteRule -> String
showsPrec :: Int -> RewriteRule -> ShowS
$cshowsPrec :: Int -> RewriteRule -> ShowS
Show)

data Definition = Defn
  { Definition -> ArgInfo
defArgInfo        :: ArgInfo -- ^ Hiding should not be used.
  , Definition -> QName
defName           :: QName   -- ^ The canonical name, used e.g. in compilation.
  , Definition -> Type
defType           :: Type    -- ^ Type of the lifted definition.
  , Definition -> [Polarity]
defPolarity       :: [Polarity]
    -- ^ Variance information on arguments of the definition.
    --   Does not include info for dropped parameters to
    --   projection(-like) functions and constructors.
  , Definition -> [Occurrence]
defArgOccurrences :: [Occurrence]
    -- ^ Positivity information on arguments of the definition.
    --   Does not include info for dropped parameters to
    --   projection(-like) functions and constructors.

    --   Sometimes Agda looks up 'Occurrence's in these lists based on
    --   their position, so one might consider replacing the list
    --   with, say, an 'IntMap'. However, presumably these lists tend
    --   to be short, in which case 'IntMap's could be slower than
    --   lists. For instance, at one point the longest list
    --   encountered for the standard library (in serialised
    --   interfaces) had length 27. Distribution:
    --
    --   Length, number of lists
    --   -----------------------
    --
    --    0, 2444
    --    1,  721
    --    2,  433
    --    3,  668
    --    4,  602
    --    5,  624
    --    6,  626
    --    7,  484
    --    8,  375
    --    9,  264
    --   10,  305
    --   11,  188
    --   12,  171
    --   13,  108
    --   14,   84
    --   15,   80
    --   16,   38
    --   17,   23
    --   18,   16
    --   19,    8
    --   20,    7
    --   21,    5
    --   22,    2
    --   23,    3
    --   27,    1

  , Definition -> NumGeneralizableArgs
defArgGeneralizable :: NumGeneralizableArgs
    -- ^ How many arguments should be generalised.
  , Definition -> [Maybe Name]
defGeneralizedParams :: [Maybe Name]
    -- ^ Gives the name of the (bound variable) parameter for named generalized
    --   parameters. This is needed to bring it into scope when type checking
    --   the data/record definition corresponding to a type with generalized
    --   parameters.
  , Definition -> [LocalDisplayForm]
defDisplay        :: [LocalDisplayForm]
  , Definition -> MutualId
defMutual         :: MutualId
  , Definition -> CompiledRepresentation
defCompiledRep    :: CompiledRepresentation
  , Definition -> Maybe QName
defInstance       :: Maybe QName
    -- ^ @Just q@ when this definition is an instance of class q
  , Definition -> Bool
defCopy           :: Bool
    -- ^ Has this function been created by a module
                         -- instantiation?
  , Definition -> Set QName
defMatchable      :: Set QName
    -- ^ The set of symbols with rewrite rules that match against this symbol
  , Definition -> Bool
defNoCompilation  :: Bool
    -- ^ should compilers skip this? Used for e.g. cubical's comp
  , Definition -> Bool
defInjective      :: Bool
    -- ^ Should the def be treated as injective by the pattern matching unifier?
  , Definition -> Bool
defCopatternLHS   :: Bool
    -- ^ Is this a function defined by copatterns?
  , Definition -> Blocked_
defBlocked        :: Blocked_
    -- ^ What blocking tag to use when we cannot reduce this def?
    --   Used when checking a function definition is blocked on a meta
    --   in the type.
  , Definition -> Defn
theDef            :: Defn
  }
    deriving (Typeable Definition
DataType
Constr
Typeable Definition
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Definition -> c Definition)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Definition)
-> (Definition -> Constr)
-> (Definition -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Definition))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Definition))
-> ((forall b. Data b => b -> b) -> Definition -> Definition)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Definition -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Definition -> r)
-> (forall u. (forall d. Data d => d -> u) -> Definition -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Definition -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Definition -> m Definition)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Definition -> m Definition)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Definition -> m Definition)
-> Data Definition
Definition -> DataType
Definition -> Constr
(forall b. Data b => b -> b) -> Definition -> Definition
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Definition -> c Definition
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Definition
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) -> Definition -> u
forall u. (forall d. Data d => d -> u) -> Definition -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Definition -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Definition -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Definition -> m Definition
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Definition -> m Definition
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Definition
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Definition -> c Definition
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Definition)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Definition)
$cDefn :: Constr
$tDefinition :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Definition -> m Definition
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Definition -> m Definition
gmapMp :: (forall d. Data d => d -> m d) -> Definition -> m Definition
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Definition -> m Definition
gmapM :: (forall d. Data d => d -> m d) -> Definition -> m Definition
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Definition -> m Definition
gmapQi :: Int -> (forall d. Data d => d -> u) -> Definition -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Definition -> u
gmapQ :: (forall d. Data d => d -> u) -> Definition -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Definition -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Definition -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Definition -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Definition -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Definition -> r
gmapT :: (forall b. Data b => b -> b) -> Definition -> Definition
$cgmapT :: (forall b. Data b => b -> b) -> Definition -> Definition
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Definition)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Definition)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Definition)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Definition)
dataTypeOf :: Definition -> DataType
$cdataTypeOf :: Definition -> DataType
toConstr :: Definition -> Constr
$ctoConstr :: Definition -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Definition
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Definition
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Definition -> c Definition
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Definition -> c Definition
$cp1Data :: Typeable Definition
Data, Int -> Definition -> ShowS
[Definition] -> ShowS
Definition -> String
(Int -> Definition -> ShowS)
-> (Definition -> String)
-> ([Definition] -> ShowS)
-> Show Definition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Definition] -> ShowS
$cshowList :: [Definition] -> ShowS
show :: Definition -> String
$cshow :: Definition -> String
showsPrec :: Int -> Definition -> ShowS
$cshowsPrec :: Int -> Definition -> ShowS
Show)

instance LensArgInfo Definition where
  getArgInfo :: Definition -> ArgInfo
getArgInfo = Definition -> ArgInfo
defArgInfo
  mapArgInfo :: (ArgInfo -> ArgInfo) -> Definition -> Definition
mapArgInfo ArgInfo -> ArgInfo
f Definition
def = Definition
def { defArgInfo :: ArgInfo
defArgInfo = ArgInfo -> ArgInfo
f (ArgInfo -> ArgInfo) -> ArgInfo -> ArgInfo
forall a b. (a -> b) -> a -> b
$ Definition -> ArgInfo
defArgInfo Definition
def }

instance LensModality  Definition where
instance LensQuantity  Definition where
instance LensRelevance Definition where

data NumGeneralizableArgs
  = NoGeneralizableArgs
  | SomeGeneralizableArgs Int
    -- ^ When lambda-lifting new args are generalizable if
    --   'SomeGeneralizableArgs', also when the number is zero.
  deriving (Typeable NumGeneralizableArgs
DataType
Constr
Typeable NumGeneralizableArgs
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> NumGeneralizableArgs
    -> c NumGeneralizableArgs)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c NumGeneralizableArgs)
-> (NumGeneralizableArgs -> Constr)
-> (NumGeneralizableArgs -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c NumGeneralizableArgs))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c NumGeneralizableArgs))
-> ((forall b. Data b => b -> b)
    -> NumGeneralizableArgs -> NumGeneralizableArgs)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NumGeneralizableArgs -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NumGeneralizableArgs -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> NumGeneralizableArgs -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> NumGeneralizableArgs -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> NumGeneralizableArgs -> m NumGeneralizableArgs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> NumGeneralizableArgs -> m NumGeneralizableArgs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> NumGeneralizableArgs -> m NumGeneralizableArgs)
-> Data NumGeneralizableArgs
NumGeneralizableArgs -> DataType
NumGeneralizableArgs -> Constr
(forall b. Data b => b -> b)
-> NumGeneralizableArgs -> NumGeneralizableArgs
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> NumGeneralizableArgs
-> c NumGeneralizableArgs
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NumGeneralizableArgs
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) -> NumGeneralizableArgs -> u
forall u.
(forall d. Data d => d -> u) -> NumGeneralizableArgs -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NumGeneralizableArgs -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NumGeneralizableArgs -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> NumGeneralizableArgs -> m NumGeneralizableArgs
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NumGeneralizableArgs -> m NumGeneralizableArgs
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NumGeneralizableArgs
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> NumGeneralizableArgs
-> c NumGeneralizableArgs
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NumGeneralizableArgs)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NumGeneralizableArgs)
$cSomeGeneralizableArgs :: Constr
$cNoGeneralizableArgs :: Constr
$tNumGeneralizableArgs :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> NumGeneralizableArgs -> m NumGeneralizableArgs
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NumGeneralizableArgs -> m NumGeneralizableArgs
gmapMp :: (forall d. Data d => d -> m d)
-> NumGeneralizableArgs -> m NumGeneralizableArgs
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NumGeneralizableArgs -> m NumGeneralizableArgs
gmapM :: (forall d. Data d => d -> m d)
-> NumGeneralizableArgs -> m NumGeneralizableArgs
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> NumGeneralizableArgs -> m NumGeneralizableArgs
gmapQi :: Int -> (forall d. Data d => d -> u) -> NumGeneralizableArgs -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> NumGeneralizableArgs -> u
gmapQ :: (forall d. Data d => d -> u) -> NumGeneralizableArgs -> [u]
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> NumGeneralizableArgs -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NumGeneralizableArgs -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NumGeneralizableArgs -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NumGeneralizableArgs -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NumGeneralizableArgs -> r
gmapT :: (forall b. Data b => b -> b)
-> NumGeneralizableArgs -> NumGeneralizableArgs
$cgmapT :: (forall b. Data b => b -> b)
-> NumGeneralizableArgs -> NumGeneralizableArgs
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NumGeneralizableArgs)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NumGeneralizableArgs)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c NumGeneralizableArgs)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NumGeneralizableArgs)
dataTypeOf :: NumGeneralizableArgs -> DataType
$cdataTypeOf :: NumGeneralizableArgs -> DataType
toConstr :: NumGeneralizableArgs -> Constr
$ctoConstr :: NumGeneralizableArgs -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NumGeneralizableArgs
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NumGeneralizableArgs
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> NumGeneralizableArgs
-> c NumGeneralizableArgs
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> NumGeneralizableArgs
-> c NumGeneralizableArgs
$cp1Data :: Typeable NumGeneralizableArgs
Data, Int -> NumGeneralizableArgs -> ShowS
[NumGeneralizableArgs] -> ShowS
NumGeneralizableArgs -> String
(Int -> NumGeneralizableArgs -> ShowS)
-> (NumGeneralizableArgs -> String)
-> ([NumGeneralizableArgs] -> ShowS)
-> Show NumGeneralizableArgs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NumGeneralizableArgs] -> ShowS
$cshowList :: [NumGeneralizableArgs] -> ShowS
show :: NumGeneralizableArgs -> String
$cshow :: NumGeneralizableArgs -> String
showsPrec :: Int -> NumGeneralizableArgs -> ShowS
$cshowsPrec :: Int -> NumGeneralizableArgs -> ShowS
Show)

theDefLens :: Lens' Defn Definition
theDefLens :: (Defn -> f Defn) -> Definition -> f Definition
theDefLens Defn -> f Defn
f Definition
d = Defn -> f Defn
f (Definition -> Defn
theDef Definition
d) f Defn -> (Defn -> Definition) -> f Definition
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Defn
df -> Definition
d { theDef :: Defn
theDef = Defn
df }

-- | Create a definition with sensible defaults.
defaultDefn :: ArgInfo -> QName -> Type -> Defn -> Definition
defaultDefn :: ArgInfo -> QName -> Type -> Defn -> Definition
defaultDefn ArgInfo
info QName
x Type
t Defn
def = Defn :: ArgInfo
-> QName
-> Type
-> [Polarity]
-> [Occurrence]
-> NumGeneralizableArgs
-> [Maybe Name]
-> [LocalDisplayForm]
-> MutualId
-> CompiledRepresentation
-> Maybe QName
-> Bool
-> Set QName
-> Bool
-> Bool
-> Bool
-> Blocked_
-> Defn
-> Definition
Defn
  { defArgInfo :: ArgInfo
defArgInfo        = ArgInfo
info
  , defName :: QName
defName           = QName
x
  , defType :: Type
defType           = Type
t
  , defPolarity :: [Polarity]
defPolarity       = []
  , defArgOccurrences :: [Occurrence]
defArgOccurrences = []
  , defArgGeneralizable :: NumGeneralizableArgs
defArgGeneralizable = NumGeneralizableArgs
NoGeneralizableArgs
  , defGeneralizedParams :: [Maybe Name]
defGeneralizedParams = []
  , defDisplay :: [LocalDisplayForm]
defDisplay        = QName -> [LocalDisplayForm]
defaultDisplayForm QName
x
  , defMutual :: MutualId
defMutual         = MutualId
0
  , defCompiledRep :: CompiledRepresentation
defCompiledRep    = CompiledRepresentation
noCompiledRep
  , defInstance :: Maybe QName
defInstance       = Maybe QName
forall a. Maybe a
Nothing
  , defCopy :: Bool
defCopy           = Bool
False
  , defMatchable :: Set QName
defMatchable      = Set QName
forall a. Set a
Set.empty
  , defNoCompilation :: Bool
defNoCompilation  = Bool
False
  , defInjective :: Bool
defInjective      = Bool
False
  , defCopatternLHS :: Bool
defCopatternLHS   = Bool
False
  , defBlocked :: Blocked_
defBlocked        = NotBlocked -> () -> Blocked_
forall t. NotBlocked -> t -> Blocked t
NotBlocked NotBlocked
ReallyNotBlocked ()
  , theDef :: Defn
theDef            = Defn
def
  }

-- | Polarity for equality and subtype checking.
data Polarity
  = Covariant      -- ^ monotone
  | Contravariant  -- ^ antitone
  | Invariant      -- ^ no information (mixed variance)
  | Nonvariant     -- ^ constant
  deriving (Typeable Polarity
DataType
Constr
Typeable Polarity
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Polarity -> c Polarity)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Polarity)
-> (Polarity -> Constr)
-> (Polarity -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Polarity))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Polarity))
-> ((forall b. Data b => b -> b) -> Polarity -> Polarity)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Polarity -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Polarity -> r)
-> (forall u. (forall d. Data d => d -> u) -> Polarity -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Polarity -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Polarity -> m Polarity)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Polarity -> m Polarity)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Polarity -> m Polarity)
-> Data Polarity
Polarity -> DataType
Polarity -> Constr
(forall b. Data b => b -> b) -> Polarity -> Polarity
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Polarity -> c Polarity
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Polarity
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) -> Polarity -> u
forall u. (forall d. Data d => d -> u) -> Polarity -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Polarity -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Polarity -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Polarity -> m Polarity
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Polarity -> m Polarity
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Polarity
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Polarity -> c Polarity
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Polarity)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Polarity)
$cNonvariant :: Constr
$cInvariant :: Constr
$cContravariant :: Constr
$cCovariant :: Constr
$tPolarity :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Polarity -> m Polarity
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Polarity -> m Polarity
gmapMp :: (forall d. Data d => d -> m d) -> Polarity -> m Polarity
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Polarity -> m Polarity
gmapM :: (forall d. Data d => d -> m d) -> Polarity -> m Polarity
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Polarity -> m Polarity
gmapQi :: Int -> (forall d. Data d => d -> u) -> Polarity -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Polarity -> u
gmapQ :: (forall d. Data d => d -> u) -> Polarity -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Polarity -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Polarity -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Polarity -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Polarity -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Polarity -> r
gmapT :: (forall b. Data b => b -> b) -> Polarity -> Polarity
$cgmapT :: (forall b. Data b => b -> b) -> Polarity -> Polarity
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Polarity)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Polarity)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Polarity)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Polarity)
dataTypeOf :: Polarity -> DataType
$cdataTypeOf :: Polarity -> DataType
toConstr :: Polarity -> Constr
$ctoConstr :: Polarity -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Polarity
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Polarity
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Polarity -> c Polarity
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Polarity -> c Polarity
$cp1Data :: Typeable Polarity
Data, Int -> Polarity -> ShowS
[Polarity] -> ShowS
Polarity -> String
(Int -> Polarity -> ShowS)
-> (Polarity -> String) -> ([Polarity] -> ShowS) -> Show Polarity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Polarity] -> ShowS
$cshowList :: [Polarity] -> ShowS
show :: Polarity -> String
$cshow :: Polarity -> String
showsPrec :: Int -> Polarity -> ShowS
$cshowsPrec :: Int -> Polarity -> ShowS
Show, Polarity -> Polarity -> Bool
(Polarity -> Polarity -> Bool)
-> (Polarity -> Polarity -> Bool) -> Eq Polarity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Polarity -> Polarity -> Bool
$c/= :: Polarity -> Polarity -> Bool
== :: Polarity -> Polarity -> Bool
$c== :: Polarity -> Polarity -> Bool
Eq)

instance Pretty Polarity where
  pretty :: Polarity -> Doc
pretty = String -> Doc
text (String -> Doc) -> (Polarity -> String) -> Polarity -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
    Polarity
Covariant     -> String
"+"
    Polarity
Contravariant -> String
"-"
    Polarity
Invariant     -> String
"*"
    Polarity
Nonvariant    -> String
"_"

-- | Information about whether an argument is forced by the type of a function.
data IsForced
  = Forced
  | NotForced
  deriving (Typeable IsForced
DataType
Constr
Typeable IsForced
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> IsForced -> c IsForced)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c IsForced)
-> (IsForced -> Constr)
-> (IsForced -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c IsForced))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsForced))
-> ((forall b. Data b => b -> b) -> IsForced -> IsForced)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> IsForced -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> IsForced -> r)
-> (forall u. (forall d. Data d => d -> u) -> IsForced -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> IsForced -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> IsForced -> m IsForced)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> IsForced -> m IsForced)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> IsForced -> m IsForced)
-> Data IsForced
IsForced -> DataType
IsForced -> Constr
(forall b. Data b => b -> b) -> IsForced -> IsForced
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsForced -> c IsForced
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsForced
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) -> IsForced -> u
forall u. (forall d. Data d => d -> u) -> IsForced -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsForced -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsForced -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IsForced -> m IsForced
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IsForced -> m IsForced
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsForced
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsForced -> c IsForced
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IsForced)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsForced)
$cNotForced :: Constr
$cForced :: Constr
$tIsForced :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> IsForced -> m IsForced
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IsForced -> m IsForced
gmapMp :: (forall d. Data d => d -> m d) -> IsForced -> m IsForced
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IsForced -> m IsForced
gmapM :: (forall d. Data d => d -> m d) -> IsForced -> m IsForced
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IsForced -> m IsForced
gmapQi :: Int -> (forall d. Data d => d -> u) -> IsForced -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> IsForced -> u
gmapQ :: (forall d. Data d => d -> u) -> IsForced -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> IsForced -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsForced -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsForced -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsForced -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsForced -> r
gmapT :: (forall b. Data b => b -> b) -> IsForced -> IsForced
$cgmapT :: (forall b. Data b => b -> b) -> IsForced -> IsForced
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsForced)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsForced)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c IsForced)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IsForced)
dataTypeOf :: IsForced -> DataType
$cdataTypeOf :: IsForced -> DataType
toConstr :: IsForced -> Constr
$ctoConstr :: IsForced -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsForced
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsForced
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsForced -> c IsForced
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsForced -> c IsForced
$cp1Data :: Typeable IsForced
Data, Int -> IsForced -> ShowS
[IsForced] -> ShowS
IsForced -> String
(Int -> IsForced -> ShowS)
-> (IsForced -> String) -> ([IsForced] -> ShowS) -> Show IsForced
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IsForced] -> ShowS
$cshowList :: [IsForced] -> ShowS
show :: IsForced -> String
$cshow :: IsForced -> String
showsPrec :: Int -> IsForced -> ShowS
$cshowsPrec :: Int -> IsForced -> ShowS
Show, IsForced -> IsForced -> Bool
(IsForced -> IsForced -> Bool)
-> (IsForced -> IsForced -> Bool) -> Eq IsForced
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IsForced -> IsForced -> Bool
$c/= :: IsForced -> IsForced -> Bool
== :: IsForced -> IsForced -> Bool
$c== :: IsForced -> IsForced -> Bool
Eq)

-- | The backends are responsible for parsing their own pragmas.
data CompilerPragma = CompilerPragma Range String
  deriving (Typeable CompilerPragma
DataType
Constr
Typeable CompilerPragma
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CompilerPragma -> c CompilerPragma)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CompilerPragma)
-> (CompilerPragma -> Constr)
-> (CompilerPragma -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CompilerPragma))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CompilerPragma))
-> ((forall b. Data b => b -> b)
    -> CompilerPragma -> CompilerPragma)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CompilerPragma -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CompilerPragma -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> CompilerPragma -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CompilerPragma -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> CompilerPragma -> m CompilerPragma)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CompilerPragma -> m CompilerPragma)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CompilerPragma -> m CompilerPragma)
-> Data CompilerPragma
CompilerPragma -> DataType
CompilerPragma -> Constr
(forall b. Data b => b -> b) -> CompilerPragma -> CompilerPragma
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompilerPragma -> c CompilerPragma
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompilerPragma
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) -> CompilerPragma -> u
forall u. (forall d. Data d => d -> u) -> CompilerPragma -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CompilerPragma -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CompilerPragma -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CompilerPragma -> m CompilerPragma
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CompilerPragma -> m CompilerPragma
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompilerPragma
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompilerPragma -> c CompilerPragma
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CompilerPragma)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CompilerPragma)
$cCompilerPragma :: Constr
$tCompilerPragma :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> CompilerPragma -> m CompilerPragma
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CompilerPragma -> m CompilerPragma
gmapMp :: (forall d. Data d => d -> m d)
-> CompilerPragma -> m CompilerPragma
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CompilerPragma -> m CompilerPragma
gmapM :: (forall d. Data d => d -> m d)
-> CompilerPragma -> m CompilerPragma
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CompilerPragma -> m CompilerPragma
gmapQi :: Int -> (forall d. Data d => d -> u) -> CompilerPragma -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CompilerPragma -> u
gmapQ :: (forall d. Data d => d -> u) -> CompilerPragma -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CompilerPragma -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CompilerPragma -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CompilerPragma -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CompilerPragma -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CompilerPragma -> r
gmapT :: (forall b. Data b => b -> b) -> CompilerPragma -> CompilerPragma
$cgmapT :: (forall b. Data b => b -> b) -> CompilerPragma -> CompilerPragma
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CompilerPragma)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CompilerPragma)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CompilerPragma)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CompilerPragma)
dataTypeOf :: CompilerPragma -> DataType
$cdataTypeOf :: CompilerPragma -> DataType
toConstr :: CompilerPragma -> Constr
$ctoConstr :: CompilerPragma -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompilerPragma
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompilerPragma
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompilerPragma -> c CompilerPragma
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompilerPragma -> c CompilerPragma
$cp1Data :: Typeable CompilerPragma
Data, Int -> CompilerPragma -> ShowS
[CompilerPragma] -> ShowS
CompilerPragma -> String
(Int -> CompilerPragma -> ShowS)
-> (CompilerPragma -> String)
-> ([CompilerPragma] -> ShowS)
-> Show CompilerPragma
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompilerPragma] -> ShowS
$cshowList :: [CompilerPragma] -> ShowS
show :: CompilerPragma -> String
$cshow :: CompilerPragma -> String
showsPrec :: Int -> CompilerPragma -> ShowS
$cshowsPrec :: Int -> CompilerPragma -> ShowS
Show, CompilerPragma -> CompilerPragma -> Bool
(CompilerPragma -> CompilerPragma -> Bool)
-> (CompilerPragma -> CompilerPragma -> Bool) -> Eq CompilerPragma
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompilerPragma -> CompilerPragma -> Bool
$c/= :: CompilerPragma -> CompilerPragma -> Bool
== :: CompilerPragma -> CompilerPragma -> Bool
$c== :: CompilerPragma -> CompilerPragma -> Bool
Eq)

instance HasRange CompilerPragma where
  getRange :: CompilerPragma -> Range
getRange (CompilerPragma Range
r String
_) = Range
r

type BackendName    = String

jsBackendName, ghcBackendName :: BackendName
jsBackendName :: String
jsBackendName  = String
"JS"
ghcBackendName :: String
ghcBackendName = String
"GHC"

type CompiledRepresentation = Map BackendName [CompilerPragma]

noCompiledRep :: CompiledRepresentation
noCompiledRep :: CompiledRepresentation
noCompiledRep = CompiledRepresentation
forall k a. Map k a
Map.empty

-- A face represented as a list of equality constraints.
-- (r,False) ↦ (r = i0)
-- (r,True ) ↦ (r = i1)
type Face = [(Term,Bool)]

-- | An alternative representation of partial elements in a telescope:
--   Γ ⊢ λ Δ. [φ₁ u₁, ... , φₙ uₙ] : Δ → PartialP (∨_ᵢ φᵢ) T
--   see cubicaltt paper (however we do not store the type T).
data System = System
  { System -> Telescope
systemTel :: Telescope
    -- ^ the telescope Δ, binding vars for the clauses, Γ ⊢ Δ
  , System -> [(Face, Term)]
systemClauses :: [(Face,Term)]
    -- ^ a system [φ₁ u₁, ... , φₙ uₙ] where Γ, Δ ⊢ φᵢ and Γ, Δ, φᵢ ⊢ uᵢ
  } deriving (Typeable System
DataType
Constr
Typeable System
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> System -> c System)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c System)
-> (System -> Constr)
-> (System -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c System))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c System))
-> ((forall b. Data b => b -> b) -> System -> System)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> System -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> System -> r)
-> (forall u. (forall d. Data d => d -> u) -> System -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> System -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> System -> m System)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> System -> m System)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> System -> m System)
-> Data System
System -> DataType
System -> Constr
(forall b. Data b => b -> b) -> System -> System
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> System -> c System
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c System
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) -> System -> u
forall u. (forall d. Data d => d -> u) -> System -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> System -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> System -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> System -> m System
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> System -> m System
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c System
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> System -> c System
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c System)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c System)
$cSystem :: Constr
$tSystem :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> System -> m System
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> System -> m System
gmapMp :: (forall d. Data d => d -> m d) -> System -> m System
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> System -> m System
gmapM :: (forall d. Data d => d -> m d) -> System -> m System
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> System -> m System
gmapQi :: Int -> (forall d. Data d => d -> u) -> System -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> System -> u
gmapQ :: (forall d. Data d => d -> u) -> System -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> System -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> System -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> System -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> System -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> System -> r
gmapT :: (forall b. Data b => b -> b) -> System -> System
$cgmapT :: (forall b. Data b => b -> b) -> System -> System
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c System)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c System)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c System)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c System)
dataTypeOf :: System -> DataType
$cdataTypeOf :: System -> DataType
toConstr :: System -> Constr
$ctoConstr :: System -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c System
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c System
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> System -> c System
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> System -> c System
$cp1Data :: Typeable System
Data, Int -> System -> ShowS
[System] -> ShowS
System -> String
(Int -> System -> ShowS)
-> (System -> String) -> ([System] -> ShowS) -> Show System
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [System] -> ShowS
$cshowList :: [System] -> ShowS
show :: System -> String
$cshow :: System -> String
showsPrec :: Int -> System -> ShowS
$cshowsPrec :: Int -> System -> ShowS
Show)

-- | Additional information for extended lambdas.
data ExtLamInfo = ExtLamInfo
  { ExtLamInfo -> ModuleName
extLamModule    :: ModuleName
    -- ^ For complicated reasons the scope checker decides the QName of a
    --   pattern lambda, and thus its module. We really need to decide the
    --   module during type checking though, since if the lambda appears in a
    --   refined context the module picked by the scope checker has very much
    --   the wrong parameters.
  , ExtLamInfo -> Maybe System
extLamSys :: !(Strict.Maybe System)
  } deriving (Typeable ExtLamInfo
DataType
Constr
Typeable ExtLamInfo
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ExtLamInfo -> c ExtLamInfo)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ExtLamInfo)
-> (ExtLamInfo -> Constr)
-> (ExtLamInfo -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ExtLamInfo))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ExtLamInfo))
-> ((forall b. Data b => b -> b) -> ExtLamInfo -> ExtLamInfo)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ExtLamInfo -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ExtLamInfo -> r)
-> (forall u. (forall d. Data d => d -> u) -> ExtLamInfo -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ExtLamInfo -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo)
-> Data ExtLamInfo
ExtLamInfo -> DataType
ExtLamInfo -> Constr
(forall b. Data b => b -> b) -> ExtLamInfo -> ExtLamInfo
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExtLamInfo -> c ExtLamInfo
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExtLamInfo
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) -> ExtLamInfo -> u
forall u. (forall d. Data d => d -> u) -> ExtLamInfo -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExtLamInfo -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExtLamInfo -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExtLamInfo
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExtLamInfo -> c ExtLamInfo
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExtLamInfo)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ExtLamInfo)
$cExtLamInfo :: Constr
$tExtLamInfo :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo
gmapMp :: (forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo
gmapM :: (forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ExtLamInfo -> m ExtLamInfo
gmapQi :: Int -> (forall d. Data d => d -> u) -> ExtLamInfo -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ExtLamInfo -> u
gmapQ :: (forall d. Data d => d -> u) -> ExtLamInfo -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ExtLamInfo -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExtLamInfo -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExtLamInfo -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExtLamInfo -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExtLamInfo -> r
gmapT :: (forall b. Data b => b -> b) -> ExtLamInfo -> ExtLamInfo
$cgmapT :: (forall b. Data b => b -> b) -> ExtLamInfo -> ExtLamInfo
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ExtLamInfo)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ExtLamInfo)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ExtLamInfo)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExtLamInfo)
dataTypeOf :: ExtLamInfo -> DataType
$cdataTypeOf :: ExtLamInfo -> DataType
toConstr :: ExtLamInfo -> Constr
$ctoConstr :: ExtLamInfo -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExtLamInfo
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExtLamInfo
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExtLamInfo -> c ExtLamInfo
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExtLamInfo -> c ExtLamInfo
$cp1Data :: Typeable ExtLamInfo
Data, Int -> ExtLamInfo -> ShowS
[ExtLamInfo] -> ShowS
ExtLamInfo -> String
(Int -> ExtLamInfo -> ShowS)
-> (ExtLamInfo -> String)
-> ([ExtLamInfo] -> ShowS)
-> Show ExtLamInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExtLamInfo] -> ShowS
$cshowList :: [ExtLamInfo] -> ShowS
show :: ExtLamInfo -> String
$cshow :: ExtLamInfo -> String
showsPrec :: Int -> ExtLamInfo -> ShowS
$cshowsPrec :: Int -> ExtLamInfo -> ShowS
Show)

modifySystem :: (System -> System) -> ExtLamInfo -> ExtLamInfo
modifySystem :: (System -> System) -> ExtLamInfo -> ExtLamInfo
modifySystem System -> System
f ExtLamInfo
e = let !e' :: ExtLamInfo
e' = ExtLamInfo
e { extLamSys :: Maybe System
extLamSys = System -> System
f (System -> System) -> Maybe System -> Maybe System
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ExtLamInfo -> Maybe System
extLamSys ExtLamInfo
e } in ExtLamInfo
e'

-- | Additional information for projection 'Function's.
data Projection = Projection
  { Projection -> Maybe QName
projProper    :: Maybe QName
    -- ^ @Nothing@ if only projection-like, @Just r@ if record projection.
    --   The @r@ is the name of the record type projected from.
    --   This field is updated by module application.
  , Projection -> QName
projOrig      :: QName
    -- ^ The original projection name
    --   (current name could be from module application).
  , Projection -> Arg QName
projFromType  :: Arg QName
    -- ^ Type projected from. Original record type if @projProper = Just{}@.
    --   Also stores @ArgInfo@ of the principal argument.
    --   This field is unchanged by module application.
  , Projection -> Int
projIndex     :: Int
    -- ^ Index of the record argument.
    --   Start counting with 1, because 0 means that
    --   it is already applied to the record value.
    --   This can happen in module instantiation, but
    --   then either the record value is @var 0@, or @funProjection == Nothing@.
  , Projection -> ProjLams
projLams :: ProjLams
    -- ^ Term @t@ to be be applied to record parameters and record value.
    --   The parameters will be dropped.
    --   In case of a proper projection, a postfix projection application
    --   will be created: @t = \ pars r -> r .p@
    --   (Invariant: the number of abstractions equals 'projIndex'.)
    --   In case of a projection-like function, just the function symbol
    --   is returned as 'Def':  @t = \ pars -> f@.
  } deriving (Typeable Projection
DataType
Constr
Typeable Projection
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Projection -> c Projection)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Projection)
-> (Projection -> Constr)
-> (Projection -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Projection))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Projection))
-> ((forall b. Data b => b -> b) -> Projection -> Projection)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Projection -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Projection -> r)
-> (forall u. (forall d. Data d => d -> u) -> Projection -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Projection -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Projection -> m Projection)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Projection -> m Projection)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Projection -> m Projection)
-> Data Projection
Projection -> DataType
Projection -> Constr
(forall b. Data b => b -> b) -> Projection -> Projection
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Projection -> c Projection
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Projection
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) -> Projection -> u
forall u. (forall d. Data d => d -> u) -> Projection -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Projection -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Projection -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Projection -> m Projection
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Projection -> m Projection
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Projection
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Projection -> c Projection
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Projection)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Projection)
$cProjection :: Constr
$tProjection :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Projection -> m Projection
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Projection -> m Projection
gmapMp :: (forall d. Data d => d -> m d) -> Projection -> m Projection
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Projection -> m Projection
gmapM :: (forall d. Data d => d -> m d) -> Projection -> m Projection
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Projection -> m Projection
gmapQi :: Int -> (forall d. Data d => d -> u) -> Projection -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Projection -> u
gmapQ :: (forall d. Data d => d -> u) -> Projection -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Projection -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Projection -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Projection -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Projection -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Projection -> r
gmapT :: (forall b. Data b => b -> b) -> Projection -> Projection
$cgmapT :: (forall b. Data b => b -> b) -> Projection -> Projection
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Projection)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Projection)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Projection)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Projection)
dataTypeOf :: Projection -> DataType
$cdataTypeOf :: Projection -> DataType
toConstr :: Projection -> Constr
$ctoConstr :: Projection -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Projection
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Projection
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Projection -> c Projection
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Projection -> c Projection
$cp1Data :: Typeable Projection
Data, Int -> Projection -> ShowS
[Projection] -> ShowS
Projection -> String
(Int -> Projection -> ShowS)
-> (Projection -> String)
-> ([Projection] -> ShowS)
-> Show Projection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Projection] -> ShowS
$cshowList :: [Projection] -> ShowS
show :: Projection -> String
$cshow :: Projection -> String
showsPrec :: Int -> Projection -> ShowS
$cshowsPrec :: Int -> Projection -> ShowS
Show)

-- | Abstractions to build projection function (dropping parameters).
newtype ProjLams = ProjLams { ProjLams -> [Arg String]
getProjLams :: [Arg ArgName] }
  deriving (Typeable ProjLams
DataType
Constr
Typeable ProjLams
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ProjLams -> c ProjLams)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ProjLams)
-> (ProjLams -> Constr)
-> (ProjLams -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ProjLams))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ProjLams))
-> ((forall b. Data b => b -> b) -> ProjLams -> ProjLams)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ProjLams -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ProjLams -> r)
-> (forall u. (forall d. Data d => d -> u) -> ProjLams -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> ProjLams -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ProjLams -> m ProjLams)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ProjLams -> m ProjLams)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ProjLams -> m ProjLams)
-> Data ProjLams
ProjLams -> DataType
ProjLams -> Constr
(forall b. Data b => b -> b) -> ProjLams -> ProjLams
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProjLams -> c ProjLams
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProjLams
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) -> ProjLams -> u
forall u. (forall d. Data d => d -> u) -> ProjLams -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ProjLams -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ProjLams -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ProjLams -> m ProjLams
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ProjLams -> m ProjLams
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProjLams
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProjLams -> c ProjLams
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ProjLams)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ProjLams)
$cProjLams :: Constr
$tProjLams :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> ProjLams -> m ProjLams
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ProjLams -> m ProjLams
gmapMp :: (forall d. Data d => d -> m d) -> ProjLams -> m ProjLams
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ProjLams -> m ProjLams
gmapM :: (forall d. Data d => d -> m d) -> ProjLams -> m ProjLams
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ProjLams -> m ProjLams
gmapQi :: Int -> (forall d. Data d => d -> u) -> ProjLams -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ProjLams -> u
gmapQ :: (forall d. Data d => d -> u) -> ProjLams -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ProjLams -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ProjLams -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ProjLams -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ProjLams -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ProjLams -> r
gmapT :: (forall b. Data b => b -> b) -> ProjLams -> ProjLams
$cgmapT :: (forall b. Data b => b -> b) -> ProjLams -> ProjLams
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ProjLams)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ProjLams)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ProjLams)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ProjLams)
dataTypeOf :: ProjLams -> DataType
$cdataTypeOf :: ProjLams -> DataType
toConstr :: ProjLams -> Constr
$ctoConstr :: ProjLams -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProjLams
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ProjLams
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProjLams -> c ProjLams
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ProjLams -> c ProjLams
$cp1Data :: Typeable ProjLams
Data, Int -> ProjLams -> ShowS
[ProjLams] -> ShowS
ProjLams -> String
(Int -> ProjLams -> ShowS)
-> (ProjLams -> String) -> ([ProjLams] -> ShowS) -> Show ProjLams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProjLams] -> ShowS
$cshowList :: [ProjLams] -> ShowS
show :: ProjLams -> String
$cshow :: ProjLams -> String
showsPrec :: Int -> ProjLams -> ShowS
$cshowsPrec :: Int -> ProjLams -> ShowS
Show, ProjLams
ProjLams -> Bool
ProjLams -> (ProjLams -> Bool) -> Null ProjLams
forall a. a -> (a -> Bool) -> Null a
null :: ProjLams -> Bool
$cnull :: ProjLams -> Bool
empty :: ProjLams
$cempty :: ProjLams
Null)

-- | Building the projection function (which drops the parameters).
projDropPars :: Projection -> ProjOrigin -> Term
-- Proper projections:
projDropPars :: Projection -> ProjOrigin -> Term
projDropPars (Projection Just{} QName
d Arg QName
_ Int
_ ProjLams
lams) ProjOrigin
o =
  case [Arg String] -> Maybe ([Arg String], Arg String)
forall a. [a] -> Maybe ([a], a)
initLast ([Arg String] -> Maybe ([Arg String], Arg String))
-> [Arg String] -> Maybe ([Arg String], Arg String)
forall a b. (a -> b) -> a -> b
$ ProjLams -> [Arg String]
getProjLams ProjLams
lams of
    Maybe ([Arg String], Arg String)
Nothing -> QName -> [Elim] -> Term
Def QName
d []
    Just ([Arg String]
pars, Arg ArgInfo
i String
y) ->
      let core :: Term
core = ArgInfo -> Abs Term -> Term
Lam ArgInfo
i (Abs Term -> Term) -> Abs Term -> Term
forall a b. (a -> b) -> a -> b
$ String -> Term -> Abs Term
forall a. String -> a -> Abs a
Abs String
y (Term -> Abs Term) -> Term -> Abs Term
forall a b. (a -> b) -> a -> b
$ Int -> [Elim] -> Term
Var Int
0 [ProjOrigin -> QName -> Elim
forall a. ProjOrigin -> QName -> Elim' a
Proj ProjOrigin
o QName
d] in
      (Arg String -> Term -> Term) -> Term -> [Arg String] -> Term
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
List.foldr (\ (Arg ArgInfo
ai String
x) -> ArgInfo -> Abs Term -> Term
Lam ArgInfo
ai (Abs Term -> Term) -> (Term -> Abs Term) -> Term -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Term -> Abs Term
forall a. String -> a -> Abs a
NoAbs String
x) Term
core [Arg String]
pars
-- Projection-like functions:
projDropPars (Projection Maybe QName
Nothing QName
_ Arg QName
_ Int
_ ProjLams
lams) ProjOrigin
o | ProjLams -> Bool
forall a. Null a => a -> Bool
null ProjLams
lams = Term
forall a. HasCallStack => a
__IMPOSSIBLE__
projDropPars (Projection Maybe QName
Nothing QName
d Arg QName
_ Int
_ ProjLams
lams) ProjOrigin
o =
  (Arg String -> Term -> Term) -> Term -> [Arg String] -> Term
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
List.foldr (\ (Arg ArgInfo
ai String
x) -> ArgInfo -> Abs Term -> Term
Lam ArgInfo
ai (Abs Term -> Term) -> (Term -> Abs Term) -> Term -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Term -> Abs Term
forall a. String -> a -> Abs a
NoAbs String
x) (QName -> [Elim] -> Term
Def QName
d []) ([Arg String] -> Term) -> [Arg String] -> Term
forall a b. (a -> b) -> a -> b
$ [Arg String] -> [Arg String]
forall a. [a] -> [a]
init ([Arg String] -> [Arg String]) -> [Arg String] -> [Arg String]
forall a b. (a -> b) -> a -> b
$ ProjLams -> [Arg String]
getProjLams ProjLams
lams

-- | The info of the principal (record) argument.
projArgInfo :: Projection -> ArgInfo
projArgInfo :: Projection -> ArgInfo
projArgInfo (Projection Maybe QName
_ QName
_ Arg QName
_ Int
_ ProjLams
lams) =
  ArgInfo -> (Arg String -> ArgInfo) -> Maybe (Arg String) -> ArgInfo
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ArgInfo
forall a. HasCallStack => a
__IMPOSSIBLE__ Arg String -> ArgInfo
forall a. LensArgInfo a => a -> ArgInfo
getArgInfo (Maybe (Arg String) -> ArgInfo) -> Maybe (Arg String) -> ArgInfo
forall a b. (a -> b) -> a -> b
$ [Arg String] -> Maybe (Arg String)
forall a. [a] -> Maybe a
lastMaybe ([Arg String] -> Maybe (Arg String))
-> [Arg String] -> Maybe (Arg String)
forall a b. (a -> b) -> a -> b
$ ProjLams -> [Arg String]
getProjLams ProjLams
lams

-- | Should a record type admit eta-equality?
data EtaEquality
  = Specified { EtaEquality -> HasEta
theEtaEquality :: !HasEta }  -- ^ User specifed 'eta-equality' or 'no-eta-equality'.
  | Inferred  { theEtaEquality :: !HasEta }  -- ^ Positivity checker inferred whether eta is safe.
  deriving (Typeable EtaEquality
DataType
Constr
Typeable EtaEquality
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> EtaEquality -> c EtaEquality)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c EtaEquality)
-> (EtaEquality -> Constr)
-> (EtaEquality -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c EtaEquality))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c EtaEquality))
-> ((forall b. Data b => b -> b) -> EtaEquality -> EtaEquality)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EtaEquality -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EtaEquality -> r)
-> (forall u. (forall d. Data d => d -> u) -> EtaEquality -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> EtaEquality -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality)
-> Data EtaEquality
EtaEquality -> DataType
EtaEquality -> Constr
(forall b. Data b => b -> b) -> EtaEquality -> EtaEquality
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EtaEquality -> c EtaEquality
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EtaEquality
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) -> EtaEquality -> u
forall u. (forall d. Data d => d -> u) -> EtaEquality -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EtaEquality -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EtaEquality -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EtaEquality
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EtaEquality -> c EtaEquality
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EtaEquality)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EtaEquality)
$cInferred :: Constr
$cSpecified :: Constr
$tEtaEquality :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality
gmapMp :: (forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality
gmapM :: (forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EtaEquality -> m EtaEquality
gmapQi :: Int -> (forall d. Data d => d -> u) -> EtaEquality -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EtaEquality -> u
gmapQ :: (forall d. Data d => d -> u) -> EtaEquality -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EtaEquality -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EtaEquality -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EtaEquality -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EtaEquality -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EtaEquality -> r
gmapT :: (forall b. Data b => b -> b) -> EtaEquality -> EtaEquality
$cgmapT :: (forall b. Data b => b -> b) -> EtaEquality -> EtaEquality
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EtaEquality)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EtaEquality)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c EtaEquality)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EtaEquality)
dataTypeOf :: EtaEquality -> DataType
$cdataTypeOf :: EtaEquality -> DataType
toConstr :: EtaEquality -> Constr
$ctoConstr :: EtaEquality -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EtaEquality
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EtaEquality
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EtaEquality -> c EtaEquality
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EtaEquality -> c EtaEquality
$cp1Data :: Typeable EtaEquality
Data, Int -> EtaEquality -> ShowS
[EtaEquality] -> ShowS
EtaEquality -> String
(Int -> EtaEquality -> ShowS)
-> (EtaEquality -> String)
-> ([EtaEquality] -> ShowS)
-> Show EtaEquality
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EtaEquality] -> ShowS
$cshowList :: [EtaEquality] -> ShowS
show :: EtaEquality -> String
$cshow :: EtaEquality -> String
showsPrec :: Int -> EtaEquality -> ShowS
$cshowsPrec :: Int -> EtaEquality -> ShowS
Show, EtaEquality -> EtaEquality -> Bool
(EtaEquality -> EtaEquality -> Bool)
-> (EtaEquality -> EtaEquality -> Bool) -> Eq EtaEquality
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EtaEquality -> EtaEquality -> Bool
$c/= :: EtaEquality -> EtaEquality -> Bool
== :: EtaEquality -> EtaEquality -> Bool
$c== :: EtaEquality -> EtaEquality -> Bool
Eq)

-- | Make sure we do not overwrite a user specification.
setEtaEquality :: EtaEquality -> HasEta -> EtaEquality
setEtaEquality :: EtaEquality -> HasEta -> EtaEquality
setEtaEquality e :: EtaEquality
e@Specified{} HasEta
_ = EtaEquality
e
setEtaEquality EtaEquality
_ HasEta
b = HasEta -> EtaEquality
Inferred HasEta
b

data FunctionFlag
  = FunStatic  -- ^ Should calls to this function be normalised at compile-time?
  | FunInline  -- ^ Should calls to this function be inlined by the compiler?
  | FunMacro   -- ^ Is this function a macro?
  deriving (Typeable FunctionFlag
DataType
Constr
Typeable FunctionFlag
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> FunctionFlag -> c FunctionFlag)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c FunctionFlag)
-> (FunctionFlag -> Constr)
-> (FunctionFlag -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c FunctionFlag))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c FunctionFlag))
-> ((forall b. Data b => b -> b) -> FunctionFlag -> FunctionFlag)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> FunctionFlag -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> FunctionFlag -> r)
-> (forall u. (forall d. Data d => d -> u) -> FunctionFlag -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> FunctionFlag -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag)
-> Data FunctionFlag
FunctionFlag -> DataType
FunctionFlag -> Constr
(forall b. Data b => b -> b) -> FunctionFlag -> FunctionFlag
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunctionFlag -> c FunctionFlag
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunctionFlag
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) -> FunctionFlag -> u
forall u. (forall d. Data d => d -> u) -> FunctionFlag -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionFlag -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionFlag -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunctionFlag
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunctionFlag -> c FunctionFlag
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FunctionFlag)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FunctionFlag)
$cFunMacro :: Constr
$cFunInline :: Constr
$cFunStatic :: Constr
$tFunctionFlag :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag
gmapMp :: (forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag
gmapM :: (forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FunctionFlag -> m FunctionFlag
gmapQi :: Int -> (forall d. Data d => d -> u) -> FunctionFlag -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FunctionFlag -> u
gmapQ :: (forall d. Data d => d -> u) -> FunctionFlag -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> FunctionFlag -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionFlag -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionFlag -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionFlag -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionFlag -> r
gmapT :: (forall b. Data b => b -> b) -> FunctionFlag -> FunctionFlag
$cgmapT :: (forall b. Data b => b -> b) -> FunctionFlag -> FunctionFlag
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FunctionFlag)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FunctionFlag)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c FunctionFlag)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FunctionFlag)
dataTypeOf :: FunctionFlag -> DataType
$cdataTypeOf :: FunctionFlag -> DataType
toConstr :: FunctionFlag -> Constr
$ctoConstr :: FunctionFlag -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunctionFlag
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunctionFlag
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunctionFlag -> c FunctionFlag
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunctionFlag -> c FunctionFlag
$cp1Data :: Typeable FunctionFlag
Data, FunctionFlag -> FunctionFlag -> Bool
(FunctionFlag -> FunctionFlag -> Bool)
-> (FunctionFlag -> FunctionFlag -> Bool) -> Eq FunctionFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionFlag -> FunctionFlag -> Bool
$c/= :: FunctionFlag -> FunctionFlag -> Bool
== :: FunctionFlag -> FunctionFlag -> Bool
$c== :: FunctionFlag -> FunctionFlag -> Bool
Eq, Eq FunctionFlag
Eq FunctionFlag
-> (FunctionFlag -> FunctionFlag -> Ordering)
-> (FunctionFlag -> FunctionFlag -> Bool)
-> (FunctionFlag -> FunctionFlag -> Bool)
-> (FunctionFlag -> FunctionFlag -> Bool)
-> (FunctionFlag -> FunctionFlag -> Bool)
-> (FunctionFlag -> FunctionFlag -> FunctionFlag)
-> (FunctionFlag -> FunctionFlag -> FunctionFlag)
-> Ord FunctionFlag
FunctionFlag -> FunctionFlag -> Bool
FunctionFlag -> FunctionFlag -> Ordering
FunctionFlag -> FunctionFlag -> FunctionFlag
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 :: FunctionFlag -> FunctionFlag -> FunctionFlag
$cmin :: FunctionFlag -> FunctionFlag -> FunctionFlag
max :: FunctionFlag -> FunctionFlag -> FunctionFlag
$cmax :: FunctionFlag -> FunctionFlag -> FunctionFlag
>= :: FunctionFlag -> FunctionFlag -> Bool
$c>= :: FunctionFlag -> FunctionFlag -> Bool
> :: FunctionFlag -> FunctionFlag -> Bool
$c> :: FunctionFlag -> FunctionFlag -> Bool
<= :: FunctionFlag -> FunctionFlag -> Bool
$c<= :: FunctionFlag -> FunctionFlag -> Bool
< :: FunctionFlag -> FunctionFlag -> Bool
$c< :: FunctionFlag -> FunctionFlag -> Bool
compare :: FunctionFlag -> FunctionFlag -> Ordering
$ccompare :: FunctionFlag -> FunctionFlag -> Ordering
$cp1Ord :: Eq FunctionFlag
Ord, Int -> FunctionFlag
FunctionFlag -> Int
FunctionFlag -> [FunctionFlag]
FunctionFlag -> FunctionFlag
FunctionFlag -> FunctionFlag -> [FunctionFlag]
FunctionFlag -> FunctionFlag -> FunctionFlag -> [FunctionFlag]
(FunctionFlag -> FunctionFlag)
-> (FunctionFlag -> FunctionFlag)
-> (Int -> FunctionFlag)
-> (FunctionFlag -> Int)
-> (FunctionFlag -> [FunctionFlag])
-> (FunctionFlag -> FunctionFlag -> [FunctionFlag])
-> (FunctionFlag -> FunctionFlag -> [FunctionFlag])
-> (FunctionFlag -> FunctionFlag -> FunctionFlag -> [FunctionFlag])
-> Enum FunctionFlag
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: FunctionFlag -> FunctionFlag -> FunctionFlag -> [FunctionFlag]
$cenumFromThenTo :: FunctionFlag -> FunctionFlag -> FunctionFlag -> [FunctionFlag]
enumFromTo :: FunctionFlag -> FunctionFlag -> [FunctionFlag]
$cenumFromTo :: FunctionFlag -> FunctionFlag -> [FunctionFlag]
enumFromThen :: FunctionFlag -> FunctionFlag -> [FunctionFlag]
$cenumFromThen :: FunctionFlag -> FunctionFlag -> [FunctionFlag]
enumFrom :: FunctionFlag -> [FunctionFlag]
$cenumFrom :: FunctionFlag -> [FunctionFlag]
fromEnum :: FunctionFlag -> Int
$cfromEnum :: FunctionFlag -> Int
toEnum :: Int -> FunctionFlag
$ctoEnum :: Int -> FunctionFlag
pred :: FunctionFlag -> FunctionFlag
$cpred :: FunctionFlag -> FunctionFlag
succ :: FunctionFlag -> FunctionFlag
$csucc :: FunctionFlag -> FunctionFlag
Enum, Int -> FunctionFlag -> ShowS
[FunctionFlag] -> ShowS
FunctionFlag -> String
(Int -> FunctionFlag -> ShowS)
-> (FunctionFlag -> String)
-> ([FunctionFlag] -> ShowS)
-> Show FunctionFlag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionFlag] -> ShowS
$cshowList :: [FunctionFlag] -> ShowS
show :: FunctionFlag -> String
$cshow :: FunctionFlag -> String
showsPrec :: Int -> FunctionFlag -> ShowS
$cshowsPrec :: Int -> FunctionFlag -> ShowS
Show)

data CompKit = CompKit
  { CompKit -> Maybe QName
nameOfHComp :: Maybe QName
  , CompKit -> Maybe QName
nameOfTransp :: Maybe QName
  }
  deriving (Typeable CompKit
DataType
Constr
Typeable CompKit
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CompKit -> c CompKit)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CompKit)
-> (CompKit -> Constr)
-> (CompKit -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CompKit))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CompKit))
-> ((forall b. Data b => b -> b) -> CompKit -> CompKit)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CompKit -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CompKit -> r)
-> (forall u. (forall d. Data d => d -> u) -> CompKit -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> CompKit -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CompKit -> m CompKit)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CompKit -> m CompKit)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CompKit -> m CompKit)
-> Data CompKit
CompKit -> DataType
CompKit -> Constr
(forall b. Data b => b -> b) -> CompKit -> CompKit
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompKit -> c CompKit
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompKit
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) -> CompKit -> u
forall u. (forall d. Data d => d -> u) -> CompKit -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CompKit -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CompKit -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CompKit -> m CompKit
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CompKit -> m CompKit
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompKit
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompKit -> c CompKit
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CompKit)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CompKit)
$cCompKit :: Constr
$tCompKit :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> CompKit -> m CompKit
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CompKit -> m CompKit
gmapMp :: (forall d. Data d => d -> m d) -> CompKit -> m CompKit
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CompKit -> m CompKit
gmapM :: (forall d. Data d => d -> m d) -> CompKit -> m CompKit
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CompKit -> m CompKit
gmapQi :: Int -> (forall d. Data d => d -> u) -> CompKit -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CompKit -> u
gmapQ :: (forall d. Data d => d -> u) -> CompKit -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CompKit -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CompKit -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CompKit -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CompKit -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CompKit -> r
gmapT :: (forall b. Data b => b -> b) -> CompKit -> CompKit
$cgmapT :: (forall b. Data b => b -> b) -> CompKit -> CompKit
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CompKit)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CompKit)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CompKit)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CompKit)
dataTypeOf :: CompKit -> DataType
$cdataTypeOf :: CompKit -> DataType
toConstr :: CompKit -> Constr
$ctoConstr :: CompKit -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompKit
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CompKit
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompKit -> c CompKit
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CompKit -> c CompKit
$cp1Data :: Typeable CompKit
Data, CompKit -> CompKit -> Bool
(CompKit -> CompKit -> Bool)
-> (CompKit -> CompKit -> Bool) -> Eq CompKit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompKit -> CompKit -> Bool
$c/= :: CompKit -> CompKit -> Bool
== :: CompKit -> CompKit -> Bool
$c== :: CompKit -> CompKit -> Bool
Eq, Eq CompKit
Eq CompKit
-> (CompKit -> CompKit -> Ordering)
-> (CompKit -> CompKit -> Bool)
-> (CompKit -> CompKit -> Bool)
-> (CompKit -> CompKit -> Bool)
-> (CompKit -> CompKit -> Bool)
-> (CompKit -> CompKit -> CompKit)
-> (CompKit -> CompKit -> CompKit)
-> Ord CompKit
CompKit -> CompKit -> Bool
CompKit -> CompKit -> Ordering
CompKit -> CompKit -> CompKit
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 :: CompKit -> CompKit -> CompKit
$cmin :: CompKit -> CompKit -> CompKit
max :: CompKit -> CompKit -> CompKit
$cmax :: CompKit -> CompKit -> CompKit
>= :: CompKit -> CompKit -> Bool
$c>= :: CompKit -> CompKit -> Bool
> :: CompKit -> CompKit -> Bool
$c> :: CompKit -> CompKit -> Bool
<= :: CompKit -> CompKit -> Bool
$c<= :: CompKit -> CompKit -> Bool
< :: CompKit -> CompKit -> Bool
$c< :: CompKit -> CompKit -> Bool
compare :: CompKit -> CompKit -> Ordering
$ccompare :: CompKit -> CompKit -> Ordering
$cp1Ord :: Eq CompKit
Ord, Int -> CompKit -> ShowS
[CompKit] -> ShowS
CompKit -> String
(Int -> CompKit -> ShowS)
-> (CompKit -> String) -> ([CompKit] -> ShowS) -> Show CompKit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompKit] -> ShowS
$cshowList :: [CompKit] -> ShowS
show :: CompKit -> String
$cshow :: CompKit -> String
showsPrec :: Int -> CompKit -> ShowS
$cshowsPrec :: Int -> CompKit -> ShowS
Show)

emptyCompKit :: CompKit
emptyCompKit :: CompKit
emptyCompKit = Maybe QName -> Maybe QName -> CompKit
CompKit Maybe QName
forall a. Maybe a
Nothing Maybe QName
forall a. Maybe a
Nothing

data Defn = Axiom -- ^ Postulate
          | DataOrRecSig
            { Defn -> Int
datarecPars :: Int }
            -- ^ Data or record type signature that doesn't yet have a definition
          | GeneralizableVar -- ^ Generalizable variable (introduced in `generalize` block)
          | AbstractDefn Defn
            -- ^ Returned by 'getConstInfo' if definition is abstract.
          | Function
            { Defn -> [Clause]
funClauses        :: [Clause]
            , Defn -> Maybe CompiledClauses
funCompiled       :: Maybe CompiledClauses
              -- ^ 'Nothing' while function is still type-checked.
              --   @Just cc@ after type and coverage checking and
              --   translation to case trees.
            , Defn -> Maybe SplitTree
funSplitTree      :: Maybe SplitTree
              -- ^ The split tree constructed by the coverage
              --   checker. Needed to re-compile the clauses after
              --   forcing translation.
            , Defn -> Maybe Compiled
funTreeless       :: Maybe Compiled
              -- ^ Intermediate representation for compiler backends.
            , Defn -> [Clause]
funCovering       :: [Clause]
              -- ^ Covering clauses computed by coverage checking.
              --   Erased by (IApply) confluence checking(?)
            , Defn -> FunctionInverse
funInv            :: FunctionInverse
            , Defn -> Maybe [QName]
funMutual         :: Maybe [QName]
              -- ^ Mutually recursive functions, @data@s and @record@s.
              --   Does include this function.
              --   Empty list if not recursive.
              --   @Nothing@ if not yet computed (by positivity checker).
            , Defn -> IsAbstract
funAbstr          :: IsAbstract
            , Defn -> Delayed
funDelayed        :: Delayed
              -- ^ Are the clauses of this definition delayed?
            , Defn -> Maybe Projection
funProjection     :: Maybe Projection
              -- ^ Is it a record projection?
              --   If yes, then return the name of the record type and index of
              --   the record argument.  Start counting with 1, because 0 means that
              --   it is already applied to the record. (Can happen in module
              --   instantiation.) This information is used in the termination
              --   checker.
            , Defn -> Set FunctionFlag
funFlags          :: Set FunctionFlag
            , Defn -> Maybe Bool
funTerminates     :: Maybe Bool
              -- ^ Has this function been termination checked?  Did it pass?
            , Defn -> Maybe ExtLamInfo
funExtLam         :: Maybe ExtLamInfo
              -- ^ Is this function generated from an extended lambda?
              --   If yes, then return the number of hidden and non-hidden lambda-lifted arguments
            , Defn -> Maybe QName
funWith           :: Maybe QName
              -- ^ Is this a generated with-function? If yes, then what's the
              --   name of the parent function.
            }
          | Datatype
            { Defn -> Int
dataPars           :: Nat            -- ^ Number of parameters.
            , Defn -> Int
dataIxs            :: Nat            -- ^ Number of indices.
            , Defn -> Maybe Clause
dataClause         :: (Maybe Clause) -- ^ This might be in an instantiated module.
            , Defn -> [QName]
dataCons           :: [QName]
              -- ^ Constructor names , ordered according to the order of their definition.
            , Defn -> Sort
dataSort           :: Sort
            , Defn -> Maybe [QName]
dataMutual         :: Maybe [QName]
              -- ^ Mutually recursive functions, @data@s and @record@s.
              --   Does include this data type.
              --   Empty if not recursive.
              --   @Nothing@ if not yet computed (by positivity checker).
            , Defn -> IsAbstract
dataAbstr          :: IsAbstract
            , Defn -> [QName]
dataPathCons       :: [QName]        -- ^ Path constructor names (subset of dataCons)
            }
          | Record
            { Defn -> Int
recPars           :: Nat
              -- ^ Number of parameters.
            , Defn -> Maybe Clause
recClause         :: Maybe Clause
              -- ^ Was this record type created by a module application?
              --   If yes, the clause is its definition (linking back to the original record type).
            , Defn -> ConHead
recConHead        :: ConHead
              -- ^ Constructor name and fields.
            , Defn -> Bool
recNamedCon       :: Bool
              -- ^ Does this record have a @constructor@?
            , Defn -> [Dom QName]
recFields         :: [Dom QName]
              -- ^ The record field names.
            , Defn -> Telescope
recTel            :: Telescope
              -- ^ The record field telescope. (Includes record parameters.)
              --   Note: @TelV recTel _ == telView' recConType@.
              --   Thus, @recTel@ is redundant.
            , Defn -> Maybe [QName]
recMutual         :: Maybe [QName]
              -- ^ Mutually recursive functions, @data@s and @record@s.
              --   Does include this record.
              --   Empty if not recursive.
              --   @Nothing@ if not yet computed (by positivity checker).
            , Defn -> EtaEquality
recEtaEquality'    :: EtaEquality
              -- ^ Eta-expand at this record type?
              --   @False@ for unguarded recursive records and coinductive records
              --   unless the user specifies otherwise.
            , Defn -> Maybe Induction
recInduction      :: Maybe Induction
              -- ^ 'Inductive' or 'CoInductive'?  Matters only for recursive records.
              --   'Nothing' means that the user did not specify it, which is an error
              --   for recursive records.
            , Defn -> IsAbstract
recAbstr          :: IsAbstract
            , Defn -> CompKit
recComp           :: CompKit
            }
          | Constructor
            { Defn -> Int
conPars   :: Int         -- ^ Number of parameters.
            , Defn -> Int
conArity  :: Int         -- ^ Number of arguments (excluding parameters).
            , Defn -> ConHead
conSrcCon :: ConHead     -- ^ Name of (original) constructor and fields. (This might be in a module instance.)
            , Defn -> QName
conData   :: QName       -- ^ Name of datatype or record type.
            , Defn -> IsAbstract
conAbstr  :: IsAbstract
            , Defn -> Induction
conInd    :: Induction   -- ^ Inductive or coinductive?
            , Defn -> CompKit
conComp   :: CompKit     -- ^ Cubical composition.
            , Defn -> Maybe [QName]
conProj   :: Maybe [QName] -- ^ Projections. 'Nothing' if not yet computed.
            , Defn -> [IsForced]
conForced :: [IsForced]
              -- ^ Which arguments are forced (i.e. determined by the type of the constructor)?
              --   Either this list is empty (if the forcing analysis isn't run), or its length is @conArity@.
            , Defn -> Maybe [Bool]
conErased :: Maybe [Bool]
              -- ^ Which arguments are erased at runtime (computed during compilation to treeless)?
              --   'True' means erased, 'False' means retained.
              --   'Nothing' if no erasure analysis has been performed yet.
              --   The length of the list is @conArity@.
            }
          | Primitive
            { Defn -> IsAbstract
primAbstr :: IsAbstract
            , Defn -> String
primName  :: String
            , Defn -> [Clause]
primClauses :: [Clause]
              -- ^ 'null' for primitive functions, @not null@ for builtin functions.
            , Defn -> FunctionInverse
primInv      :: FunctionInverse
              -- ^ Builtin functions can have inverses. For instance, natural number addition.
            , Defn -> Maybe CompiledClauses
primCompiled :: Maybe CompiledClauses
              -- ^ 'Nothing' for primitive functions,
              --   @'Just' something@ for builtin functions.
            }
            -- ^ Primitive or builtin functions.
    deriving (Typeable Defn
DataType
Constr
Typeable Defn
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Defn -> c Defn)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Defn)
-> (Defn -> Constr)
-> (Defn -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Defn))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Defn))
-> ((forall b. Data b => b -> b) -> Defn -> Defn)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Defn -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Defn -> r)
-> (forall u. (forall d. Data d => d -> u) -> Defn -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Defn -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Defn -> m Defn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Defn -> m Defn)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Defn -> m Defn)
-> Data Defn
Defn -> DataType
Defn -> Constr
(forall b. Data b => b -> b) -> Defn -> Defn
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Defn -> c Defn
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Defn
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) -> Defn -> u
forall u. (forall d. Data d => d -> u) -> Defn -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Defn -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Defn -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Defn -> m Defn
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Defn -> m Defn
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Defn
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Defn -> c Defn
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Defn)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Defn)
$cPrimitive :: Constr
$cConstructor :: Constr
$cRecord :: Constr
$cDatatype :: Constr
$cFunction :: Constr
$cAbstractDefn :: Constr
$cGeneralizableVar :: Constr
$cDataOrRecSig :: Constr
$cAxiom :: Constr
$tDefn :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Defn -> m Defn
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Defn -> m Defn
gmapMp :: (forall d. Data d => d -> m d) -> Defn -> m Defn
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Defn -> m Defn
gmapM :: (forall d. Data d => d -> m d) -> Defn -> m Defn
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Defn -> m Defn
gmapQi :: Int -> (forall d. Data d => d -> u) -> Defn -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Defn -> u
gmapQ :: (forall d. Data d => d -> u) -> Defn -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Defn -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Defn -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Defn -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Defn -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Defn -> r
gmapT :: (forall b. Data b => b -> b) -> Defn -> Defn
$cgmapT :: (forall b. Data b => b -> b) -> Defn -> Defn
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Defn)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Defn)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Defn)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Defn)
dataTypeOf :: Defn -> DataType
$cdataTypeOf :: Defn -> DataType
toConstr :: Defn -> Constr
$ctoConstr :: Defn -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Defn
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Defn
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Defn -> c Defn
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Defn -> c Defn
$cp1Data :: Typeable Defn
Data, Int -> Defn -> ShowS
[Defn] -> ShowS
Defn -> String
(Int -> Defn -> ShowS)
-> (Defn -> String) -> ([Defn] -> ShowS) -> Show Defn
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Defn] -> ShowS
$cshowList :: [Defn] -> ShowS
show :: Defn -> String
$cshow :: Defn -> String
showsPrec :: Int -> Defn -> ShowS
$cshowsPrec :: Int -> Defn -> ShowS
Show)

instance Pretty Definition where
  pretty :: Definition -> Doc
pretty Defn{Bool
[Maybe Name]
[Polarity]
[Occurrence]
[LocalDisplayForm]
Maybe QName
CompiledRepresentation
Set QName
ArgInfo
QName
Blocked_
Type
MutualId
Defn
NumGeneralizableArgs
theDef :: Defn
defBlocked :: Blocked_
defCopatternLHS :: Bool
defInjective :: Bool
defNoCompilation :: Bool
defMatchable :: Set QName
defCopy :: Bool
defInstance :: Maybe QName
defCompiledRep :: CompiledRepresentation
defMutual :: MutualId
defDisplay :: [LocalDisplayForm]
defGeneralizedParams :: [Maybe Name]
defArgGeneralizable :: NumGeneralizableArgs
defArgOccurrences :: [Occurrence]
defPolarity :: [Polarity]
defType :: Type
defName :: QName
defArgInfo :: ArgInfo
theDef :: Definition -> Defn
defBlocked :: Definition -> Blocked_
defCopatternLHS :: Definition -> Bool
defInjective :: Definition -> Bool
defNoCompilation :: Definition -> Bool
defMatchable :: Definition -> Set QName
defCopy :: Definition -> Bool
defInstance :: Definition -> Maybe QName
defCompiledRep :: Definition -> CompiledRepresentation
defMutual :: Definition -> MutualId
defDisplay :: Definition -> [LocalDisplayForm]
defGeneralizedParams :: Definition -> [Maybe Name]
defArgGeneralizable :: Definition -> NumGeneralizableArgs
defArgOccurrences :: Definition -> [Occurrence]
defPolarity :: Definition -> [Polarity]
defType :: Definition -> Type
defName :: Definition -> QName
defArgInfo :: Definition -> ArgInfo
..} =
    Doc
"Defn {" Doc -> Doc -> Doc
<?> [Doc] -> Doc
vcat
      [ Doc
"defArgInfo        =" Doc -> Doc -> Doc
<?> ArgInfo -> Doc
forall a. Show a => a -> Doc
pshow ArgInfo
defArgInfo
      , Doc
"defName           =" Doc -> Doc -> Doc
<?> QName -> Doc
forall a. Pretty a => a -> Doc
pretty QName
defName
      , Doc
"defType           =" Doc -> Doc -> Doc
<?> Type -> Doc
forall a. Pretty a => a -> Doc
pretty Type
defType
      , Doc
"defPolarity       =" Doc -> Doc -> Doc
<?> [Polarity] -> Doc
forall a. Show a => a -> Doc
pshow [Polarity]
defPolarity
      , Doc
"defArgOccurrences =" Doc -> Doc -> Doc
<?> [Occurrence] -> Doc
forall a. Show a => a -> Doc
pshow [Occurrence]
defArgOccurrences
      , Doc
"defGeneralizedParams =" Doc -> Doc -> Doc
<?> [Maybe Name] -> Doc
forall a. Show a => a -> Doc
pshow [Maybe Name]
defGeneralizedParams
      , Doc
"defDisplay        =" Doc -> Doc -> Doc
<?> [LocalDisplayForm] -> Doc
forall a. Show a => a -> Doc
pshow [LocalDisplayForm]
defDisplay -- TODO: pretty DisplayForm
      , Doc
"defMutual         =" Doc -> Doc -> Doc
<?> MutualId -> Doc
forall a. Show a => a -> Doc
pshow MutualId
defMutual
      , Doc
"defCompiledRep    =" Doc -> Doc -> Doc
<?> CompiledRepresentation -> Doc
forall a. Show a => a -> Doc
pshow CompiledRepresentation
defCompiledRep
      , Doc
"defInstance       =" Doc -> Doc -> Doc
<?> Maybe QName -> Doc
forall a. Show a => a -> Doc
pshow Maybe QName
defInstance
      , Doc
"defCopy           =" Doc -> Doc -> Doc
<?> Bool -> Doc
forall a. Show a => a -> Doc
pshow Bool
defCopy
      , Doc
"defMatchable      =" Doc -> Doc -> Doc
<?> [QName] -> Doc
forall a. Show a => a -> Doc
pshow (Set QName -> [QName]
forall a. Set a -> [a]
Set.toList Set QName
defMatchable)
      , Doc
"defInjective      =" Doc -> Doc -> Doc
<?> Bool -> Doc
forall a. Show a => a -> Doc
pshow Bool
defInjective
      , Doc
"defCopatternLHS   =" Doc -> Doc -> Doc
<?> Bool -> Doc
forall a. Show a => a -> Doc
pshow Bool
defCopatternLHS
      , Doc
"theDef            =" Doc -> Doc -> Doc
<?> Defn -> Doc
forall a. Pretty a => a -> Doc
pretty Defn
theDef ] Doc -> Doc -> Doc
<+> Doc
"}"

instance Pretty Defn where
  pretty :: Defn -> Doc
pretty Defn
Axiom = Doc
"Axiom"
  pretty (DataOrRecSig Int
n)   = Doc
"DataOrRecSig" Doc -> Doc -> Doc
<+> Int -> Doc
forall a. Pretty a => a -> Doc
pretty Int
n
  pretty GeneralizableVar{} = Doc
"GeneralizableVar"
  pretty (AbstractDefn Defn
def) = Doc
"AbstractDefn" Doc -> Doc -> Doc
<?> Doc -> Doc
parens (Defn -> Doc
forall a. Pretty a => a -> Doc
pretty Defn
def)
  pretty Function{[Clause]
Maybe Bool
Maybe [QName]
Maybe QName
Maybe Compiled
Maybe SplitTree
Maybe CompiledClauses
Maybe Projection
Maybe ExtLamInfo
Set FunctionFlag
IsAbstract
Delayed
FunctionInverse
funWith :: Maybe QName
funExtLam :: Maybe ExtLamInfo
funTerminates :: Maybe Bool
funFlags :: Set FunctionFlag
funProjection :: Maybe Projection
funDelayed :: Delayed
funAbstr :: IsAbstract
funMutual :: Maybe [QName]
funInv :: FunctionInverse
funCovering :: [Clause]
funTreeless :: Maybe Compiled
funSplitTree :: Maybe SplitTree
funCompiled :: Maybe CompiledClauses
funClauses :: [Clause]
funWith :: Defn -> Maybe QName
funExtLam :: Defn -> Maybe ExtLamInfo
funTerminates :: Defn -> Maybe Bool
funFlags :: Defn -> Set FunctionFlag
funProjection :: Defn -> Maybe Projection
funDelayed :: Defn -> Delayed
funAbstr :: Defn -> IsAbstract
funMutual :: Defn -> Maybe [QName]
funInv :: Defn -> FunctionInverse
funCovering :: Defn -> [Clause]
funTreeless :: Defn -> Maybe Compiled
funSplitTree :: Defn -> Maybe SplitTree
funCompiled :: Defn -> Maybe CompiledClauses
funClauses :: Defn -> [Clause]
..} =
    Doc
"Function {" Doc -> Doc -> Doc
<?> [Doc] -> Doc
vcat
      [ Doc
"funClauses      =" Doc -> Doc -> Doc
<?> [Doc] -> Doc
vcat ((Clause -> Doc) -> [Clause] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map Clause -> Doc
forall a. Pretty a => a -> Doc
pretty [Clause]
funClauses)
      , Doc
"funCompiled     =" Doc -> Doc -> Doc
<?> Maybe CompiledClauses -> Doc
forall a. Show a => a -> Doc
pshow Maybe CompiledClauses
funCompiled
      , Doc
"funSplitTree    =" Doc -> Doc -> Doc
<?> Maybe SplitTree -> Doc
forall a. Show a => a -> Doc
pshow Maybe SplitTree
funSplitTree
      , Doc
"funTreeless     =" Doc -> Doc -> Doc
<?> Maybe Compiled -> Doc
forall a. Show a => a -> Doc
pshow Maybe Compiled
funTreeless
      , Doc
"funInv          =" Doc -> Doc -> Doc
<?> FunctionInverse -> Doc
forall a. Show a => a -> Doc
pshow FunctionInverse
funInv
      , Doc
"funMutual       =" Doc -> Doc -> Doc
<?> Maybe [QName] -> Doc
forall a. Show a => a -> Doc
pshow Maybe [QName]
funMutual
      , Doc
"funAbstr        =" Doc -> Doc -> Doc
<?> IsAbstract -> Doc
forall a. Show a => a -> Doc
pshow IsAbstract
funAbstr
      , Doc
"funDelayed      =" Doc -> Doc -> Doc
<?> Delayed -> Doc
forall a. Show a => a -> Doc
pshow Delayed
funDelayed
      , Doc
"funProjection   =" Doc -> Doc -> Doc
<?> Maybe Projection -> Doc
forall a. Show a => a -> Doc
pshow Maybe Projection
funProjection
      , Doc
"funFlags        =" Doc -> Doc -> Doc
<?> Set FunctionFlag -> Doc
forall a. Show a => a -> Doc
pshow Set FunctionFlag
funFlags
      , Doc
"funTerminates   =" Doc -> Doc -> Doc
<?> Maybe Bool -> Doc
forall a. Show a => a -> Doc
pshow Maybe Bool
funTerminates
      , Doc
"funWith         =" Doc -> Doc -> Doc
<?> Maybe QName -> Doc
forall a. Show a => a -> Doc
pshow Maybe QName
funWith ] Doc -> Doc -> Doc
<?> Doc
"}"
  pretty Datatype{Int
[QName]
Maybe [QName]
Maybe Clause
IsAbstract
Sort
dataPathCons :: [QName]
dataAbstr :: IsAbstract
dataMutual :: Maybe [QName]
dataSort :: Sort
dataCons :: [QName]
dataClause :: Maybe Clause
dataIxs :: Int
dataPars :: Int
dataPathCons :: Defn -> [QName]
dataAbstr :: Defn -> IsAbstract
dataMutual :: Defn -> Maybe [QName]
dataSort :: Defn -> Sort
dataCons :: Defn -> [QName]
dataClause :: Defn -> Maybe Clause
dataIxs :: Defn -> Int
dataPars :: Defn -> Int
..} =
    Doc
"Datatype {" Doc -> Doc -> Doc
<?> [Doc] -> Doc
vcat
      [ Doc
"dataPars       =" Doc -> Doc -> Doc
<?> Int -> Doc
forall a. Show a => a -> Doc
pshow Int
dataPars
      , Doc
"dataIxs        =" Doc -> Doc -> Doc
<?> Int -> Doc
forall a. Show a => a -> Doc
pshow Int
dataIxs
      , Doc
"dataClause     =" Doc -> Doc -> Doc
<?> Maybe Clause -> Doc
forall a. Pretty a => a -> Doc
pretty Maybe Clause
dataClause
      , Doc
"dataCons       =" Doc -> Doc -> Doc
<?> [QName] -> Doc
forall a. Show a => a -> Doc
pshow [QName]
dataCons
      , Doc
"dataSort       =" Doc -> Doc -> Doc
<?> Sort -> Doc
forall a. Pretty a => a -> Doc
pretty Sort
dataSort
      , Doc
"dataMutual     =" Doc -> Doc -> Doc
<?> Maybe [QName] -> Doc
forall a. Show a => a -> Doc
pshow Maybe [QName]
dataMutual
      , Doc
"dataAbstr      =" Doc -> Doc -> Doc
<?> IsAbstract -> Doc
forall a. Show a => a -> Doc
pshow IsAbstract
dataAbstr ] Doc -> Doc -> Doc
<?> Doc
"}"
  pretty Record{Bool
Int
[Dom QName]
Maybe [QName]
Maybe Induction
Maybe Clause
IsAbstract
Telescope
ConHead
CompKit
EtaEquality
recComp :: CompKit
recAbstr :: IsAbstract
recInduction :: Maybe Induction
recEtaEquality' :: EtaEquality
recMutual :: Maybe [QName]
recTel :: Telescope
recFields :: [Dom QName]
recNamedCon :: Bool
recConHead :: ConHead
recClause :: Maybe Clause
recPars :: Int
recComp :: Defn -> CompKit
recAbstr :: Defn -> IsAbstract
recInduction :: Defn -> Maybe Induction
recEtaEquality' :: Defn -> EtaEquality
recMutual :: Defn -> Maybe [QName]
recTel :: Defn -> Telescope
recFields :: Defn -> [Dom QName]
recNamedCon :: Defn -> Bool
recConHead :: Defn -> ConHead
recClause :: Defn -> Maybe Clause
recPars :: Defn -> Int
..} =
    Doc
"Record {" Doc -> Doc -> Doc
<?> [Doc] -> Doc
vcat
      [ Doc
"recPars         =" Doc -> Doc -> Doc
<?> Int -> Doc
forall a. Show a => a -> Doc
pshow Int
recPars
      , Doc
"recClause       =" Doc -> Doc -> Doc
<?> Maybe Clause -> Doc
forall a. Pretty a => a -> Doc
pretty Maybe Clause
recClause
      , Doc
"recConHead      =" Doc -> Doc -> Doc
<?> ConHead -> Doc
forall a. Show a => a -> Doc
pshow ConHead
recConHead
      , Doc
"recNamedCon     =" Doc -> Doc -> Doc
<?> Bool -> Doc
forall a. Show a => a -> Doc
pshow Bool
recNamedCon
      , Doc
"recFields       =" Doc -> Doc -> Doc
<?> [Dom QName] -> Doc
forall a. Show a => a -> Doc
pshow [Dom QName]
recFields
      , Doc
"recTel          =" Doc -> Doc -> Doc
<?> Telescope -> Doc
forall a. Pretty a => a -> Doc
pretty Telescope
recTel
      , Doc
"recMutual       =" Doc -> Doc -> Doc
<?> Maybe [QName] -> Doc
forall a. Show a => a -> Doc
pshow Maybe [QName]
recMutual
      , Doc
"recEtaEquality' =" Doc -> Doc -> Doc
<?> EtaEquality -> Doc
forall a. Show a => a -> Doc
pshow EtaEquality
recEtaEquality'
      , Doc
"recInduction    =" Doc -> Doc -> Doc
<?> Maybe Induction -> Doc
forall a. Show a => a -> Doc
pshow Maybe Induction
recInduction
      , Doc
"recAbstr        =" Doc -> Doc -> Doc
<?> IsAbstract -> Doc
forall a. Show a => a -> Doc
pshow IsAbstract
recAbstr ] Doc -> Doc -> Doc
<?> Doc
"}"
  pretty Constructor{Int
[IsForced]
Maybe [Bool]
Maybe [QName]
IsAbstract
Induction
QName
ConHead
CompKit
conErased :: Maybe [Bool]
conForced :: [IsForced]
conProj :: Maybe [QName]
conComp :: CompKit
conInd :: Induction
conAbstr :: IsAbstract
conData :: QName
conSrcCon :: ConHead
conArity :: Int
conPars :: Int
conErased :: Defn -> Maybe [Bool]
conForced :: Defn -> [IsForced]
conProj :: Defn -> Maybe [QName]
conComp :: Defn -> CompKit
conInd :: Defn -> Induction
conAbstr :: Defn -> IsAbstract
conData :: Defn -> QName
conSrcCon :: Defn -> ConHead
conArity :: Defn -> Int
conPars :: Defn -> Int
..} =
    Doc
"Constructor {" Doc -> Doc -> Doc
<?> [Doc] -> Doc
vcat
      [ Doc
"conPars   =" Doc -> Doc -> Doc
<?> Int -> Doc
forall a. Show a => a -> Doc
pshow Int
conPars
      , Doc
"conArity  =" Doc -> Doc -> Doc
<?> Int -> Doc
forall a. Show a => a -> Doc
pshow Int
conArity
      , Doc
"conSrcCon =" Doc -> Doc -> Doc
<?> ConHead -> Doc
forall a. Show a => a -> Doc
pshow ConHead
conSrcCon
      , Doc
"conData   =" Doc -> Doc -> Doc
<?> QName -> Doc
forall a. Show a => a -> Doc
pshow QName
conData
      , Doc
"conAbstr  =" Doc -> Doc -> Doc
<?> IsAbstract -> Doc
forall a. Show a => a -> Doc
pshow IsAbstract
conAbstr
      , Doc
"conInd    =" Doc -> Doc -> Doc
<?> Induction -> Doc
forall a. Show a => a -> Doc
pshow Induction
conInd
      , Doc
"conErased =" Doc -> Doc -> Doc
<?> Maybe [Bool] -> Doc
forall a. Show a => a -> Doc
pshow Maybe [Bool]
conErased ] Doc -> Doc -> Doc
<?> Doc
"}"
  pretty Primitive{String
[Clause]
Maybe CompiledClauses
IsAbstract
FunctionInverse
primCompiled :: Maybe CompiledClauses
primInv :: FunctionInverse
primClauses :: [Clause]
primName :: String
primAbstr :: IsAbstract
primCompiled :: Defn -> Maybe CompiledClauses
primInv :: Defn -> FunctionInverse
primClauses :: Defn -> [Clause]
primName :: Defn -> String
primAbstr :: Defn -> IsAbstract
..} =
    Doc
"Primitive {" Doc -> Doc -> Doc
<?> [Doc] -> Doc
vcat
      [ Doc
"primAbstr    =" Doc -> Doc -> Doc
<?> IsAbstract -> Doc
forall a. Show a => a -> Doc
pshow IsAbstract
primAbstr
      , Doc
"primName     =" Doc -> Doc -> Doc
<?> String -> Doc
forall a. Show a => a -> Doc
pshow String
primName
      , Doc
"primClauses  =" Doc -> Doc -> Doc
<?> [Clause] -> Doc
forall a. Show a => a -> Doc
pshow [Clause]
primClauses
      , Doc
"primCompiled =" Doc -> Doc -> Doc
<?> Maybe CompiledClauses -> Doc
forall a. Show a => a -> Doc
pshow Maybe CompiledClauses
primCompiled ] Doc -> Doc -> Doc
<?> Doc
"}"


-- | Is the record type recursive?
recRecursive :: Defn -> Bool
recRecursive :: Defn -> Bool
recRecursive (Record { recMutual :: Defn -> Maybe [QName]
recMutual = Just [QName]
qs }) = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [QName] -> Bool
forall a. Null a => a -> Bool
null [QName]
qs
recRecursive Defn
_ = Bool
forall a. HasCallStack => a
__IMPOSSIBLE__

recEtaEquality :: Defn -> HasEta
recEtaEquality :: Defn -> HasEta
recEtaEquality = EtaEquality -> HasEta
theEtaEquality (EtaEquality -> HasEta) -> (Defn -> EtaEquality) -> Defn -> HasEta
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Defn -> EtaEquality
recEtaEquality'

-- | A template for creating 'Function' definitions, with sensible defaults.
emptyFunction :: Defn
emptyFunction :: Defn
emptyFunction = Function :: [Clause]
-> Maybe CompiledClauses
-> Maybe SplitTree
-> Maybe Compiled
-> [Clause]
-> FunctionInverse
-> Maybe [QName]
-> IsAbstract
-> Delayed
-> Maybe Projection
-> Set FunctionFlag
-> Maybe Bool
-> Maybe ExtLamInfo
-> Maybe QName
-> Defn
Function
  { funClauses :: [Clause]
funClauses     = []
  , funCompiled :: Maybe CompiledClauses
funCompiled    = Maybe CompiledClauses
forall a. Maybe a
Nothing
  , funSplitTree :: Maybe SplitTree
funSplitTree   = Maybe SplitTree
forall a. Maybe a
Nothing
  , funTreeless :: Maybe Compiled
funTreeless    = Maybe Compiled
forall a. Maybe a
Nothing
  , funInv :: FunctionInverse
funInv         = FunctionInverse
forall c. FunctionInverse' c
NotInjective
  , funMutual :: Maybe [QName]
funMutual      = Maybe [QName]
forall a. Maybe a
Nothing
  , funAbstr :: IsAbstract
funAbstr       = IsAbstract
ConcreteDef
  , funDelayed :: Delayed
funDelayed     = Delayed
NotDelayed
  , funProjection :: Maybe Projection
funProjection  = Maybe Projection
forall a. Maybe a
Nothing
  , funFlags :: Set FunctionFlag
funFlags       = Set FunctionFlag
forall a. Set a
Set.empty
  , funTerminates :: Maybe Bool
funTerminates  = Maybe Bool
forall a. Maybe a
Nothing
  , funExtLam :: Maybe ExtLamInfo
funExtLam      = Maybe ExtLamInfo
forall a. Maybe a
Nothing
  , funWith :: Maybe QName
funWith        = Maybe QName
forall a. Maybe a
Nothing
  , funCovering :: [Clause]
funCovering    = []
  }

funFlag :: FunctionFlag -> Lens' Bool Defn
funFlag :: FunctionFlag -> Lens' Bool Defn
funFlag FunctionFlag
flag Bool -> f Bool
f def :: Defn
def@Function{ funFlags :: Defn -> Set FunctionFlag
funFlags = Set FunctionFlag
flags } =
  Bool -> f Bool
f (FunctionFlag -> Set FunctionFlag -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member FunctionFlag
flag Set FunctionFlag
flags) f Bool -> (Bool -> Defn) -> f Defn
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&>
  \ Bool
b -> Defn
def{ funFlags :: Set FunctionFlag
funFlags = (if Bool
b then FunctionFlag -> Set FunctionFlag -> Set FunctionFlag
forall a. Ord a => a -> Set a -> Set a
Set.insert else FunctionFlag -> Set FunctionFlag -> Set FunctionFlag
forall a. Ord a => a -> Set a -> Set a
Set.delete) FunctionFlag
flag Set FunctionFlag
flags }
funFlag FunctionFlag
_ Bool -> f Bool
f Defn
def = Bool -> f Bool
f Bool
False f Bool -> (Bool -> Defn) -> f Defn
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> Defn -> Bool -> Defn
forall a b. a -> b -> a
const Defn
def

funStatic, funInline, funMacro :: Lens' Bool Defn
funStatic :: (Bool -> f Bool) -> Defn -> f Defn
funStatic       = FunctionFlag -> Lens' Bool Defn
funFlag FunctionFlag
FunStatic
funInline :: (Bool -> f Bool) -> Defn -> f Defn
funInline       = FunctionFlag -> Lens' Bool Defn
funFlag FunctionFlag
FunInline
funMacro :: (Bool -> f Bool) -> Defn -> f Defn
funMacro        = FunctionFlag -> Lens' Bool Defn
funFlag FunctionFlag
FunMacro

isMacro :: Defn -> Bool
isMacro :: Defn -> Bool
isMacro = (Defn -> Lens' Bool Defn -> Bool
forall o i. o -> Lens' i o -> i
^. Lens' Bool Defn
funMacro)

-- | Checking whether we are dealing with a function yet to be defined.
isEmptyFunction :: Defn -> Bool
isEmptyFunction :: Defn -> Bool
isEmptyFunction Defn
def =
  case Defn
def of
    Function { funClauses :: Defn -> [Clause]
funClauses = [] } -> Bool
True
    Defn
_ -> Bool
False

isCopatternLHS :: [Clause] -> Bool
isCopatternLHS :: [Clause] -> Bool
isCopatternLHS = (Clause -> Bool) -> [Clause] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
List.any ((NamedArg DeBruijnPattern -> Bool)
-> [NamedArg DeBruijnPattern] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
List.any (Maybe (ProjOrigin, AmbiguousQName) -> Bool
forall a. Maybe a -> Bool
isJust (Maybe (ProjOrigin, AmbiguousQName) -> Bool)
-> (NamedArg DeBruijnPattern -> Maybe (ProjOrigin, AmbiguousQName))
-> NamedArg DeBruijnPattern
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NamedArg DeBruijnPattern -> Maybe (ProjOrigin, AmbiguousQName)
forall a. IsProjP a => a -> Maybe (ProjOrigin, AmbiguousQName)
A.isProjP) ([NamedArg DeBruijnPattern] -> Bool)
-> (Clause -> [NamedArg DeBruijnPattern]) -> Clause -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Clause -> [NamedArg DeBruijnPattern]
namedClausePats)

recCon :: Defn -> QName
recCon :: Defn -> QName
recCon Record{ ConHead
recConHead :: ConHead
recConHead :: Defn -> ConHead
recConHead } = ConHead -> QName
conName ConHead
recConHead
recCon Defn
_ = QName
forall a. HasCallStack => a
__IMPOSSIBLE__

defIsRecord :: Defn -> Bool
defIsRecord :: Defn -> Bool
defIsRecord Record{} = Bool
True
defIsRecord Defn
_        = Bool
False

defIsDataOrRecord :: Defn -> Bool
defIsDataOrRecord :: Defn -> Bool
defIsDataOrRecord Record{}   = Bool
True
defIsDataOrRecord Datatype{} = Bool
True
defIsDataOrRecord Defn
_          = Bool
False

defConstructors :: Defn -> [QName]
defConstructors :: Defn -> [QName]
defConstructors Datatype{dataCons :: Defn -> [QName]
dataCons = [QName]
cs} = [QName]
cs
defConstructors Record{recConHead :: Defn -> ConHead
recConHead = ConHead
c} = [ConHead -> QName
conName ConHead
c]
defConstructors Defn
_ = [QName]
forall a. HasCallStack => a
__IMPOSSIBLE__

newtype Fields = Fields [(C.Name, Type)]
  deriving Fields
Fields -> Bool
Fields -> (Fields -> Bool) -> Null Fields
forall a. a -> (a -> Bool) -> Null a
null :: Fields -> Bool
$cnull :: Fields -> Bool
empty :: Fields
$cempty :: Fields
Null

-- | Did we encounter a simplifying reduction?
--   In terms of CIC, that would be a iota-reduction.
--   In terms of Agda, this is a constructor or literal
--   pattern that matched.
--   Just beta-reduction (substitution) or delta-reduction
--   (unfolding of definitions) does not count as simplifying?

data Simplification = YesSimplification | NoSimplification
  deriving (Typeable Simplification
DataType
Constr
Typeable Simplification
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Simplification -> c Simplification)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Simplification)
-> (Simplification -> Constr)
-> (Simplification -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Simplification))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Simplification))
-> ((forall b. Data b => b -> b)
    -> Simplification -> Simplification)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Simplification -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Simplification -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> Simplification -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Simplification -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> Simplification -> m Simplification)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Simplification -> m Simplification)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Simplification -> m Simplification)
-> Data Simplification
Simplification -> DataType
Simplification -> Constr
(forall b. Data b => b -> b) -> Simplification -> Simplification
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Simplification -> c Simplification
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Simplification
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) -> Simplification -> u
forall u. (forall d. Data d => d -> u) -> Simplification -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Simplification -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Simplification -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> Simplification -> m Simplification
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> Simplification -> m Simplification
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Simplification
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Simplification -> c Simplification
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Simplification)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c Simplification)
$cNoSimplification :: Constr
$cYesSimplification :: Constr
$tSimplification :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> Simplification -> m Simplification
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> Simplification -> m Simplification
gmapMp :: (forall d. Data d => d -> m d)
-> Simplification -> m Simplification
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> Simplification -> m Simplification
gmapM :: (forall d. Data d => d -> m d)
-> Simplification -> m Simplification
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> Simplification -> m Simplification
gmapQi :: Int -> (forall d. Data d => d -> u) -> Simplification -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> Simplification -> u
gmapQ :: (forall d. Data d => d -> u) -> Simplification -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Simplification -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Simplification -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Simplification -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Simplification -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Simplification -> r
gmapT :: (forall b. Data b => b -> b) -> Simplification -> Simplification
$cgmapT :: (forall b. Data b => b -> b) -> Simplification -> Simplification
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c Simplification)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c Simplification)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Simplification)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Simplification)
dataTypeOf :: Simplification -> DataType
$cdataTypeOf :: Simplification -> DataType
toConstr :: Simplification -> Constr
$ctoConstr :: Simplification -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Simplification
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Simplification
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Simplification -> c Simplification
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Simplification -> c Simplification
$cp1Data :: Typeable Simplification
Data, Simplification -> Simplification -> Bool
(Simplification -> Simplification -> Bool)
-> (Simplification -> Simplification -> Bool) -> Eq Simplification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Simplification -> Simplification -> Bool
$c/= :: Simplification -> Simplification -> Bool
== :: Simplification -> Simplification -> Bool
$c== :: Simplification -> Simplification -> Bool
Eq, Int -> Simplification -> ShowS
[Simplification] -> ShowS
Simplification -> String
(Int -> Simplification -> ShowS)
-> (Simplification -> String)
-> ([Simplification] -> ShowS)
-> Show Simplification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Simplification] -> ShowS
$cshowList :: [Simplification] -> ShowS
show :: Simplification -> String
$cshow :: Simplification -> String
showsPrec :: Int -> Simplification -> ShowS
$cshowsPrec :: Int -> Simplification -> ShowS
Show)

instance Null Simplification where
  empty :: Simplification
empty = Simplification
NoSimplification
  null :: Simplification -> Bool
null  = (Simplification -> Simplification -> Bool
forall a. Eq a => a -> a -> Bool
== Simplification
NoSimplification)

instance Semigroup Simplification where
  Simplification
YesSimplification <> :: Simplification -> Simplification -> Simplification
<> Simplification
_ = Simplification
YesSimplification
  Simplification
NoSimplification  <> Simplification
s = Simplification
s

instance Monoid Simplification where
  mempty :: Simplification
mempty = Simplification
NoSimplification
  mappend :: Simplification -> Simplification -> Simplification
mappend = Simplification -> Simplification -> Simplification
forall a. Semigroup a => a -> a -> a
(<>)

data Reduced no yes
  = NoReduction no
  | YesReduction Simplification yes
  deriving a -> Reduced no b -> Reduced no a
(a -> b) -> Reduced no a -> Reduced no b
(forall a b. (a -> b) -> Reduced no a -> Reduced no b)
-> (forall a b. a -> Reduced no b -> Reduced no a)
-> Functor (Reduced no)
forall a b. a -> Reduced no b -> Reduced no a
forall a b. (a -> b) -> Reduced no a -> Reduced no b
forall no a b. a -> Reduced no b -> Reduced no a
forall no a b. (a -> b) -> Reduced no a -> Reduced no b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Reduced no b -> Reduced no a
$c<$ :: forall no a b. a -> Reduced no b -> Reduced no a
fmap :: (a -> b) -> Reduced no a -> Reduced no b
$cfmap :: forall no a b. (a -> b) -> Reduced no a -> Reduced no b
Functor

redReturn :: a -> ReduceM (Reduced a' a)
redReturn :: a -> ReduceM (Reduced a' a)
redReturn = Reduced a' a -> ReduceM (Reduced a' a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Reduced a' a -> ReduceM (Reduced a' a))
-> (a -> Reduced a' a) -> a -> ReduceM (Reduced a' a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Simplification -> a -> Reduced a' a
forall no yes. Simplification -> yes -> Reduced no yes
YesReduction Simplification
YesSimplification

-- | Conceptually: @redBind m f k = either (return . Left . f) k =<< m@

redBind :: ReduceM (Reduced a a') -> (a -> b) ->
           (a' -> ReduceM (Reduced b b')) -> ReduceM (Reduced b b')
redBind :: ReduceM (Reduced a a')
-> (a -> b)
-> (a' -> ReduceM (Reduced b b'))
-> ReduceM (Reduced b b')
redBind ReduceM (Reduced a a')
ma a -> b
f a' -> ReduceM (Reduced b b')
k = do
  Reduced a a'
r <- ReduceM (Reduced a a')
ma
  case Reduced a a'
r of
    NoReduction a
x    -> Reduced b b' -> ReduceM (Reduced b b')
forall (m :: * -> *) a. Monad m => a -> m a
return (Reduced b b' -> ReduceM (Reduced b b'))
-> Reduced b b' -> ReduceM (Reduced b b')
forall a b. (a -> b) -> a -> b
$ b -> Reduced b b'
forall no yes. no -> Reduced no yes
NoReduction (b -> Reduced b b') -> b -> Reduced b b'
forall a b. (a -> b) -> a -> b
$ a -> b
f a
x
    YesReduction Simplification
_ a'
y -> a' -> ReduceM (Reduced b b')
k a'
y

-- | Three cases: 1. not reduced, 2. reduced, but blocked, 3. reduced, not blocked.
data IsReduced
  = NotReduced
  | Reduced    (Blocked ())

data MaybeReduced a = MaybeRed
  { MaybeReduced a -> IsReduced
isReduced     :: IsReduced
  , MaybeReduced a -> a
ignoreReduced :: a
  }
  deriving (a -> MaybeReduced b -> MaybeReduced a
(a -> b) -> MaybeReduced a -> MaybeReduced b
(forall a b. (a -> b) -> MaybeReduced a -> MaybeReduced b)
-> (forall a b. a -> MaybeReduced b -> MaybeReduced a)
-> Functor MaybeReduced
forall a b. a -> MaybeReduced b -> MaybeReduced a
forall a b. (a -> b) -> MaybeReduced a -> MaybeReduced b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> MaybeReduced b -> MaybeReduced a
$c<$ :: forall a b. a -> MaybeReduced b -> MaybeReduced a
fmap :: (a -> b) -> MaybeReduced a -> MaybeReduced b
$cfmap :: forall a b. (a -> b) -> MaybeReduced a -> MaybeReduced b
Functor)

instance IsProjElim e => IsProjElim (MaybeReduced e) where
  isProjElim :: MaybeReduced e -> Maybe (ProjOrigin, QName)
isProjElim = e -> Maybe (ProjOrigin, QName)
forall e. IsProjElim e => e -> Maybe (ProjOrigin, QName)
isProjElim (e -> Maybe (ProjOrigin, QName))
-> (MaybeReduced e -> e)
-> MaybeReduced e
-> Maybe (ProjOrigin, QName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MaybeReduced e -> e
forall a. MaybeReduced a -> a
ignoreReduced

type MaybeReducedArgs = [MaybeReduced (Arg Term)]
type MaybeReducedElims = [MaybeReduced Elim]

notReduced :: a -> MaybeReduced a
notReduced :: a -> MaybeReduced a
notReduced a
x = IsReduced -> a -> MaybeReduced a
forall a. IsReduced -> a -> MaybeReduced a
MaybeRed IsReduced
NotReduced a
x

reduced :: Blocked (Arg Term) -> MaybeReduced (Arg Term)
reduced :: Blocked (Arg Term) -> MaybeReduced (Arg Term)
reduced Blocked (Arg Term)
b = case Blocked (Arg Term)
b of
  NotBlocked NotBlocked
_ (Arg ArgInfo
_ (MetaV MetaId
x [Elim]
_)) -> IsReduced -> Arg Term -> MaybeReduced (Arg Term)
forall a. IsReduced -> a -> MaybeReduced a
MaybeRed (Blocked_ -> IsReduced
Reduced (Blocked_ -> IsReduced) -> Blocked_ -> IsReduced
forall a b. (a -> b) -> a -> b
$ MetaId -> () -> Blocked_
forall t. MetaId -> t -> Blocked t
Blocked MetaId
x ()) Arg Term
v
  Blocked (Arg Term)
_                                -> IsReduced -> Arg Term -> MaybeReduced (Arg Term)
forall a. IsReduced -> a -> MaybeReduced a
MaybeRed (Blocked_ -> IsReduced
Reduced (Blocked_ -> IsReduced) -> Blocked_ -> IsReduced
forall a b. (a -> b) -> a -> b
$ () () -> Blocked (Arg Term) -> Blocked_
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Blocked (Arg Term)
b)      Arg Term
v
  where
    v :: Arg Term
v = Blocked (Arg Term) -> Arg Term
forall t. Blocked t -> t
ignoreBlocking Blocked (Arg Term)
b

-- | Controlling 'reduce'.
data AllowedReduction
  = ProjectionReductions     -- ^ (Projection and) projection-like functions may be reduced.
  | InlineReductions         -- ^ Functions marked INLINE may be reduced.
  | CopatternReductions      -- ^ Copattern definitions may be reduced.
  | FunctionReductions       -- ^ Non-recursive functions and primitives may be reduced.
  | RecursiveReductions      -- ^ Even recursive functions may be reduced.
  | LevelReductions          -- ^ Reduce @'Level'@ terms.
  | TypeLevelReductions      -- ^ Allow @allReductions@ in types, even
                             --   if not allowed at term level (used
                             --   by confluence checker)
  | UnconfirmedReductions    -- ^ Functions whose termination has not (yet) been confirmed.
  | NonTerminatingReductions -- ^ Functions that have failed termination checking.
  deriving (Int -> AllowedReduction -> ShowS
[AllowedReduction] -> ShowS
AllowedReduction -> String
(Int -> AllowedReduction -> ShowS)
-> (AllowedReduction -> String)
-> ([AllowedReduction] -> ShowS)
-> Show AllowedReduction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AllowedReduction] -> ShowS
$cshowList :: [AllowedReduction] -> ShowS
show :: AllowedReduction -> String
$cshow :: AllowedReduction -> String
showsPrec :: Int -> AllowedReduction -> ShowS
$cshowsPrec :: Int -> AllowedReduction -> ShowS
Show, AllowedReduction -> AllowedReduction -> Bool
(AllowedReduction -> AllowedReduction -> Bool)
-> (AllowedReduction -> AllowedReduction -> Bool)
-> Eq AllowedReduction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllowedReduction -> AllowedReduction -> Bool
$c/= :: AllowedReduction -> AllowedReduction -> Bool
== :: AllowedReduction -> AllowedReduction -> Bool
$c== :: AllowedReduction -> AllowedReduction -> Bool
Eq, Eq AllowedReduction
Eq AllowedReduction
-> (AllowedReduction -> AllowedReduction -> Ordering)
-> (AllowedReduction -> AllowedReduction -> Bool)
-> (AllowedReduction -> AllowedReduction -> Bool)
-> (AllowedReduction -> AllowedReduction -> Bool)
-> (AllowedReduction -> AllowedReduction -> Bool)
-> (AllowedReduction -> AllowedReduction -> AllowedReduction)
-> (AllowedReduction -> AllowedReduction -> AllowedReduction)
-> Ord AllowedReduction
AllowedReduction -> AllowedReduction -> Bool
AllowedReduction -> AllowedReduction -> Ordering
AllowedReduction -> AllowedReduction -> AllowedReduction
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 :: AllowedReduction -> AllowedReduction -> AllowedReduction
$cmin :: AllowedReduction -> AllowedReduction -> AllowedReduction
max :: AllowedReduction -> AllowedReduction -> AllowedReduction
$cmax :: AllowedReduction -> AllowedReduction -> AllowedReduction
>= :: AllowedReduction -> AllowedReduction -> Bool
$c>= :: AllowedReduction -> AllowedReduction -> Bool
> :: AllowedReduction -> AllowedReduction -> Bool
$c> :: AllowedReduction -> AllowedReduction -> Bool
<= :: AllowedReduction -> AllowedReduction -> Bool
$c<= :: AllowedReduction -> AllowedReduction -> Bool
< :: AllowedReduction -> AllowedReduction -> Bool
$c< :: AllowedReduction -> AllowedReduction -> Bool
compare :: AllowedReduction -> AllowedReduction -> Ordering
$ccompare :: AllowedReduction -> AllowedReduction -> Ordering
$cp1Ord :: Eq AllowedReduction
Ord, Int -> AllowedReduction
AllowedReduction -> Int
AllowedReduction -> [AllowedReduction]
AllowedReduction -> AllowedReduction
AllowedReduction -> AllowedReduction -> [AllowedReduction]
AllowedReduction
-> AllowedReduction -> AllowedReduction -> [AllowedReduction]
(AllowedReduction -> AllowedReduction)
-> (AllowedReduction -> AllowedReduction)
-> (Int -> AllowedReduction)
-> (AllowedReduction -> Int)
-> (AllowedReduction -> [AllowedReduction])
-> (AllowedReduction -> AllowedReduction -> [AllowedReduction])
-> (AllowedReduction -> AllowedReduction -> [AllowedReduction])
-> (AllowedReduction
    -> AllowedReduction -> AllowedReduction -> [AllowedReduction])
-> Enum AllowedReduction
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: AllowedReduction
-> AllowedReduction -> AllowedReduction -> [AllowedReduction]
$cenumFromThenTo :: AllowedReduction
-> AllowedReduction -> AllowedReduction -> [AllowedReduction]
enumFromTo :: AllowedReduction -> AllowedReduction -> [AllowedReduction]
$cenumFromTo :: AllowedReduction -> AllowedReduction -> [AllowedReduction]
enumFromThen :: AllowedReduction -> AllowedReduction -> [AllowedReduction]
$cenumFromThen :: AllowedReduction -> AllowedReduction -> [AllowedReduction]
enumFrom :: AllowedReduction -> [AllowedReduction]
$cenumFrom :: AllowedReduction -> [AllowedReduction]
fromEnum :: AllowedReduction -> Int
$cfromEnum :: AllowedReduction -> Int
toEnum :: Int -> AllowedReduction
$ctoEnum :: Int -> AllowedReduction
pred :: AllowedReduction -> AllowedReduction
$cpred :: AllowedReduction -> AllowedReduction
succ :: AllowedReduction -> AllowedReduction
$csucc :: AllowedReduction -> AllowedReduction
Enum, AllowedReduction
AllowedReduction -> AllowedReduction -> Bounded AllowedReduction
forall a. a -> a -> Bounded a
maxBound :: AllowedReduction
$cmaxBound :: AllowedReduction
minBound :: AllowedReduction
$cminBound :: AllowedReduction
Bounded, Ord AllowedReduction
Ord AllowedReduction
-> ((AllowedReduction, AllowedReduction) -> [AllowedReduction])
-> ((AllowedReduction, AllowedReduction)
    -> AllowedReduction -> Int)
-> ((AllowedReduction, AllowedReduction)
    -> AllowedReduction -> Int)
-> ((AllowedReduction, AllowedReduction)
    -> AllowedReduction -> Bool)
-> ((AllowedReduction, AllowedReduction) -> Int)
-> ((AllowedReduction, AllowedReduction) -> Int)
-> Ix AllowedReduction
(AllowedReduction, AllowedReduction) -> Int
(AllowedReduction, AllowedReduction) -> [AllowedReduction]
(AllowedReduction, AllowedReduction) -> AllowedReduction -> Bool
(AllowedReduction, AllowedReduction) -> AllowedReduction -> Int
forall a.
Ord a
-> ((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
unsafeRangeSize :: (AllowedReduction, AllowedReduction) -> Int
$cunsafeRangeSize :: (AllowedReduction, AllowedReduction) -> Int
rangeSize :: (AllowedReduction, AllowedReduction) -> Int
$crangeSize :: (AllowedReduction, AllowedReduction) -> Int
inRange :: (AllowedReduction, AllowedReduction) -> AllowedReduction -> Bool
$cinRange :: (AllowedReduction, AllowedReduction) -> AllowedReduction -> Bool
unsafeIndex :: (AllowedReduction, AllowedReduction) -> AllowedReduction -> Int
$cunsafeIndex :: (AllowedReduction, AllowedReduction) -> AllowedReduction -> Int
index :: (AllowedReduction, AllowedReduction) -> AllowedReduction -> Int
$cindex :: (AllowedReduction, AllowedReduction) -> AllowedReduction -> Int
range :: (AllowedReduction, AllowedReduction) -> [AllowedReduction]
$crange :: (AllowedReduction, AllowedReduction) -> [AllowedReduction]
$cp1Ix :: Ord AllowedReduction
Ix, Typeable AllowedReduction
DataType
Constr
Typeable AllowedReduction
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AllowedReduction -> c AllowedReduction)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AllowedReduction)
-> (AllowedReduction -> Constr)
-> (AllowedReduction -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AllowedReduction))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AllowedReduction))
-> ((forall b. Data b => b -> b)
    -> AllowedReduction -> AllowedReduction)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AllowedReduction -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AllowedReduction -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> AllowedReduction -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AllowedReduction -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> AllowedReduction -> m AllowedReduction)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AllowedReduction -> m AllowedReduction)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> AllowedReduction -> m AllowedReduction)
-> Data AllowedReduction
AllowedReduction -> DataType
AllowedReduction -> Constr
(forall b. Data b => b -> b)
-> AllowedReduction -> AllowedReduction
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AllowedReduction -> c AllowedReduction
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AllowedReduction
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) -> AllowedReduction -> u
forall u. (forall d. Data d => d -> u) -> AllowedReduction -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AllowedReduction -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AllowedReduction -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AllowedReduction -> m AllowedReduction
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AllowedReduction -> m AllowedReduction
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AllowedReduction
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AllowedReduction -> c AllowedReduction
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AllowedReduction)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AllowedReduction)
$cNonTerminatingReductions :: Constr
$cUnconfirmedReductions :: Constr
$cTypeLevelReductions :: Constr
$cLevelReductions :: Constr
$cRecursiveReductions :: Constr
$cFunctionReductions :: Constr
$cCopatternReductions :: Constr
$cInlineReductions :: Constr
$cProjectionReductions :: Constr
$tAllowedReduction :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> AllowedReduction -> m AllowedReduction
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AllowedReduction -> m AllowedReduction
gmapMp :: (forall d. Data d => d -> m d)
-> AllowedReduction -> m AllowedReduction
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AllowedReduction -> m AllowedReduction
gmapM :: (forall d. Data d => d -> m d)
-> AllowedReduction -> m AllowedReduction
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AllowedReduction -> m AllowedReduction
gmapQi :: Int -> (forall d. Data d => d -> u) -> AllowedReduction -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AllowedReduction -> u
gmapQ :: (forall d. Data d => d -> u) -> AllowedReduction -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AllowedReduction -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AllowedReduction -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AllowedReduction -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AllowedReduction -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AllowedReduction -> r
gmapT :: (forall b. Data b => b -> b)
-> AllowedReduction -> AllowedReduction
$cgmapT :: (forall b. Data b => b -> b)
-> AllowedReduction -> AllowedReduction
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AllowedReduction)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AllowedReduction)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c AllowedReduction)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AllowedReduction)
dataTypeOf :: AllowedReduction -> DataType
$cdataTypeOf :: AllowedReduction -> DataType
toConstr :: AllowedReduction -> Constr
$ctoConstr :: AllowedReduction -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AllowedReduction
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AllowedReduction
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AllowedReduction -> c AllowedReduction
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AllowedReduction -> c AllowedReduction
$cp1Data :: Typeable AllowedReduction
Data)

type AllowedReductions = SmallSet AllowedReduction

-- | Not quite all reductions (skip non-terminating reductions)
allReductions :: AllowedReductions
allReductions :: AllowedReductions
allReductions = AllowedReduction -> AllowedReductions -> AllowedReductions
forall a. SmallSetElement a => a -> SmallSet a -> SmallSet a
SmallSet.delete AllowedReduction
NonTerminatingReductions AllowedReductions
reallyAllReductions

reallyAllReductions :: AllowedReductions
reallyAllReductions :: AllowedReductions
reallyAllReductions = AllowedReductions
forall a. SmallSetElement a => SmallSet a
SmallSet.total


-- | Primitives

data PrimitiveImpl = PrimImpl Type PrimFun

data PrimFun = PrimFun
  { PrimFun -> QName
primFunName           :: QName
  , PrimFun -> Int
primFunArity          :: Arity
  , PrimFun
-> [Arg Term] -> Int -> ReduceM (Reduced MaybeReducedArgs Term)
primFunImplementation :: [Arg Term] -> Int -> ReduceM (Reduced MaybeReducedArgs Term)
  }

primFun :: QName -> Arity -> ([Arg Term] -> ReduceM (Reduced MaybeReducedArgs Term)) -> PrimFun
primFun :: QName
-> Int
-> ([Arg Term] -> ReduceM (Reduced MaybeReducedArgs Term))
-> PrimFun
primFun QName
q Int
ar [Arg Term] -> ReduceM (Reduced MaybeReducedArgs Term)
imp = QName
-> Int
-> ([Arg Term] -> Int -> ReduceM (Reduced MaybeReducedArgs Term))
-> PrimFun
PrimFun QName
q Int
ar (\ [Arg Term]
args Int
_ -> [Arg Term] -> ReduceM (Reduced MaybeReducedArgs Term)
imp [Arg Term]
args)

defClauses :: Definition -> [Clause]
defClauses :: Definition -> [Clause]
defClauses Defn{theDef :: Definition -> Defn
theDef = Function{funClauses :: Defn -> [Clause]
funClauses = [Clause]
cs}}        = [Clause]
cs
defClauses Defn{theDef :: Definition -> Defn
theDef = Primitive{primClauses :: Defn -> [Clause]
primClauses = [Clause]
cs}}      = [Clause]
cs
defClauses Defn{theDef :: Definition -> Defn
theDef = Datatype{dataClause :: Defn -> Maybe Clause
dataClause = Just Clause
c}}    = [Clause
c]
defClauses Defn{theDef :: Definition -> Defn
theDef = Record{recClause :: Defn -> Maybe Clause
recClause = Just Clause
c}}       = [Clause
c]
defClauses Definition
_                                               = []

defCompiled :: Definition -> Maybe CompiledClauses
defCompiled :: Definition -> Maybe CompiledClauses
defCompiled Defn{theDef :: Definition -> Defn
theDef = Function {funCompiled :: Defn -> Maybe CompiledClauses
funCompiled  = Maybe CompiledClauses
mcc}} = Maybe CompiledClauses
mcc
defCompiled Defn{theDef :: Definition -> Defn
theDef = Primitive{primCompiled :: Defn -> Maybe CompiledClauses
primCompiled = Maybe CompiledClauses
mcc}} = Maybe CompiledClauses
mcc
defCompiled Definition
_ = Maybe CompiledClauses
forall a. Maybe a
Nothing

defParameters :: Definition -> Maybe Nat
defParameters :: Definition -> Maybe Int
defParameters Defn{theDef :: Definition -> Defn
theDef = Datatype{dataPars :: Defn -> Int
dataPars = Int
n}} = Int -> Maybe Int
forall a. a -> Maybe a
Just Int
n
defParameters Defn{theDef :: Definition -> Defn
theDef = Record  {recPars :: Defn -> Int
recPars  = Int
n}} = Int -> Maybe Int
forall a. a -> Maybe a
Just Int
n
defParameters Definition
_                                     = Maybe Int
forall a. Maybe a
Nothing

defInverse :: Definition -> FunctionInverse
defInverse :: Definition -> FunctionInverse
defInverse Defn{theDef :: Definition -> Defn
theDef = Function { funInv :: Defn -> FunctionInverse
funInv  = FunctionInverse
inv }} = FunctionInverse
inv
defInverse Defn{theDef :: Definition -> Defn
theDef = Primitive{ primInv :: Defn -> FunctionInverse
primInv = FunctionInverse
inv }} = FunctionInverse
inv
defInverse Definition
_                                         = FunctionInverse
forall c. FunctionInverse' c
NotInjective

defCompilerPragmas :: BackendName -> Definition -> [CompilerPragma]
defCompilerPragmas :: String -> Definition -> [CompilerPragma]
defCompilerPragmas String
b = [CompilerPragma] -> [CompilerPragma]
forall a. [a] -> [a]
reverse ([CompilerPragma] -> [CompilerPragma])
-> (Definition -> [CompilerPragma])
-> Definition
-> [CompilerPragma]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CompilerPragma] -> Maybe [CompilerPragma] -> [CompilerPragma]
forall a. a -> Maybe a -> a
fromMaybe [] (Maybe [CompilerPragma] -> [CompilerPragma])
-> (Definition -> Maybe [CompilerPragma])
-> Definition
-> [CompilerPragma]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CompiledRepresentation -> Maybe [CompilerPragma]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup String
b (CompiledRepresentation -> Maybe [CompilerPragma])
-> (Definition -> CompiledRepresentation)
-> Definition
-> Maybe [CompilerPragma]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Definition -> CompiledRepresentation
defCompiledRep
  -- reversed because we add new pragmas to the front of the list

-- | Are the clauses of this definition delayed?
defDelayed :: Definition -> Delayed
defDelayed :: Definition -> Delayed
defDelayed Defn{theDef :: Definition -> Defn
theDef = Function{funDelayed :: Defn -> Delayed
funDelayed = Delayed
d}} = Delayed
d
defDelayed Definition
_                                       = Delayed
NotDelayed

-- | Has the definition failed the termination checker?
defNonterminating :: Definition -> Bool
defNonterminating :: Definition -> Bool
defNonterminating Defn{theDef :: Definition -> Defn
theDef = Function{funTerminates :: Defn -> Maybe Bool
funTerminates = Just Bool
False}} = Bool
True
defNonterminating Definition
_                                                   = Bool
False

-- | Has the definition not termination checked or did the check fail?
defTerminationUnconfirmed :: Definition -> Bool
defTerminationUnconfirmed :: Definition -> Bool
defTerminationUnconfirmed Defn{theDef :: Definition -> Defn
theDef = Function{funTerminates :: Defn -> Maybe Bool
funTerminates = Just Bool
True}} = Bool
False
defTerminationUnconfirmed Defn{theDef :: Definition -> Defn
theDef = Function{funTerminates :: Defn -> Maybe Bool
funTerminates = Maybe Bool
_        }} = Bool
True
defTerminationUnconfirmed Definition
_ = Bool
False

defAbstract :: Definition -> IsAbstract
defAbstract :: Definition -> IsAbstract
defAbstract Definition
d = case Definition -> Defn
theDef Definition
d of
    Axiom{}                   -> IsAbstract
ConcreteDef
    DataOrRecSig{}            -> IsAbstract
ConcreteDef
    GeneralizableVar{}        -> IsAbstract
ConcreteDef
    AbstractDefn{}            -> IsAbstract
AbstractDef
    Function{funAbstr :: Defn -> IsAbstract
funAbstr = IsAbstract
a}    -> IsAbstract
a
    Datatype{dataAbstr :: Defn -> IsAbstract
dataAbstr = IsAbstract
a}   -> IsAbstract
a
    Record{recAbstr :: Defn -> IsAbstract
recAbstr = IsAbstract
a}      -> IsAbstract
a
    Constructor{conAbstr :: Defn -> IsAbstract
conAbstr = IsAbstract
a} -> IsAbstract
a
    Primitive{primAbstr :: Defn -> IsAbstract
primAbstr = IsAbstract
a}  -> IsAbstract
a

defForced :: Definition -> [IsForced]
defForced :: Definition -> [IsForced]
defForced Definition
d = case Definition -> Defn
theDef Definition
d of
    Constructor{conForced :: Defn -> [IsForced]
conForced = [IsForced]
fs} -> [IsForced]
fs
    Axiom{}                     -> []
    DataOrRecSig{}              -> []
    GeneralizableVar{}          -> []
    AbstractDefn{}              -> []
    Function{}                  -> []
    Datatype{}                  -> []
    Record{}                    -> []
    Primitive{}                 -> []

---------------------------------------------------------------------------
-- ** Injectivity
---------------------------------------------------------------------------

type FunctionInverse = FunctionInverse' Clause
type InversionMap c = Map TermHead [c]

data FunctionInverse' c
  = NotInjective
  | Inverse (InversionMap c)
  deriving (Typeable (FunctionInverse' c)
DataType
Constr
Typeable (FunctionInverse' c)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> FunctionInverse' c
    -> c (FunctionInverse' c))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (FunctionInverse' c))
-> (FunctionInverse' c -> Constr)
-> (FunctionInverse' c -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (FunctionInverse' c)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (FunctionInverse' c)))
-> ((forall b. Data b => b -> b)
    -> FunctionInverse' c -> FunctionInverse' c)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> FunctionInverse' c -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> FunctionInverse' c -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> FunctionInverse' c -> m (FunctionInverse' c))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> FunctionInverse' c -> m (FunctionInverse' c))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> FunctionInverse' c -> m (FunctionInverse' c))
-> Data (FunctionInverse' c)
FunctionInverse' c -> DataType
FunctionInverse' c -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (FunctionInverse' c))
(forall b. Data b => b -> b)
-> FunctionInverse' c -> FunctionInverse' c
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> FunctionInverse' c
-> c (FunctionInverse' c)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (FunctionInverse' c)
forall c. Data c => Typeable (FunctionInverse' c)
forall c. Data c => FunctionInverse' c -> DataType
forall c. Data c => FunctionInverse' c -> Constr
forall c.
Data c =>
(forall b. Data b => b -> b)
-> FunctionInverse' c -> FunctionInverse' c
forall c u.
Data c =>
Int -> (forall d. Data d => d -> u) -> FunctionInverse' c -> u
forall c u.
Data c =>
(forall d. Data d => d -> u) -> FunctionInverse' c -> [u]
forall c r r'.
Data c =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r
forall c r r'.
Data c =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r
forall c (m :: * -> *).
(Data c, Monad m) =>
(forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
forall c (m :: * -> *).
(Data c, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
forall c (c :: * -> *).
Data c =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (FunctionInverse' c)
forall c (c :: * -> *).
Data c =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> FunctionInverse' c
-> c (FunctionInverse' c)
forall c (t :: * -> *) (c :: * -> *).
(Data c, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (FunctionInverse' c))
forall c (t :: * -> * -> *) (c :: * -> *).
(Data c, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (FunctionInverse' c))
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) -> FunctionInverse' c -> u
forall u. (forall d. Data d => d -> u) -> FunctionInverse' c -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (FunctionInverse' c)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> FunctionInverse' c
-> c (FunctionInverse' c)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (FunctionInverse' c))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (FunctionInverse' c))
$cInverse :: Constr
$cNotInjective :: Constr
$tFunctionInverse' :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
$cgmapMo :: forall c (m :: * -> *).
(Data c, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
gmapMp :: (forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
$cgmapMp :: forall c (m :: * -> *).
(Data c, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
gmapM :: (forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
$cgmapM :: forall c (m :: * -> *).
(Data c, Monad m) =>
(forall d. Data d => d -> m d)
-> FunctionInverse' c -> m (FunctionInverse' c)
gmapQi :: Int -> (forall d. Data d => d -> u) -> FunctionInverse' c -> u
$cgmapQi :: forall c u.
Data c =>
Int -> (forall d. Data d => d -> u) -> FunctionInverse' c -> u
gmapQ :: (forall d. Data d => d -> u) -> FunctionInverse' c -> [u]
$cgmapQ :: forall c u.
Data c =>
(forall d. Data d => d -> u) -> FunctionInverse' c -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r
$cgmapQr :: forall c r r'.
Data c =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r
$cgmapQl :: forall c r r'.
Data c =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionInverse' c -> r
gmapT :: (forall b. Data b => b -> b)
-> FunctionInverse' c -> FunctionInverse' c
$cgmapT :: forall c.
Data c =>
(forall b. Data b => b -> b)
-> FunctionInverse' c -> FunctionInverse' c
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (FunctionInverse' c))
$cdataCast2 :: forall c (t :: * -> * -> *) (c :: * -> *).
(Data c, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (FunctionInverse' c))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (FunctionInverse' c))
$cdataCast1 :: forall c (t :: * -> *) (c :: * -> *).
(Data c, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (FunctionInverse' c))
dataTypeOf :: FunctionInverse' c -> DataType
$cdataTypeOf :: forall c. Data c => FunctionInverse' c -> DataType
toConstr :: FunctionInverse' c -> Constr
$ctoConstr :: forall c. Data c => FunctionInverse' c -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (FunctionInverse' c)
$cgunfold :: forall c (c :: * -> *).
Data c =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (FunctionInverse' c)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> FunctionInverse' c
-> c (FunctionInverse' c)
$cgfoldl :: forall c (c :: * -> *).
Data c =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> FunctionInverse' c
-> c (FunctionInverse' c)
$cp1Data :: forall c. Data c => Typeable (FunctionInverse' c)
Data, Int -> FunctionInverse' c -> ShowS
[FunctionInverse' c] -> ShowS
FunctionInverse' c -> String
(Int -> FunctionInverse' c -> ShowS)
-> (FunctionInverse' c -> String)
-> ([FunctionInverse' c] -> ShowS)
-> Show (FunctionInverse' c)
forall c. Show c => Int -> FunctionInverse' c -> ShowS
forall c. Show c => [FunctionInverse' c] -> ShowS
forall c. Show c => FunctionInverse' c -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionInverse' c] -> ShowS
$cshowList :: forall c. Show c => [FunctionInverse' c] -> ShowS
show :: FunctionInverse' c -> String
$cshow :: forall c. Show c => FunctionInverse' c -> String
showsPrec :: Int -> FunctionInverse' c -> ShowS
$cshowsPrec :: forall c. Show c => Int -> FunctionInverse' c -> ShowS
Show, a -> FunctionInverse' b -> FunctionInverse' a
(a -> b) -> FunctionInverse' a -> FunctionInverse' b
(forall a b. (a -> b) -> FunctionInverse' a -> FunctionInverse' b)
-> (forall a b. a -> FunctionInverse' b -> FunctionInverse' a)
-> Functor FunctionInverse'
forall a b. a -> FunctionInverse' b -> FunctionInverse' a
forall a b. (a -> b) -> FunctionInverse' a -> FunctionInverse' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> FunctionInverse' b -> FunctionInverse' a
$c<$ :: forall a b. a -> FunctionInverse' b -> FunctionInverse' a
fmap :: (a -> b) -> FunctionInverse' a -> FunctionInverse' b
$cfmap :: forall a b. (a -> b) -> FunctionInverse' a -> FunctionInverse' b
Functor)

data TermHead = SortHead
              | PiHead
              | ConsHead QName
              | VarHead Nat
              | UnknownHead
  deriving (Typeable TermHead
DataType
Constr
Typeable TermHead
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TermHead -> c TermHead)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TermHead)
-> (TermHead -> Constr)
-> (TermHead -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TermHead))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TermHead))
-> ((forall b. Data b => b -> b) -> TermHead -> TermHead)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TermHead -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TermHead -> r)
-> (forall u. (forall d. Data d => d -> u) -> TermHead -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> TermHead -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TermHead -> m TermHead)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TermHead -> m TermHead)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TermHead -> m TermHead)
-> Data TermHead
TermHead -> DataType
TermHead -> Constr
(forall b. Data b => b -> b) -> TermHead -> TermHead
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TermHead -> c TermHead
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TermHead
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) -> TermHead -> u
forall u. (forall d. Data d => d -> u) -> TermHead -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TermHead -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TermHead -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TermHead -> m TermHead
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TermHead -> m TermHead
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TermHead
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TermHead -> c TermHead
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TermHead)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TermHead)
$cUnknownHead :: Constr
$cVarHead :: Constr
$cConsHead :: Constr
$cPiHead :: Constr
$cSortHead :: Constr
$tTermHead :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> TermHead -> m TermHead
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TermHead -> m TermHead
gmapMp :: (forall d. Data d => d -> m d) -> TermHead -> m TermHead
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TermHead -> m TermHead
gmapM :: (forall d. Data d => d -> m d) -> TermHead -> m TermHead
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TermHead -> m TermHead
gmapQi :: Int -> (forall d. Data d => d -> u) -> TermHead -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TermHead -> u
gmapQ :: (forall d. Data d => d -> u) -> TermHead -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TermHead -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TermHead -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TermHead -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TermHead -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TermHead -> r
gmapT :: (forall b. Data b => b -> b) -> TermHead -> TermHead
$cgmapT :: (forall b. Data b => b -> b) -> TermHead -> TermHead
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TermHead)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TermHead)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c TermHead)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TermHead)
dataTypeOf :: TermHead -> DataType
$cdataTypeOf :: TermHead -> DataType
toConstr :: TermHead -> Constr
$ctoConstr :: TermHead -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TermHead
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TermHead
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TermHead -> c TermHead
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TermHead -> c TermHead
$cp1Data :: Typeable TermHead
Data, TermHead -> TermHead -> Bool
(TermHead -> TermHead -> Bool)
-> (TermHead -> TermHead -> Bool) -> Eq TermHead
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TermHead -> TermHead -> Bool
$c/= :: TermHead -> TermHead -> Bool
== :: TermHead -> TermHead -> Bool
$c== :: TermHead -> TermHead -> Bool
Eq, Eq TermHead
Eq TermHead
-> (TermHead -> TermHead -> Ordering)
-> (TermHead -> TermHead -> Bool)
-> (TermHead -> TermHead -> Bool)
-> (TermHead -> TermHead -> Bool)
-> (TermHead -> TermHead -> Bool)
-> (TermHead -> TermHead -> TermHead)
-> (TermHead -> TermHead -> TermHead)
-> Ord TermHead
TermHead -> TermHead -> Bool
TermHead -> TermHead -> Ordering
TermHead -> TermHead -> TermHead
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 :: TermHead -> TermHead -> TermHead
$cmin :: TermHead -> TermHead -> TermHead
max :: TermHead -> TermHead -> TermHead
$cmax :: TermHead -> TermHead -> TermHead
>= :: TermHead -> TermHead -> Bool
$c>= :: TermHead -> TermHead -> Bool
> :: TermHead -> TermHead -> Bool
$c> :: TermHead -> TermHead -> Bool
<= :: TermHead -> TermHead -> Bool
$c<= :: TermHead -> TermHead -> Bool
< :: TermHead -> TermHead -> Bool
$c< :: TermHead -> TermHead -> Bool
compare :: TermHead -> TermHead -> Ordering
$ccompare :: TermHead -> TermHead -> Ordering
$cp1Ord :: Eq TermHead
Ord, Int -> TermHead -> ShowS
[TermHead] -> ShowS
TermHead -> String
(Int -> TermHead -> ShowS)
-> (TermHead -> String) -> ([TermHead] -> ShowS) -> Show TermHead
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TermHead] -> ShowS
$cshowList :: [TermHead] -> ShowS
show :: TermHead -> String
$cshow :: TermHead -> String
showsPrec :: Int -> TermHead -> ShowS
$cshowsPrec :: Int -> TermHead -> ShowS
Show)

instance Pretty TermHead where
  pretty :: TermHead -> Doc
pretty = \ case
    TermHead
SortHead    -> Doc
"SortHead"
    TermHead
PiHead      -> Doc
"PiHead"
    ConsHead QName
q  -> Doc
"ConsHead" Doc -> Doc -> Doc
<+> QName -> Doc
forall a. Pretty a => a -> Doc
pretty QName
q
    VarHead Int
i   -> String -> Doc
text (String
"VarHead " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
i)
    TermHead
UnknownHead -> Doc
"UnknownHead"

---------------------------------------------------------------------------
-- ** Mutual blocks
---------------------------------------------------------------------------

newtype MutualId = MutId Int32
  deriving (Typeable MutualId
DataType
Constr
Typeable MutualId
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> MutualId -> c MutualId)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c MutualId)
-> (MutualId -> Constr)
-> (MutualId -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c MutualId))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MutualId))
-> ((forall b. Data b => b -> b) -> MutualId -> MutualId)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> MutualId -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> MutualId -> r)
-> (forall u. (forall d. Data d => d -> u) -> MutualId -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> MutualId -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> MutualId -> m MutualId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MutualId -> m MutualId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> MutualId -> m MutualId)
-> Data MutualId
MutualId -> DataType
MutualId -> Constr
(forall b. Data b => b -> b) -> MutualId -> MutualId
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MutualId -> c MutualId
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MutualId
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) -> MutualId -> u
forall u. (forall d. Data d => d -> u) -> MutualId -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MutualId -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MutualId -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MutualId -> m MutualId
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MutualId -> m MutualId
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MutualId
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MutualId -> c MutualId
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MutualId)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MutualId)
$cMutId :: Constr
$tMutualId :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> MutualId -> m MutualId
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MutualId -> m MutualId
gmapMp :: (forall d. Data d => d -> m d) -> MutualId -> m MutualId
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MutualId -> m MutualId
gmapM :: (forall d. Data d => d -> m d) -> MutualId -> m MutualId
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MutualId -> m MutualId
gmapQi :: Int -> (forall d. Data d => d -> u) -> MutualId -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MutualId -> u
gmapQ :: (forall d. Data d => d -> u) -> MutualId -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> MutualId -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MutualId -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MutualId -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MutualId -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MutualId -> r
gmapT :: (forall b. Data b => b -> b) -> MutualId -> MutualId
$cgmapT :: (forall b. Data b => b -> b) -> MutualId -> MutualId
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MutualId)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MutualId)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c MutualId)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c MutualId)
dataTypeOf :: MutualId -> DataType
$cdataTypeOf :: MutualId -> DataType
toConstr :: MutualId -> Constr
$ctoConstr :: MutualId -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MutualId
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c MutualId
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MutualId -> c MutualId
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MutualId -> c MutualId
$cp1Data :: Typeable MutualId
Data, MutualId -> MutualId -> Bool
(MutualId -> MutualId -> Bool)
-> (MutualId -> MutualId -> Bool) -> Eq MutualId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MutualId -> MutualId -> Bool
$c/= :: MutualId -> MutualId -> Bool
== :: MutualId -> MutualId -> Bool
$c== :: MutualId -> MutualId -> Bool
Eq, Eq MutualId
Eq MutualId
-> (MutualId -> MutualId -> Ordering)
-> (MutualId -> MutualId -> Bool)
-> (MutualId -> MutualId -> Bool)
-> (MutualId -> MutualId -> Bool)
-> (MutualId -> MutualId -> Bool)
-> (MutualId -> MutualId -> MutualId)
-> (MutualId -> MutualId -> MutualId)
-> Ord MutualId
MutualId -> MutualId -> Bool
MutualId -> MutualId -> Ordering
MutualId -> MutualId -> MutualId
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 :: MutualId -> MutualId -> MutualId
$cmin :: MutualId -> MutualId -> MutualId
max :: MutualId -> MutualId -> MutualId
$cmax :: MutualId -> MutualId -> MutualId
>= :: MutualId -> MutualId -> Bool
$c>= :: MutualId -> MutualId -> Bool
> :: MutualId -> MutualId -> Bool
$c> :: MutualId -> MutualId -> Bool
<= :: MutualId -> MutualId -> Bool
$c<= :: MutualId -> MutualId -> Bool
< :: MutualId -> MutualId -> Bool
$c< :: MutualId -> MutualId -> Bool
compare :: MutualId -> MutualId -> Ordering
$ccompare :: MutualId -> MutualId -> Ordering
$cp1Ord :: Eq MutualId
Ord, Int -> MutualId -> ShowS
[MutualId] -> ShowS
MutualId -> String
(Int -> MutualId -> ShowS)
-> (MutualId -> String) -> ([MutualId] -> ShowS) -> Show MutualId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MutualId] -> ShowS
$cshowList :: [MutualId] -> ShowS
show :: MutualId -> String
$cshow :: MutualId -> String
showsPrec :: Int -> MutualId -> ShowS
$cshowsPrec :: Int -> MutualId -> ShowS
Show, Integer -> MutualId
MutualId -> MutualId
MutualId -> MutualId -> MutualId
(MutualId -> MutualId -> MutualId)
-> (MutualId -> MutualId -> MutualId)
-> (MutualId -> MutualId -> MutualId)
-> (MutualId -> MutualId)
-> (MutualId -> MutualId)
-> (MutualId -> MutualId)
-> (Integer -> MutualId)
-> Num MutualId
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> MutualId
$cfromInteger :: Integer -> MutualId
signum :: MutualId -> MutualId
$csignum :: MutualId -> MutualId
abs :: MutualId -> MutualId
$cabs :: MutualId -> MutualId
negate :: MutualId -> MutualId
$cnegate :: MutualId -> MutualId
* :: MutualId -> MutualId -> MutualId
$c* :: MutualId -> MutualId -> MutualId
- :: MutualId -> MutualId -> MutualId
$c- :: MutualId -> MutualId -> MutualId
+ :: MutualId -> MutualId -> MutualId
$c+ :: MutualId -> MutualId -> MutualId
Num, Int -> MutualId
MutualId -> Int
MutualId -> [MutualId]
MutualId -> MutualId
MutualId -> MutualId -> [MutualId]
MutualId -> MutualId -> MutualId -> [MutualId]
(MutualId -> MutualId)
-> (MutualId -> MutualId)
-> (Int -> MutualId)
-> (MutualId -> Int)
-> (MutualId -> [MutualId])
-> (MutualId -> MutualId -> [MutualId])
-> (MutualId -> MutualId -> [MutualId])
-> (MutualId -> MutualId -> MutualId -> [MutualId])
-> Enum MutualId
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: MutualId -> MutualId -> MutualId -> [MutualId]
$cenumFromThenTo :: MutualId -> MutualId -> MutualId -> [MutualId]
enumFromTo :: MutualId -> MutualId -> [MutualId]
$cenumFromTo :: MutualId -> MutualId -> [MutualId]
enumFromThen :: MutualId -> MutualId -> [MutualId]
$cenumFromThen :: MutualId -> MutualId -> [MutualId]
enumFrom :: MutualId -> [MutualId]
$cenumFrom :: MutualId -> [MutualId]
fromEnum :: MutualId -> Int
$cfromEnum :: MutualId -> Int
toEnum :: Int -> MutualId
$ctoEnum :: Int -> MutualId
pred :: MutualId -> MutualId
$cpred :: MutualId -> MutualId
succ :: MutualId -> MutualId
$csucc :: MutualId -> MutualId
Enum)

---------------------------------------------------------------------------
-- ** Statistics
---------------------------------------------------------------------------

type Statistics = Map String Integer

---------------------------------------------------------------------------
-- ** Trace
---------------------------------------------------------------------------

data Call
  = CheckClause Type A.SpineClause
  | CheckLHS A.SpineLHS
  | CheckPattern A.Pattern Telescope Type
  | CheckLetBinding A.LetBinding
  | InferExpr A.Expr
  | CheckExprCall Comparison A.Expr Type
  | CheckDotPattern A.Expr Term
  | CheckProjection Range QName Type
  | IsTypeCall Comparison A.Expr Sort
  | IsType_ A.Expr
  | InferVar Name
  | InferDef QName
  | CheckArguments Range [NamedArg A.Expr] Type (Maybe Type)
  | CheckMetaSolution Range MetaId Type Term
  | CheckTargetType Range Type Type
  | CheckDataDef Range QName [A.LamBinding] [A.Constructor]
  | CheckRecDef Range QName [A.LamBinding] [A.Constructor]
  | CheckConstructor QName Telescope Sort A.Constructor
  | CheckConstructorFitsIn QName Type Sort
  | CheckFunDefCall Range QName [A.Clause]
  | CheckPragma Range A.Pragma
  | CheckPrimitive Range QName A.Expr
  | CheckIsEmpty Range Type
  | CheckConfluence QName QName
  | CheckWithFunctionType Type
  | CheckSectionApplication Range ModuleName A.ModuleApplication
  | CheckNamedWhere ModuleName
  | ScopeCheckExpr C.Expr
  | ScopeCheckDeclaration NiceDeclaration
  | ScopeCheckLHS C.QName C.Pattern
  | NoHighlighting
  | ModuleContents  -- ^ Interaction command: show module contents.
  | SetRange Range  -- ^ used by 'setCurrentRange'
  deriving Typeable Call
DataType
Constr
Typeable Call
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Call -> c Call)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Call)
-> (Call -> Constr)
-> (Call -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Call))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Call))
-> ((forall b. Data b => b -> b) -> Call -> Call)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Call -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Call -> r)
-> (forall u. (forall d. Data d => d -> u) -> Call -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Call -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Call -> m Call)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Call -> m Call)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Call -> m Call)
-> Data Call
Call -> DataType
Call -> Constr
(forall b. Data b => b -> b) -> Call -> Call
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Call -> c Call
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Call
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) -> Call -> u
forall u. (forall d. Data d => d -> u) -> Call -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Call -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Call -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Call -> m Call
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Call -> m Call
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Call
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Call -> c Call
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Call)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Call)
$cSetRange :: Constr
$cModuleContents :: Constr
$cNoHighlighting :: Constr
$cScopeCheckLHS :: Constr
$cScopeCheckDeclaration :: Constr
$cScopeCheckExpr :: Constr
$cCheckNamedWhere :: Constr
$cCheckSectionApplication :: Constr
$cCheckWithFunctionType :: Constr
$cCheckConfluence :: Constr
$cCheckIsEmpty :: Constr
$cCheckPrimitive :: Constr
$cCheckPragma :: Constr
$cCheckFunDefCall :: Constr
$cCheckConstructorFitsIn :: Constr
$cCheckConstructor :: Constr
$cCheckRecDef :: Constr
$cCheckDataDef :: Constr
$cCheckTargetType :: Constr
$cCheckMetaSolution :: Constr
$cCheckArguments :: Constr
$cInferDef :: Constr
$cInferVar :: Constr
$cIsType_ :: Constr
$cIsTypeCall :: Constr
$cCheckProjection :: Constr
$cCheckDotPattern :: Constr
$cCheckExprCall :: Constr
$cInferExpr :: Constr
$cCheckLetBinding :: Constr
$cCheckPattern :: Constr
$cCheckLHS :: Constr
$cCheckClause :: Constr
$tCall :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Call -> m Call
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Call -> m Call
gmapMp :: (forall d. Data d => d -> m d) -> Call -> m Call
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Call -> m Call
gmapM :: (forall d. Data d => d -> m d) -> Call -> m Call
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Call -> m Call
gmapQi :: Int -> (forall d. Data d => d -> u) -> Call -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Call -> u
gmapQ :: (forall d. Data d => d -> u) -> Call -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Call -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Call -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Call -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Call -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Call -> r
gmapT :: (forall b. Data b => b -> b) -> Call -> Call
$cgmapT :: (forall b. Data b => b -> b) -> Call -> Call
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Call)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Call)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Call)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Call)
dataTypeOf :: Call -> DataType
$cdataTypeOf :: Call -> DataType
toConstr :: Call -> Constr
$ctoConstr :: Call -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Call
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Call
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Call -> c Call
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Call -> c Call
$cp1Data :: Typeable Call
Data

instance Pretty Call where
    pretty :: Call -> Doc
pretty CheckClause{}             = Doc
"CheckClause"
    pretty CheckLHS{}                = Doc
"CheckLHS"
    pretty CheckPattern{}            = Doc
"CheckPattern"
    pretty InferExpr{}               = Doc
"InferExpr"
    pretty CheckExprCall{}           = Doc
"CheckExprCall"
    pretty CheckLetBinding{}         = Doc
"CheckLetBinding"
    pretty CheckProjection{}         = Doc
"CheckProjection"
    pretty IsTypeCall{}              = Doc
"IsTypeCall"
    pretty IsType_{}                 = Doc
"IsType_"
    pretty InferVar{}                = Doc
"InferVar"
    pretty InferDef{}                = Doc
"InferDef"
    pretty CheckArguments{}          = Doc
"CheckArguments"
    pretty CheckMetaSolution{}       = Doc
"CheckMetaSolution"
    pretty CheckTargetType{}         = Doc
"CheckTargetType"
    pretty CheckDataDef{}            = Doc
"CheckDataDef"
    pretty CheckRecDef{}             = Doc
"CheckRecDef"
    pretty CheckConstructor{}        = Doc
"CheckConstructor"
    pretty CheckConstructorFitsIn{}  = Doc
"CheckConstructorFitsIn"
    pretty CheckFunDefCall{}         = Doc
"CheckFunDefCall"
    pretty CheckPragma{}             = Doc
"CheckPragma"
    pretty CheckPrimitive{}          = Doc
"CheckPrimitive"
    pretty CheckWithFunctionType{}   = Doc
"CheckWithFunctionType"
    pretty CheckNamedWhere{}         = Doc
"CheckNamedWhere"
    pretty ScopeCheckExpr{}          = Doc
"ScopeCheckExpr"
    pretty ScopeCheckDeclaration{}   = Doc
"ScopeCheckDeclaration"
    pretty ScopeCheckLHS{}           = Doc
"ScopeCheckLHS"
    pretty CheckDotPattern{}         = Doc
"CheckDotPattern"
    pretty SetRange{}                = Doc
"SetRange"
    pretty CheckSectionApplication{} = Doc
"CheckSectionApplication"
    pretty CheckIsEmpty{}            = Doc
"CheckIsEmpty"
    pretty CheckConfluence{}         = Doc
"CheckConfluence"
    pretty NoHighlighting{}          = Doc
"NoHighlighting"
    pretty ModuleContents{}          = Doc
"ModuleContents"

instance HasRange Call where
    getRange :: Call -> Range
getRange (CheckClause Type
_ SpineClause
c)               = SpineClause -> Range
forall t. HasRange t => t -> Range
getRange SpineClause
c
    getRange (CheckLHS SpineLHS
lhs)                  = SpineLHS -> Range
forall t. HasRange t => t -> Range
getRange SpineLHS
lhs
    getRange (CheckPattern Pattern
p Telescope
_ Type
_)            = Pattern -> Range
forall t. HasRange t => t -> Range
getRange Pattern
p
    getRange (InferExpr Expr
e)                   = Expr -> Range
forall t. HasRange t => t -> Range
getRange Expr
e
    getRange (CheckExprCall Comparison
_ Expr
e Type
_)           = Expr -> Range
forall t. HasRange t => t -> Range
getRange Expr
e
    getRange (CheckLetBinding LetBinding
b)             = LetBinding -> Range
forall t. HasRange t => t -> Range
getRange LetBinding
b
    getRange (CheckProjection Range
r QName
_ Type
_)         = Range
r
    getRange (IsTypeCall Comparison
cmp Expr
e Sort
s)            = Expr -> Range
forall t. HasRange t => t -> Range
getRange Expr
e
    getRange (IsType_ Expr
e)                     = Expr -> Range
forall t. HasRange t => t -> Range
getRange Expr
e
    getRange (InferVar Name
x)                    = Name -> Range
forall t. HasRange t => t -> Range
getRange Name
x
    getRange (InferDef QName
f)                    = QName -> Range
forall t. HasRange t => t -> Range
getRange QName
f
    getRange (CheckArguments Range
r [NamedArg Expr]
_ Type
_ Maybe Type
_)        = Range
r
    getRange (CheckMetaSolution Range
r MetaId
_ Type
_ Term
_)     = Range
r
    getRange (CheckTargetType Range
r Type
_ Type
_)         = Range
r
    getRange (CheckDataDef Range
i QName
_ [LamBinding]
_ [Constructor]
_)          = Range -> Range
forall t. HasRange t => t -> Range
getRange Range
i
    getRange (CheckRecDef Range
i QName
_ [LamBinding]
_ [Constructor]
_)           = Range -> Range
forall t. HasRange t => t -> Range
getRange Range
i
    getRange (CheckConstructor QName
_ Telescope
_ Sort
_ Constructor
c)      = Constructor -> Range
forall t. HasRange t => t -> Range
getRange Constructor
c
    getRange (CheckConstructorFitsIn QName
c Type
_ Sort
_)  = QName -> Range
forall t. HasRange t => t -> Range
getRange QName
c
    getRange (CheckFunDefCall Range
i QName
_ [Clause]
_)         = Range -> Range
forall t. HasRange t => t -> Range
getRange Range
i
    getRange (CheckPragma Range
r Pragma
_)               = Range
r
    getRange (CheckPrimitive Range
i QName
_ Expr
_)          = Range -> Range
forall t. HasRange t => t -> Range
getRange Range
i
    getRange CheckWithFunctionType{}         = Range
forall a. Range' a
noRange
    getRange (CheckNamedWhere ModuleName
m)             = ModuleName -> Range
forall t. HasRange t => t -> Range
getRange ModuleName
m
    getRange (ScopeCheckExpr Expr
e)              = Expr -> Range
forall t. HasRange t => t -> Range
getRange Expr
e
    getRange (ScopeCheckDeclaration NiceDeclaration
d)       = NiceDeclaration -> Range
forall t. HasRange t => t -> Range
getRange NiceDeclaration
d
    getRange (ScopeCheckLHS QName
_ Pattern
p)             = Pattern -> Range
forall t. HasRange t => t -> Range
getRange Pattern
p
    getRange (CheckDotPattern Expr
e Term
_)           = Expr -> Range
forall t. HasRange t => t -> Range
getRange Expr
e
    getRange (SetRange Range
r)                    = Range
r
    getRange (CheckSectionApplication Range
r ModuleName
_ ModuleApplication
_) = Range
r
    getRange (CheckIsEmpty Range
r Type
_)              = Range
r
    getRange (CheckConfluence QName
rule1 QName
rule2)   = Range -> Range -> Range
forall a. Ord a => a -> a -> a
max (QName -> Range
forall t. HasRange t => t -> Range
getRange QName
rule1) (QName -> Range
forall t. HasRange t => t -> Range
getRange QName
rule2)
    getRange Call
NoHighlighting                  = Range
forall a. Range' a
noRange
    getRange Call
ModuleContents                  = Range
forall a. Range' a
noRange

---------------------------------------------------------------------------
-- ** Instance table
---------------------------------------------------------------------------

-- | The instance table is a @Map@ associating to every name of
--   record/data type/postulate its list of instances
type InstanceTable = Map QName (Set QName)

-- | When typechecking something of the following form:
--
--     instance
--       x : _
--       x = y
--
--   it's not yet known where to add @x@, so we add it to a list of
--   unresolved instances and we'll deal with it later.
type TempInstanceTable = (InstanceTable , Set QName)

---------------------------------------------------------------------------
-- ** Builtin things
---------------------------------------------------------------------------

data BuiltinDescriptor
  = BuiltinData (TCM Type) [String]
  | BuiltinDataCons (TCM Type)
  | BuiltinPrim String (Term -> TCM ())
  | BuiltinPostulate Relevance (TCM Type)
  | BuiltinUnknown (Maybe (TCM Type)) (Term -> Type -> TCM ())
    -- ^ Builtin of any kind.
    --   Type can be checked (@Just t@) or inferred (@Nothing@).
    --   The second argument is the hook for the verification function.

data BuiltinInfo =
   BuiltinInfo { BuiltinInfo -> String
builtinName :: String
               , BuiltinInfo -> BuiltinDescriptor
builtinDesc :: BuiltinDescriptor }

type BuiltinThings pf = Map String (Builtin pf)

data Builtin pf
        = Builtin Term
        | Prim pf
    deriving (Int -> Builtin pf -> ShowS
[Builtin pf] -> ShowS
Builtin pf -> String
(Int -> Builtin pf -> ShowS)
-> (Builtin pf -> String)
-> ([Builtin pf] -> ShowS)
-> Show (Builtin pf)
forall pf. Show pf => Int -> Builtin pf -> ShowS
forall pf. Show pf => [Builtin pf] -> ShowS
forall pf. Show pf => Builtin pf -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Builtin pf] -> ShowS
$cshowList :: forall pf. Show pf => [Builtin pf] -> ShowS
show :: Builtin pf -> String
$cshow :: forall pf. Show pf => Builtin pf -> String
showsPrec :: Int -> Builtin pf -> ShowS
$cshowsPrec :: forall pf. Show pf => Int -> Builtin pf -> ShowS
Show, a -> Builtin b -> Builtin a
(a -> b) -> Builtin a -> Builtin b
(forall a b. (a -> b) -> Builtin a -> Builtin b)
-> (forall a b. a -> Builtin b -> Builtin a) -> Functor Builtin
forall a b. a -> Builtin b -> Builtin a
forall a b. (a -> b) -> Builtin a -> Builtin b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Builtin b -> Builtin a
$c<$ :: forall a b. a -> Builtin b -> Builtin a
fmap :: (a -> b) -> Builtin a -> Builtin b
$cfmap :: forall a b. (a -> b) -> Builtin a -> Builtin b
Functor, Builtin a -> Bool
(a -> m) -> Builtin a -> m
(a -> b -> b) -> b -> Builtin a -> b
(forall m. Monoid m => Builtin m -> m)
-> (forall m a. Monoid m => (a -> m) -> Builtin a -> m)
-> (forall m a. Monoid m => (a -> m) -> Builtin a -> m)
-> (forall a b. (a -> b -> b) -> b -> Builtin a -> b)
-> (forall a b. (a -> b -> b) -> b -> Builtin a -> b)
-> (forall b a. (b -> a -> b) -> b -> Builtin a -> b)
-> (forall b a. (b -> a -> b) -> b -> Builtin a -> b)
-> (forall a. (a -> a -> a) -> Builtin a -> a)
-> (forall a. (a -> a -> a) -> Builtin a -> a)
-> (forall a. Builtin a -> [a])
-> (forall a. Builtin a -> Bool)
-> (forall a. Builtin a -> Int)
-> (forall a. Eq a => a -> Builtin a -> Bool)
-> (forall a. Ord a => Builtin a -> a)
-> (forall a. Ord a => Builtin a -> a)
-> (forall a. Num a => Builtin a -> a)
-> (forall a. Num a => Builtin a -> a)
-> Foldable Builtin
forall a. Eq a => a -> Builtin a -> Bool
forall a. Num a => Builtin a -> a
forall a. Ord a => Builtin a -> a
forall m. Monoid m => Builtin m -> m
forall a. Builtin a -> Bool
forall a. Builtin a -> Int
forall a. Builtin a -> [a]
forall a. (a -> a -> a) -> Builtin a -> a
forall m a. Monoid m => (a -> m) -> Builtin a -> m
forall b a. (b -> a -> b) -> b -> Builtin a -> b
forall a b. (a -> b -> b) -> b -> Builtin 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 :: Builtin a -> a
$cproduct :: forall a. Num a => Builtin a -> a
sum :: Builtin a -> a
$csum :: forall a. Num a => Builtin a -> a
minimum :: Builtin a -> a
$cminimum :: forall a. Ord a => Builtin a -> a
maximum :: Builtin a -> a
$cmaximum :: forall a. Ord a => Builtin a -> a
elem :: a -> Builtin a -> Bool
$celem :: forall a. Eq a => a -> Builtin a -> Bool
length :: Builtin a -> Int
$clength :: forall a. Builtin a -> Int
null :: Builtin a -> Bool
$cnull :: forall a. Builtin a -> Bool
toList :: Builtin a -> [a]
$ctoList :: forall a. Builtin a -> [a]
foldl1 :: (a -> a -> a) -> Builtin a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Builtin a -> a
foldr1 :: (a -> a -> a) -> Builtin a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Builtin a -> a
foldl' :: (b -> a -> b) -> b -> Builtin a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Builtin a -> b
foldl :: (b -> a -> b) -> b -> Builtin a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Builtin a -> b
foldr' :: (a -> b -> b) -> b -> Builtin a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Builtin a -> b
foldr :: (a -> b -> b) -> b -> Builtin a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Builtin a -> b
foldMap' :: (a -> m) -> Builtin a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Builtin a -> m
foldMap :: (a -> m) -> Builtin a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Builtin a -> m
fold :: Builtin m -> m
$cfold :: forall m. Monoid m => Builtin m -> m
Foldable, Functor Builtin
Foldable Builtin
Functor Builtin
-> Foldable Builtin
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Builtin a -> f (Builtin b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Builtin (f a) -> f (Builtin a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Builtin a -> m (Builtin b))
-> (forall (m :: * -> *) a.
    Monad m =>
    Builtin (m a) -> m (Builtin a))
-> Traversable Builtin
(a -> f b) -> Builtin a -> f (Builtin 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 => Builtin (m a) -> m (Builtin a)
forall (f :: * -> *) a.
Applicative f =>
Builtin (f a) -> f (Builtin a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Builtin a -> m (Builtin b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Builtin a -> f (Builtin b)
sequence :: Builtin (m a) -> m (Builtin a)
$csequence :: forall (m :: * -> *) a. Monad m => Builtin (m a) -> m (Builtin a)
mapM :: (a -> m b) -> Builtin a -> m (Builtin b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Builtin a -> m (Builtin b)
sequenceA :: Builtin (f a) -> f (Builtin a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Builtin (f a) -> f (Builtin a)
traverse :: (a -> f b) -> Builtin a -> f (Builtin b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Builtin a -> f (Builtin b)
$cp2Traversable :: Foldable Builtin
$cp1Traversable :: Functor Builtin
Traversable)

---------------------------------------------------------------------------
-- * Highlighting levels
---------------------------------------------------------------------------

-- | How much highlighting should be sent to the user interface?

data HighlightingLevel
  = None
  | NonInteractive
  | Interactive
    -- ^ This includes both non-interactive highlighting and
    -- interactive highlighting of the expression that is currently
    -- being type-checked.
    deriving (HighlightingLevel -> HighlightingLevel -> Bool
(HighlightingLevel -> HighlightingLevel -> Bool)
-> (HighlightingLevel -> HighlightingLevel -> Bool)
-> Eq HighlightingLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HighlightingLevel -> HighlightingLevel -> Bool
$c/= :: HighlightingLevel -> HighlightingLevel -> Bool
== :: HighlightingLevel -> HighlightingLevel -> Bool
$c== :: HighlightingLevel -> HighlightingLevel -> Bool
Eq, Eq HighlightingLevel
Eq HighlightingLevel
-> (HighlightingLevel -> HighlightingLevel -> Ordering)
-> (HighlightingLevel -> HighlightingLevel -> Bool)
-> (HighlightingLevel -> HighlightingLevel -> Bool)
-> (HighlightingLevel -> HighlightingLevel -> Bool)
-> (HighlightingLevel -> HighlightingLevel -> Bool)
-> (HighlightingLevel -> HighlightingLevel -> HighlightingLevel)
-> (HighlightingLevel -> HighlightingLevel -> HighlightingLevel)
-> Ord HighlightingLevel
HighlightingLevel -> HighlightingLevel -> Bool
HighlightingLevel -> HighlightingLevel -> Ordering
HighlightingLevel -> HighlightingLevel -> HighlightingLevel
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 :: HighlightingLevel -> HighlightingLevel -> HighlightingLevel
$cmin :: HighlightingLevel -> HighlightingLevel -> HighlightingLevel
max :: HighlightingLevel -> HighlightingLevel -> HighlightingLevel
$cmax :: HighlightingLevel -> HighlightingLevel -> HighlightingLevel
>= :: HighlightingLevel -> HighlightingLevel -> Bool
$c>= :: HighlightingLevel -> HighlightingLevel -> Bool
> :: HighlightingLevel -> HighlightingLevel -> Bool
$c> :: HighlightingLevel -> HighlightingLevel -> Bool
<= :: HighlightingLevel -> HighlightingLevel -> Bool
$c<= :: HighlightingLevel -> HighlightingLevel -> Bool
< :: HighlightingLevel -> HighlightingLevel -> Bool
$c< :: HighlightingLevel -> HighlightingLevel -> Bool
compare :: HighlightingLevel -> HighlightingLevel -> Ordering
$ccompare :: HighlightingLevel -> HighlightingLevel -> Ordering
$cp1Ord :: Eq HighlightingLevel
Ord, Int -> HighlightingLevel -> ShowS
[HighlightingLevel] -> ShowS
HighlightingLevel -> String
(Int -> HighlightingLevel -> ShowS)
-> (HighlightingLevel -> String)
-> ([HighlightingLevel] -> ShowS)
-> Show HighlightingLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HighlightingLevel] -> ShowS
$cshowList :: [HighlightingLevel] -> ShowS
show :: HighlightingLevel -> String
$cshow :: HighlightingLevel -> String
showsPrec :: Int -> HighlightingLevel -> ShowS
$cshowsPrec :: Int -> HighlightingLevel -> ShowS
Show, ReadPrec [HighlightingLevel]
ReadPrec HighlightingLevel
Int -> ReadS HighlightingLevel
ReadS [HighlightingLevel]
(Int -> ReadS HighlightingLevel)
-> ReadS [HighlightingLevel]
-> ReadPrec HighlightingLevel
-> ReadPrec [HighlightingLevel]
-> Read HighlightingLevel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HighlightingLevel]
$creadListPrec :: ReadPrec [HighlightingLevel]
readPrec :: ReadPrec HighlightingLevel
$creadPrec :: ReadPrec HighlightingLevel
readList :: ReadS [HighlightingLevel]
$creadList :: ReadS [HighlightingLevel]
readsPrec :: Int -> ReadS HighlightingLevel
$creadsPrec :: Int -> ReadS HighlightingLevel
Read, Typeable HighlightingLevel
DataType
Constr
Typeable HighlightingLevel
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> HighlightingLevel
    -> c HighlightingLevel)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HighlightingLevel)
-> (HighlightingLevel -> Constr)
-> (HighlightingLevel -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HighlightingLevel))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HighlightingLevel))
-> ((forall b. Data b => b -> b)
    -> HighlightingLevel -> HighlightingLevel)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HighlightingLevel -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HighlightingLevel -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> HighlightingLevel -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> HighlightingLevel -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> HighlightingLevel -> m HighlightingLevel)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HighlightingLevel -> m HighlightingLevel)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HighlightingLevel -> m HighlightingLevel)
-> Data HighlightingLevel
HighlightingLevel -> DataType
HighlightingLevel -> Constr
(forall b. Data b => b -> b)
-> HighlightingLevel -> HighlightingLevel
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HighlightingLevel -> c HighlightingLevel
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HighlightingLevel
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) -> HighlightingLevel -> u
forall u. (forall d. Data d => d -> u) -> HighlightingLevel -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingLevel -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingLevel -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> HighlightingLevel -> m HighlightingLevel
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> HighlightingLevel -> m HighlightingLevel
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HighlightingLevel
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HighlightingLevel -> c HighlightingLevel
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HighlightingLevel)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c HighlightingLevel)
$cInteractive :: Constr
$cNonInteractive :: Constr
$cNone :: Constr
$tHighlightingLevel :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> HighlightingLevel -> m HighlightingLevel
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> HighlightingLevel -> m HighlightingLevel
gmapMp :: (forall d. Data d => d -> m d)
-> HighlightingLevel -> m HighlightingLevel
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> HighlightingLevel -> m HighlightingLevel
gmapM :: (forall d. Data d => d -> m d)
-> HighlightingLevel -> m HighlightingLevel
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> HighlightingLevel -> m HighlightingLevel
gmapQi :: Int -> (forall d. Data d => d -> u) -> HighlightingLevel -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> HighlightingLevel -> u
gmapQ :: (forall d. Data d => d -> u) -> HighlightingLevel -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> HighlightingLevel -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingLevel -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingLevel -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingLevel -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingLevel -> r
gmapT :: (forall b. Data b => b -> b)
-> HighlightingLevel -> HighlightingLevel
$cgmapT :: (forall b. Data b => b -> b)
-> HighlightingLevel -> HighlightingLevel
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c HighlightingLevel)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c HighlightingLevel)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c HighlightingLevel)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HighlightingLevel)
dataTypeOf :: HighlightingLevel -> DataType
$cdataTypeOf :: HighlightingLevel -> DataType
toConstr :: HighlightingLevel -> Constr
$ctoConstr :: HighlightingLevel -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HighlightingLevel
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HighlightingLevel
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HighlightingLevel -> c HighlightingLevel
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HighlightingLevel -> c HighlightingLevel
$cp1Data :: Typeable HighlightingLevel
Data)

-- | How should highlighting be sent to the user interface?

data HighlightingMethod
  = Direct
    -- ^ Via stdout.
  | Indirect
    -- ^ Both via files and via stdout.
    deriving (HighlightingMethod -> HighlightingMethod -> Bool
(HighlightingMethod -> HighlightingMethod -> Bool)
-> (HighlightingMethod -> HighlightingMethod -> Bool)
-> Eq HighlightingMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HighlightingMethod -> HighlightingMethod -> Bool
$c/= :: HighlightingMethod -> HighlightingMethod -> Bool
== :: HighlightingMethod -> HighlightingMethod -> Bool
$c== :: HighlightingMethod -> HighlightingMethod -> Bool
Eq, Int -> HighlightingMethod -> ShowS
[HighlightingMethod] -> ShowS
HighlightingMethod -> String
(Int -> HighlightingMethod -> ShowS)
-> (HighlightingMethod -> String)
-> ([HighlightingMethod] -> ShowS)
-> Show HighlightingMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HighlightingMethod] -> ShowS
$cshowList :: [HighlightingMethod] -> ShowS
show :: HighlightingMethod -> String
$cshow :: HighlightingMethod -> String
showsPrec :: Int -> HighlightingMethod -> ShowS
$cshowsPrec :: Int -> HighlightingMethod -> ShowS
Show, ReadPrec [HighlightingMethod]
ReadPrec HighlightingMethod
Int -> ReadS HighlightingMethod
ReadS [HighlightingMethod]
(Int -> ReadS HighlightingMethod)
-> ReadS [HighlightingMethod]
-> ReadPrec HighlightingMethod
-> ReadPrec [HighlightingMethod]
-> Read HighlightingMethod
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HighlightingMethod]
$creadListPrec :: ReadPrec [HighlightingMethod]
readPrec :: ReadPrec HighlightingMethod
$creadPrec :: ReadPrec HighlightingMethod
readList :: ReadS [HighlightingMethod]
$creadList :: ReadS [HighlightingMethod]
readsPrec :: Int -> ReadS HighlightingMethod
$creadsPrec :: Int -> ReadS HighlightingMethod
Read, Typeable HighlightingMethod
DataType
Constr
Typeable HighlightingMethod
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> HighlightingMethod
    -> c HighlightingMethod)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HighlightingMethod)
-> (HighlightingMethod -> Constr)
-> (HighlightingMethod -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HighlightingMethod))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HighlightingMethod))
-> ((forall b. Data b => b -> b)
    -> HighlightingMethod -> HighlightingMethod)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HighlightingMethod -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HighlightingMethod -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> HighlightingMethod -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> HighlightingMethod -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> HighlightingMethod -> m HighlightingMethod)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HighlightingMethod -> m HighlightingMethod)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HighlightingMethod -> m HighlightingMethod)
-> Data HighlightingMethod
HighlightingMethod -> DataType
HighlightingMethod -> Constr
(forall b. Data b => b -> b)
-> HighlightingMethod -> HighlightingMethod
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> HighlightingMethod
-> c HighlightingMethod
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HighlightingMethod
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) -> HighlightingMethod -> u
forall u. (forall d. Data d => d -> u) -> HighlightingMethod -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingMethod -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingMethod -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> HighlightingMethod -> m HighlightingMethod
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> HighlightingMethod -> m HighlightingMethod
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HighlightingMethod
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> HighlightingMethod
-> c HighlightingMethod
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HighlightingMethod)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c HighlightingMethod)
$cIndirect :: Constr
$cDirect :: Constr
$tHighlightingMethod :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> HighlightingMethod -> m HighlightingMethod
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> HighlightingMethod -> m HighlightingMethod
gmapMp :: (forall d. Data d => d -> m d)
-> HighlightingMethod -> m HighlightingMethod
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> HighlightingMethod -> m HighlightingMethod
gmapM :: (forall d. Data d => d -> m d)
-> HighlightingMethod -> m HighlightingMethod
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> HighlightingMethod -> m HighlightingMethod
gmapQi :: Int -> (forall d. Data d => d -> u) -> HighlightingMethod -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> HighlightingMethod -> u
gmapQ :: (forall d. Data d => d -> u) -> HighlightingMethod -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> HighlightingMethod -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingMethod -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingMethod -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingMethod -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HighlightingMethod -> r
gmapT :: (forall b. Data b => b -> b)
-> HighlightingMethod -> HighlightingMethod
$cgmapT :: (forall b. Data b => b -> b)
-> HighlightingMethod -> HighlightingMethod
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c HighlightingMethod)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c HighlightingMethod)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c HighlightingMethod)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HighlightingMethod)
dataTypeOf :: HighlightingMethod -> DataType
$cdataTypeOf :: HighlightingMethod -> DataType
toConstr :: HighlightingMethod -> Constr
$ctoConstr :: HighlightingMethod -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HighlightingMethod
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HighlightingMethod
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> HighlightingMethod
-> c HighlightingMethod
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> HighlightingMethod
-> c HighlightingMethod
$cp1Data :: Typeable HighlightingMethod
Data)

-- | @ifTopLevelAndHighlightingLevelIs l b m@ runs @m@ when we're
-- type-checking the top-level module and either the highlighting
-- level is /at least/ @l@ or @b@ is 'True'.

ifTopLevelAndHighlightingLevelIsOr ::
  MonadTCM tcm => HighlightingLevel -> Bool -> tcm () -> tcm ()
ifTopLevelAndHighlightingLevelIsOr :: HighlightingLevel -> Bool -> tcm () -> tcm ()
ifTopLevelAndHighlightingLevelIsOr HighlightingLevel
l Bool
b tcm ()
m = do
  TCEnv
e <- tcm TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  Bool -> tcm () -> tcm ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (TCEnv -> Int
envModuleNestingLevel TCEnv
e Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 Bool -> Bool -> Bool
&&
        (TCEnv -> HighlightingLevel
envHighlightingLevel TCEnv
e HighlightingLevel -> HighlightingLevel -> Bool
forall a. Ord a => a -> a -> Bool
>= HighlightingLevel
l Bool -> Bool -> Bool
|| Bool
b))
       tcm ()
m

-- | @ifTopLevelAndHighlightingLevelIs l m@ runs @m@ when we're
-- type-checking the top-level module and the highlighting level is
-- /at least/ @l@.

ifTopLevelAndHighlightingLevelIs ::
  MonadTCM tcm => HighlightingLevel -> tcm () -> tcm ()
ifTopLevelAndHighlightingLevelIs :: HighlightingLevel -> tcm () -> tcm ()
ifTopLevelAndHighlightingLevelIs HighlightingLevel
l =
  HighlightingLevel -> Bool -> tcm () -> tcm ()
forall (tcm :: * -> *).
MonadTCM tcm =>
HighlightingLevel -> Bool -> tcm () -> tcm ()
ifTopLevelAndHighlightingLevelIsOr HighlightingLevel
l Bool
False

---------------------------------------------------------------------------
-- * Type checking environment
---------------------------------------------------------------------------

data TCEnv =
    TCEnv { TCEnv -> Context
envContext             :: Context
          , TCEnv -> LetBindings
envLetBindings         :: LetBindings
          , TCEnv -> ModuleName
envCurrentModule       :: ModuleName
          , TCEnv -> Maybe AbsolutePath
envCurrentPath         :: Maybe AbsolutePath
            -- ^ The path to the file that is currently being
            -- type-checked.  'Nothing' if we do not have a file
            -- (like in interactive mode see @CommandLine@).
          , TCEnv -> [(ModuleName, Int)]
envAnonymousModules    :: [(ModuleName, Nat)] -- ^ anonymous modules and their number of free variables
          , TCEnv -> [TopLevelModuleName]
envImportPath          :: [C.TopLevelModuleName] -- ^ to detect import cycles
          , TCEnv -> Maybe MutualId
envMutualBlock         :: Maybe MutualId -- ^ the current (if any) mutual block
          , TCEnv -> TerminationCheck ()
envTerminationCheck    :: TerminationCheck ()  -- ^ are we inside the scope of a termination pragma
          , TCEnv -> CoverageCheck
envCoverageCheck       :: CoverageCheck        -- ^ are we inside the scope of a coverage pragma
          , TCEnv -> Bool
envMakeCase            :: Bool                 -- ^ are we inside a make-case (if so, ignore forcing analysis in unifier)
          , TCEnv -> Bool
envSolvingConstraints  :: Bool
                -- ^ Are we currently in the process of solving active constraints?
          , TCEnv -> Bool
envCheckingWhere       :: Bool
                -- ^ Have we stepped into the where-declarations of a clause?
                --   Everything under a @where@ will be checked with this flag on.
          , TCEnv -> Bool
envWorkingOnTypes      :: Bool
                -- ^ Are we working on types? Turned on by 'workOnTypes'.
          , TCEnv -> Bool
envAssignMetas         :: Bool
            -- ^ Are we allowed to assign metas?
          , TCEnv -> Set ProblemId
envActiveProblems      :: Set ProblemId
          , TCEnv -> AbstractMode
envAbstractMode        :: AbstractMode
                -- ^ When checking the typesignature of a public definition
                --   or the body of a non-abstract definition this is true.
                --   To prevent information about abstract things leaking
                --   outside the module.
          , TCEnv -> Modality
envModality            :: Modality
                -- ^ 'Relevance' component:
                -- Are we checking an irrelevant argument? (=@Irrelevant@)
                -- Then top-level irrelevant declarations are enabled.
                -- Other value: @Relevant@, then only relevant decls. are available.
                --
                -- 'Quantity' component:
                -- Are we checking a runtime-irrelevant thing? (='Quantity0')
                -- Then runtime-irrelevant things are usable.
                -- Other value: @Quantity1@, runtime relevant.
                -- @Quantityω@ is not allowed here, see Bob Atkey, LiCS 2018.
          , TCEnv -> Bool
envDisplayFormsEnabled :: Bool
                -- ^ Sometimes we want to disable display forms.
          , TCEnv -> Range
envRange :: Range
          , TCEnv -> Range
envHighlightingRange :: Range
                -- ^ Interactive highlighting uses this range rather
                --   than 'envRange'.
          , TCEnv -> IPClause
envClause :: IPClause
                -- ^ What is the current clause we are type-checking?
                --   Will be recorded in interaction points in this clause.
          , TCEnv -> Maybe (Closure Call)
envCall  :: Maybe (Closure Call)
                -- ^ what we're doing at the moment
          , TCEnv -> HighlightingLevel
envHighlightingLevel  :: HighlightingLevel
                -- ^ Set to 'None' when imported modules are
                --   type-checked.
          , TCEnv -> HighlightingMethod
envHighlightingMethod :: HighlightingMethod
          , TCEnv -> Int
envModuleNestingLevel :: !Int
                -- ^ This number indicates how far away from the
                --   top-level module Agda has come when chasing
                --   modules. The level of a given module is not
                --   necessarily the same as the length, in the module
                --   dependency graph, of the shortest path from the
                --   top-level module; it depends on in which order
                --   Agda chooses to chase dependencies.
          , TCEnv -> ExpandHidden
envExpandLast :: ExpandHidden
                -- ^ When type-checking an alias f=e, we do not want
                -- to insert hidden arguments in the end, because
                -- these will become unsolved metas.
          , TCEnv -> Maybe QName
envAppDef :: Maybe QName
                -- ^ We are reducing an application of this function.
                -- (For debugging of incomplete matches only.)
          , TCEnv -> Simplification
envSimplification :: Simplification
                -- ^ Did we encounter a simplification (proper match)
                --   during the current reduction process?
          , TCEnv -> AllowedReductions
envAllowedReductions :: AllowedReductions
          , TCEnv -> Int
envInjectivityDepth :: Int
                -- ^ Injectivity can cause non-termination for unsolvable contraints
                --   (#431, #3067). Keep a limit on the nesting depth of injectivity
                --   uses.
          , TCEnv -> Bool
envCompareBlocked :: Bool
                -- ^ When @True@, the conversion checker will consider
                --   all term constructors as injective, including
                --   blocked function applications and metas. Warning:
                --   this should only be used when not assigning any
                --   metas (e.g. when @envAssignMetas@ is @False@ or
                --   when running @pureEqualTerms@) or else we get
                --   non-unique meta solutions.
          , TCEnv -> Bool
envPrintDomainFreePi :: Bool
                -- ^ When @True@, types will be omitted from printed pi types if they
                --   can be inferred.
          , TCEnv -> Bool
envPrintMetasBare :: Bool
                -- ^ When @True@, throw away meta numbers and meta elims.
                --   This is used for reifying terms for feeding into the
                --   user's source code, e.g., for the interaction tactics @solveAll@.
          , TCEnv -> Bool
envInsideDotPattern :: Bool
                -- ^ Used by the scope checker to make sure that certain forms
                --   of expressions are not used inside dot patterns: extended
                --   lambdas and let-expressions.
          , TCEnv -> UnquoteFlags
envUnquoteFlags :: UnquoteFlags
          , TCEnv -> Int
envInstanceDepth :: !Int
                -- ^ Until we get a termination checker for instance search (#1743) we
                --   limit the search depth to ensure termination.
          , TCEnv -> Bool
envIsDebugPrinting :: Bool
          , TCEnv -> [QName]
envPrintingPatternLambdas :: [QName]
                -- ^ #3004: pattern lambdas with copatterns may refer to themselves. We
                --   don't have a good story for what to do in this case, but at least
                --   printing shouldn't loop. Here we keep track of which pattern lambdas
                --   we are currently in the process of printing.
          , TCEnv -> Bool
envCallByNeed :: Bool
                -- ^ Use call-by-need evaluation for reductions.
          , TCEnv -> CheckpointId
envCurrentCheckpoint :: CheckpointId
                -- ^ Checkpoints track the evolution of the context as we go
                -- under binders or refine it by pattern matching.
          , TCEnv -> Map CheckpointId Substitution
envCheckpoints :: Map CheckpointId Substitution
                -- ^ Keeps the substitution from each previous checkpoint to
                --   the current context.
          , TCEnv -> DoGeneralize
envGeneralizeMetas :: DoGeneralize
                -- ^ Should new metas generalized over.
          , TCEnv -> Map QName GeneralizedValue
envGeneralizedVars :: Map QName GeneralizedValue
                -- ^ Values for used generalizable variables.
          , TCEnv -> Bool
envCheckOptionConsistency :: Bool
                -- ^ Do we check that options in imported files are
                --   consistent with each other?
          , TCEnv -> Maybe String
envActiveBackendName :: Maybe BackendName
                -- ^ Is some backend active at the moment, and if yes, which?
                --   NB: we only store the 'BackendName' here, otherwise
                --   @instance Data TCEnv@ is not derivable.
                --   The actual backend can be obtained from the name via 'stBackends'.
          }
    deriving Typeable TCEnv
DataType
Constr
Typeable TCEnv
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TCEnv -> c TCEnv)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TCEnv)
-> (TCEnv -> Constr)
-> (TCEnv -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TCEnv))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TCEnv))
-> ((forall b. Data b => b -> b) -> TCEnv -> TCEnv)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TCEnv -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TCEnv -> r)
-> (forall u. (forall d. Data d => d -> u) -> TCEnv -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> TCEnv -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TCEnv -> m TCEnv)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TCEnv -> m TCEnv)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TCEnv -> m TCEnv)
-> Data TCEnv
TCEnv -> DataType
TCEnv -> Constr
(forall b. Data b => b -> b) -> TCEnv -> TCEnv
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TCEnv -> c TCEnv
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TCEnv
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) -> TCEnv -> u
forall u. (forall d. Data d => d -> u) -> TCEnv -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TCEnv -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TCEnv -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TCEnv -> m TCEnv
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TCEnv -> m TCEnv
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TCEnv
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TCEnv -> c TCEnv
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TCEnv)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TCEnv)
$cTCEnv :: Constr
$tTCEnv :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> TCEnv -> m TCEnv
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TCEnv -> m TCEnv
gmapMp :: (forall d. Data d => d -> m d) -> TCEnv -> m TCEnv
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TCEnv -> m TCEnv
gmapM :: (forall d. Data d => d -> m d) -> TCEnv -> m TCEnv
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TCEnv -> m TCEnv
gmapQi :: Int -> (forall d. Data d => d -> u) -> TCEnv -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TCEnv -> u
gmapQ :: (forall d. Data d => d -> u) -> TCEnv -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TCEnv -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TCEnv -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TCEnv -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TCEnv -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TCEnv -> r
gmapT :: (forall b. Data b => b -> b) -> TCEnv -> TCEnv
$cgmapT :: (forall b. Data b => b -> b) -> TCEnv -> TCEnv
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TCEnv)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TCEnv)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c TCEnv)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TCEnv)
dataTypeOf :: TCEnv -> DataType
$cdataTypeOf :: TCEnv -> DataType
toConstr :: TCEnv -> Constr
$ctoConstr :: TCEnv -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TCEnv
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TCEnv
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TCEnv -> c TCEnv
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TCEnv -> c TCEnv
$cp1Data :: Typeable TCEnv
Data

initEnv :: TCEnv
initEnv :: TCEnv
initEnv = TCEnv :: Context
-> LetBindings
-> ModuleName
-> Maybe AbsolutePath
-> [(ModuleName, Int)]
-> [TopLevelModuleName]
-> Maybe MutualId
-> TerminationCheck ()
-> CoverageCheck
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Set ProblemId
-> AbstractMode
-> Modality
-> Bool
-> Range
-> Range
-> IPClause
-> Maybe (Closure Call)
-> HighlightingLevel
-> HighlightingMethod
-> Int
-> ExpandHidden
-> Maybe QName
-> Simplification
-> AllowedReductions
-> Int
-> Bool
-> Bool
-> Bool
-> Bool
-> UnquoteFlags
-> Int
-> Bool
-> [QName]
-> Bool
-> CheckpointId
-> Map CheckpointId Substitution
-> DoGeneralize
-> Map QName GeneralizedValue
-> Bool
-> Maybe String
-> TCEnv
TCEnv { envContext :: Context
envContext             = []
                , envLetBindings :: LetBindings
envLetBindings         = LetBindings
forall k a. Map k a
Map.empty
                , envCurrentModule :: ModuleName
envCurrentModule       = ModuleName
noModuleName
                , envCurrentPath :: Maybe AbsolutePath
envCurrentPath         = Maybe AbsolutePath
forall a. Maybe a
Nothing
                , envAnonymousModules :: [(ModuleName, Int)]
envAnonymousModules    = []
                , envImportPath :: [TopLevelModuleName]
envImportPath          = []
                , envMutualBlock :: Maybe MutualId
envMutualBlock         = Maybe MutualId
forall a. Maybe a
Nothing
                , envTerminationCheck :: TerminationCheck ()
envTerminationCheck    = TerminationCheck ()
forall m. TerminationCheck m
TerminationCheck
                , envCoverageCheck :: CoverageCheck
envCoverageCheck       = CoverageCheck
YesCoverageCheck
                , envMakeCase :: Bool
envMakeCase            = Bool
False
                , envSolvingConstraints :: Bool
envSolvingConstraints  = Bool
False
                , envCheckingWhere :: Bool
envCheckingWhere       = Bool
False
                , envActiveProblems :: Set ProblemId
envActiveProblems      = Set ProblemId
forall a. Set a
Set.empty
                , envWorkingOnTypes :: Bool
envWorkingOnTypes      = Bool
False
                , envAssignMetas :: Bool
envAssignMetas         = Bool
True
                , envAbstractMode :: AbstractMode
envAbstractMode        = AbstractMode
ConcreteMode
  -- Andreas, 2013-02-21:  This was 'AbstractMode' until now.
  -- However, top-level checks for mutual blocks, such as
  -- constructor-headedness, should not be able to look into
  -- abstract definitions unless abstract themselves.
  -- (See also discussion on issue 796.)
  -- The initial mode should be 'ConcreteMode', ensuring you
  -- can only look into abstract things in an abstract
  -- definition (which sets 'AbstractMode').
                , envModality :: Modality
envModality               = Modality
forall a. Monoid a => a
mempty
                , envDisplayFormsEnabled :: Bool
envDisplayFormsEnabled    = Bool
True
                , envRange :: Range
envRange                  = Range
forall a. Range' a
noRange
                , envHighlightingRange :: Range
envHighlightingRange      = Range
forall a. Range' a
noRange
                , envClause :: IPClause
envClause                 = IPClause
IPNoClause
                , envCall :: Maybe (Closure Call)
envCall                   = Maybe (Closure Call)
forall a. Maybe a
Nothing
                , envHighlightingLevel :: HighlightingLevel
envHighlightingLevel      = HighlightingLevel
None
                , envHighlightingMethod :: HighlightingMethod
envHighlightingMethod     = HighlightingMethod
Indirect
                , envModuleNestingLevel :: Int
envModuleNestingLevel     = -Int
1
                , envExpandLast :: ExpandHidden
envExpandLast             = ExpandHidden
ExpandLast
                , envAppDef :: Maybe QName
envAppDef                 = Maybe QName
forall a. Maybe a
Nothing
                , envSimplification :: Simplification
envSimplification         = Simplification
NoSimplification
                , envAllowedReductions :: AllowedReductions
envAllowedReductions      = AllowedReductions
allReductions
                , envInjectivityDepth :: Int
envInjectivityDepth       = Int
0
                , envCompareBlocked :: Bool
envCompareBlocked         = Bool
False
                , envPrintDomainFreePi :: Bool
envPrintDomainFreePi      = Bool
False
                , envPrintMetasBare :: Bool
envPrintMetasBare         = Bool
False
                , envInsideDotPattern :: Bool
envInsideDotPattern       = Bool
False
                , envUnquoteFlags :: UnquoteFlags
envUnquoteFlags           = UnquoteFlags
defaultUnquoteFlags
                , envInstanceDepth :: Int
envInstanceDepth          = Int
0
                , envIsDebugPrinting :: Bool
envIsDebugPrinting        = Bool
False
                , envPrintingPatternLambdas :: [QName]
envPrintingPatternLambdas = []
                , envCallByNeed :: Bool
envCallByNeed             = Bool
True
                , envCurrentCheckpoint :: CheckpointId
envCurrentCheckpoint      = CheckpointId
0
                , envCheckpoints :: Map CheckpointId Substitution
envCheckpoints            = CheckpointId -> Substitution -> Map CheckpointId Substitution
forall k a. k -> a -> Map k a
Map.singleton CheckpointId
0 Substitution
forall a. Substitution' a
IdS
                , envGeneralizeMetas :: DoGeneralize
envGeneralizeMetas        = DoGeneralize
NoGeneralize
                , envGeneralizedVars :: Map QName GeneralizedValue
envGeneralizedVars        = Map QName GeneralizedValue
forall k a. Map k a
Map.empty
                , envCheckOptionConsistency :: Bool
envCheckOptionConsistency = Bool
True
                , envActiveBackendName :: Maybe String
envActiveBackendName      = Maybe String
forall a. Maybe a
Nothing
                }

class LensTCEnv a where
  lensTCEnv :: Lens' TCEnv a

instance LensTCEnv TCEnv where
  lensTCEnv :: (TCEnv -> f TCEnv) -> TCEnv -> f TCEnv
lensTCEnv = (TCEnv -> f TCEnv) -> TCEnv -> f TCEnv
forall a. a -> a
id

instance LensModality TCEnv where
  -- Cohesion shouldn't have an environment component.
  getModality :: TCEnv -> Modality
getModality = Cohesion -> Modality -> Modality
forall a. LensCohesion a => Cohesion -> a -> a
setCohesion Cohesion
defaultCohesion (Modality -> Modality) -> (TCEnv -> Modality) -> TCEnv -> Modality
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCEnv -> Modality
envModality
  mapModality :: (Modality -> Modality) -> TCEnv -> TCEnv
mapModality Modality -> Modality
f TCEnv
e = TCEnv
e { envModality :: Modality
envModality = Cohesion -> Modality -> Modality
forall a. LensCohesion a => Cohesion -> a -> a
setCohesion Cohesion
defaultCohesion (Modality -> Modality) -> Modality -> Modality
forall a b. (a -> b) -> a -> b
$ Modality -> Modality
f (Modality -> Modality) -> Modality -> Modality
forall a b. (a -> b) -> a -> b
$ TCEnv -> Modality
envModality TCEnv
e }

instance LensRelevance TCEnv where
instance LensQuantity  TCEnv where

data UnquoteFlags = UnquoteFlags
  { UnquoteFlags -> Bool
_unquoteNormalise :: Bool }
  deriving Typeable UnquoteFlags
DataType
Constr
Typeable UnquoteFlags
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> UnquoteFlags -> c UnquoteFlags)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c UnquoteFlags)
-> (UnquoteFlags -> Constr)
-> (UnquoteFlags -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c UnquoteFlags))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c UnquoteFlags))
-> ((forall b. Data b => b -> b) -> UnquoteFlags -> UnquoteFlags)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> UnquoteFlags -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> UnquoteFlags -> r)
-> (forall u. (forall d. Data d => d -> u) -> UnquoteFlags -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> UnquoteFlags -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags)
-> Data UnquoteFlags
UnquoteFlags -> DataType
UnquoteFlags -> Constr
(forall b. Data b => b -> b) -> UnquoteFlags -> UnquoteFlags
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnquoteFlags -> c UnquoteFlags
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnquoteFlags
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) -> UnquoteFlags -> u
forall u. (forall d. Data d => d -> u) -> UnquoteFlags -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnquoteFlags -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnquoteFlags -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnquoteFlags
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnquoteFlags -> c UnquoteFlags
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnquoteFlags)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnquoteFlags)
$cUnquoteFlags :: Constr
$tUnquoteFlags :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags
gmapMp :: (forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags
gmapM :: (forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnquoteFlags -> m UnquoteFlags
gmapQi :: Int -> (forall d. Data d => d -> u) -> UnquoteFlags -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> UnquoteFlags -> u
gmapQ :: (forall d. Data d => d -> u) -> UnquoteFlags -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> UnquoteFlags -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnquoteFlags -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnquoteFlags -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnquoteFlags -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnquoteFlags -> r
gmapT :: (forall b. Data b => b -> b) -> UnquoteFlags -> UnquoteFlags
$cgmapT :: (forall b. Data b => b -> b) -> UnquoteFlags -> UnquoteFlags
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnquoteFlags)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnquoteFlags)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c UnquoteFlags)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnquoteFlags)
dataTypeOf :: UnquoteFlags -> DataType
$cdataTypeOf :: UnquoteFlags -> DataType
toConstr :: UnquoteFlags -> Constr
$ctoConstr :: UnquoteFlags -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnquoteFlags
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnquoteFlags
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnquoteFlags -> c UnquoteFlags
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnquoteFlags -> c UnquoteFlags
$cp1Data :: Typeable UnquoteFlags
Data

defaultUnquoteFlags :: UnquoteFlags
defaultUnquoteFlags :: UnquoteFlags
defaultUnquoteFlags = UnquoteFlags :: Bool -> UnquoteFlags
UnquoteFlags
  { _unquoteNormalise :: Bool
_unquoteNormalise = Bool
False }

unquoteNormalise :: Lens' Bool UnquoteFlags
unquoteNormalise :: (Bool -> f Bool) -> UnquoteFlags -> f UnquoteFlags
unquoteNormalise Bool -> f Bool
f UnquoteFlags
e = Bool -> f Bool
f (UnquoteFlags -> Bool
_unquoteNormalise UnquoteFlags
e) f Bool -> (Bool -> UnquoteFlags) -> f UnquoteFlags
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> UnquoteFlags
e { _unquoteNormalise :: Bool
_unquoteNormalise = Bool
x }

eUnquoteNormalise :: Lens' Bool TCEnv
eUnquoteNormalise :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eUnquoteNormalise = (UnquoteFlags -> f UnquoteFlags) -> TCEnv -> f TCEnv
Lens' UnquoteFlags TCEnv
eUnquoteFlags ((UnquoteFlags -> f UnquoteFlags) -> TCEnv -> f TCEnv)
-> ((Bool -> f Bool) -> UnquoteFlags -> f UnquoteFlags)
-> (Bool -> f Bool)
-> TCEnv
-> f TCEnv
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> f Bool) -> UnquoteFlags -> f UnquoteFlags
Lens' Bool UnquoteFlags
unquoteNormalise

-- * e-prefixed lenses
------------------------------------------------------------------------

eContext :: Lens' Context TCEnv
eContext :: (Context -> f Context) -> TCEnv -> f TCEnv
eContext Context -> f Context
f TCEnv
e = Context -> f Context
f (TCEnv -> Context
envContext TCEnv
e) f Context -> (Context -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Context
x -> TCEnv
e { envContext :: Context
envContext = Context
x }

eLetBindings :: Lens' LetBindings TCEnv
eLetBindings :: (LetBindings -> f LetBindings) -> TCEnv -> f TCEnv
eLetBindings LetBindings -> f LetBindings
f TCEnv
e = LetBindings -> f LetBindings
f (TCEnv -> LetBindings
envLetBindings TCEnv
e) f LetBindings -> (LetBindings -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ LetBindings
x -> TCEnv
e { envLetBindings :: LetBindings
envLetBindings = LetBindings
x }

eCurrentModule :: Lens' ModuleName TCEnv
eCurrentModule :: (ModuleName -> f ModuleName) -> TCEnv -> f TCEnv
eCurrentModule ModuleName -> f ModuleName
f TCEnv
e = ModuleName -> f ModuleName
f (TCEnv -> ModuleName
envCurrentModule TCEnv
e) f ModuleName -> (ModuleName -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ ModuleName
x -> TCEnv
e { envCurrentModule :: ModuleName
envCurrentModule = ModuleName
x }

eCurrentPath :: Lens' (Maybe AbsolutePath) TCEnv
eCurrentPath :: (Maybe AbsolutePath -> f (Maybe AbsolutePath)) -> TCEnv -> f TCEnv
eCurrentPath Maybe AbsolutePath -> f (Maybe AbsolutePath)
f TCEnv
e = Maybe AbsolutePath -> f (Maybe AbsolutePath)
f (TCEnv -> Maybe AbsolutePath
envCurrentPath TCEnv
e) f (Maybe AbsolutePath) -> (Maybe AbsolutePath -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Maybe AbsolutePath
x -> TCEnv
e { envCurrentPath :: Maybe AbsolutePath
envCurrentPath = Maybe AbsolutePath
x }

eAnonymousModules :: Lens' [(ModuleName, Nat)] TCEnv
eAnonymousModules :: ([(ModuleName, Int)] -> f [(ModuleName, Int)]) -> TCEnv -> f TCEnv
eAnonymousModules [(ModuleName, Int)] -> f [(ModuleName, Int)]
f TCEnv
e = [(ModuleName, Int)] -> f [(ModuleName, Int)]
f (TCEnv -> [(ModuleName, Int)]
envAnonymousModules TCEnv
e) f [(ModuleName, Int)] -> ([(ModuleName, Int)] -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ [(ModuleName, Int)]
x -> TCEnv
e { envAnonymousModules :: [(ModuleName, Int)]
envAnonymousModules = [(ModuleName, Int)]
x }

eImportPath :: Lens' [C.TopLevelModuleName] TCEnv
eImportPath :: ([TopLevelModuleName] -> f [TopLevelModuleName])
-> TCEnv -> f TCEnv
eImportPath [TopLevelModuleName] -> f [TopLevelModuleName]
f TCEnv
e = [TopLevelModuleName] -> f [TopLevelModuleName]
f (TCEnv -> [TopLevelModuleName]
envImportPath TCEnv
e) f [TopLevelModuleName]
-> ([TopLevelModuleName] -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ [TopLevelModuleName]
x -> TCEnv
e { envImportPath :: [TopLevelModuleName]
envImportPath = [TopLevelModuleName]
x }

eMutualBlock :: Lens' (Maybe MutualId) TCEnv
eMutualBlock :: (Maybe MutualId -> f (Maybe MutualId)) -> TCEnv -> f TCEnv
eMutualBlock Maybe MutualId -> f (Maybe MutualId)
f TCEnv
e = Maybe MutualId -> f (Maybe MutualId)
f (TCEnv -> Maybe MutualId
envMutualBlock TCEnv
e) f (Maybe MutualId) -> (Maybe MutualId -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Maybe MutualId
x -> TCEnv
e { envMutualBlock :: Maybe MutualId
envMutualBlock = Maybe MutualId
x }

eTerminationCheck :: Lens' (TerminationCheck ()) TCEnv
eTerminationCheck :: (TerminationCheck () -> f (TerminationCheck ()))
-> TCEnv -> f TCEnv
eTerminationCheck TerminationCheck () -> f (TerminationCheck ())
f TCEnv
e = TerminationCheck () -> f (TerminationCheck ())
f (TCEnv -> TerminationCheck ()
envTerminationCheck TCEnv
e) f (TerminationCheck ())
-> (TerminationCheck () -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ TerminationCheck ()
x -> TCEnv
e { envTerminationCheck :: TerminationCheck ()
envTerminationCheck = TerminationCheck ()
x }

eCoverageCheck :: Lens' CoverageCheck TCEnv
eCoverageCheck :: (CoverageCheck -> f CoverageCheck) -> TCEnv -> f TCEnv
eCoverageCheck CoverageCheck -> f CoverageCheck
f TCEnv
e = CoverageCheck -> f CoverageCheck
f (TCEnv -> CoverageCheck
envCoverageCheck TCEnv
e) f CoverageCheck -> (CoverageCheck -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ CoverageCheck
x -> TCEnv
e { envCoverageCheck :: CoverageCheck
envCoverageCheck = CoverageCheck
x }

eMakeCase :: Lens' Bool TCEnv
eMakeCase :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eMakeCase Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envMakeCase TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envMakeCase :: Bool
envMakeCase = Bool
x }

eSolvingConstraints :: Lens' Bool TCEnv
eSolvingConstraints :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eSolvingConstraints Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envSolvingConstraints TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envSolvingConstraints :: Bool
envSolvingConstraints = Bool
x }

eCheckingWhere :: Lens' Bool TCEnv
eCheckingWhere :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eCheckingWhere Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envCheckingWhere TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envCheckingWhere :: Bool
envCheckingWhere = Bool
x }

eWorkingOnTypes :: Lens' Bool TCEnv
eWorkingOnTypes :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eWorkingOnTypes Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envWorkingOnTypes TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envWorkingOnTypes :: Bool
envWorkingOnTypes = Bool
x }

eAssignMetas :: Lens' Bool TCEnv
eAssignMetas :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eAssignMetas Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envAssignMetas TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envAssignMetas :: Bool
envAssignMetas = Bool
x }

eActiveProblems :: Lens' (Set ProblemId) TCEnv
eActiveProblems :: (Set ProblemId -> f (Set ProblemId)) -> TCEnv -> f TCEnv
eActiveProblems Set ProblemId -> f (Set ProblemId)
f TCEnv
e = Set ProblemId -> f (Set ProblemId)
f (TCEnv -> Set ProblemId
envActiveProblems TCEnv
e) f (Set ProblemId) -> (Set ProblemId -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Set ProblemId
x -> TCEnv
e { envActiveProblems :: Set ProblemId
envActiveProblems = Set ProblemId
x }

eAbstractMode :: Lens' AbstractMode TCEnv
eAbstractMode :: (AbstractMode -> f AbstractMode) -> TCEnv -> f TCEnv
eAbstractMode AbstractMode -> f AbstractMode
f TCEnv
e = AbstractMode -> f AbstractMode
f (TCEnv -> AbstractMode
envAbstractMode TCEnv
e) f AbstractMode -> (AbstractMode -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ AbstractMode
x -> TCEnv
e { envAbstractMode :: AbstractMode
envAbstractMode = AbstractMode
x }

-- Andrea 23/02/2020: use get/setModality to enforce invariants of the
--                    envModality field.
eModality :: Lens' Modality TCEnv
eModality :: (Modality -> f Modality) -> TCEnv -> f TCEnv
eModality Modality -> f Modality
f TCEnv
e = Modality -> f Modality
f (TCEnv -> Modality
forall a. LensModality a => a -> Modality
getModality TCEnv
e) f Modality -> (Modality -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Modality
x -> Modality -> TCEnv -> TCEnv
forall a. LensModality a => Modality -> a -> a
setModality Modality
x TCEnv
e

eRelevance :: Lens' Relevance TCEnv
eRelevance :: (Relevance -> f Relevance) -> TCEnv -> f TCEnv
eRelevance = (Modality -> f Modality) -> TCEnv -> f TCEnv
Lens' Modality TCEnv
eModality ((Modality -> f Modality) -> TCEnv -> f TCEnv)
-> ((Relevance -> f Relevance) -> Modality -> f Modality)
-> (Relevance -> f Relevance)
-> TCEnv
-> f TCEnv
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Relevance -> f Relevance) -> Modality -> f Modality
Lens' Relevance Modality
lModRelevance

eQuantity :: Lens' Quantity TCEnv
eQuantity :: (Quantity -> f Quantity) -> TCEnv -> f TCEnv
eQuantity = (Modality -> f Modality) -> TCEnv -> f TCEnv
Lens' Modality TCEnv
eModality ((Modality -> f Modality) -> TCEnv -> f TCEnv)
-> ((Quantity -> f Quantity) -> Modality -> f Modality)
-> (Quantity -> f Quantity)
-> TCEnv
-> f TCEnv
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Quantity -> f Quantity) -> Modality -> f Modality
Lens' Quantity Modality
lModQuantity

eDisplayFormsEnabled :: Lens' Bool TCEnv
eDisplayFormsEnabled :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eDisplayFormsEnabled Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envDisplayFormsEnabled TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envDisplayFormsEnabled :: Bool
envDisplayFormsEnabled = Bool
x }

eRange :: Lens' Range TCEnv
eRange :: (Range -> f Range) -> TCEnv -> f TCEnv
eRange Range -> f Range
f TCEnv
e = Range -> f Range
f (TCEnv -> Range
envRange TCEnv
e) f Range -> (Range -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Range
x -> TCEnv
e { envRange :: Range
envRange = Range
x }

eHighlightingRange :: Lens' Range TCEnv
eHighlightingRange :: (Range -> f Range) -> TCEnv -> f TCEnv
eHighlightingRange Range -> f Range
f TCEnv
e = Range -> f Range
f (TCEnv -> Range
envHighlightingRange TCEnv
e) f Range -> (Range -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Range
x -> TCEnv
e { envHighlightingRange :: Range
envHighlightingRange = Range
x }

eCall :: Lens' (Maybe (Closure Call)) TCEnv
eCall :: (Maybe (Closure Call) -> f (Maybe (Closure Call)))
-> TCEnv -> f TCEnv
eCall Maybe (Closure Call) -> f (Maybe (Closure Call))
f TCEnv
e = Maybe (Closure Call) -> f (Maybe (Closure Call))
f (TCEnv -> Maybe (Closure Call)
envCall TCEnv
e) f (Maybe (Closure Call))
-> (Maybe (Closure Call) -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Maybe (Closure Call)
x -> TCEnv
e { envCall :: Maybe (Closure Call)
envCall = Maybe (Closure Call)
x }

eHighlightingLevel :: Lens' HighlightingLevel TCEnv
eHighlightingLevel :: (HighlightingLevel -> f HighlightingLevel) -> TCEnv -> f TCEnv
eHighlightingLevel HighlightingLevel -> f HighlightingLevel
f TCEnv
e = HighlightingLevel -> f HighlightingLevel
f (TCEnv -> HighlightingLevel
envHighlightingLevel TCEnv
e) f HighlightingLevel -> (HighlightingLevel -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ HighlightingLevel
x -> TCEnv
e { envHighlightingLevel :: HighlightingLevel
envHighlightingLevel = HighlightingLevel
x }

eHighlightingMethod :: Lens' HighlightingMethod TCEnv
eHighlightingMethod :: (HighlightingMethod -> f HighlightingMethod) -> TCEnv -> f TCEnv
eHighlightingMethod HighlightingMethod -> f HighlightingMethod
f TCEnv
e = HighlightingMethod -> f HighlightingMethod
f (TCEnv -> HighlightingMethod
envHighlightingMethod TCEnv
e) f HighlightingMethod -> (HighlightingMethod -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ HighlightingMethod
x -> TCEnv
e { envHighlightingMethod :: HighlightingMethod
envHighlightingMethod = HighlightingMethod
x }

eModuleNestingLevel :: Lens' Int TCEnv
eModuleNestingLevel :: (Int -> f Int) -> TCEnv -> f TCEnv
eModuleNestingLevel Int -> f Int
f TCEnv
e = Int -> f Int
f (TCEnv -> Int
envModuleNestingLevel TCEnv
e) f Int -> (Int -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Int
x -> TCEnv
e { envModuleNestingLevel :: Int
envModuleNestingLevel = Int
x }

eExpandLast :: Lens' ExpandHidden TCEnv
eExpandLast :: (ExpandHidden -> f ExpandHidden) -> TCEnv -> f TCEnv
eExpandLast ExpandHidden -> f ExpandHidden
f TCEnv
e = ExpandHidden -> f ExpandHidden
f (TCEnv -> ExpandHidden
envExpandLast TCEnv
e) f ExpandHidden -> (ExpandHidden -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ ExpandHidden
x -> TCEnv
e { envExpandLast :: ExpandHidden
envExpandLast = ExpandHidden
x }

eAppDef :: Lens' (Maybe QName) TCEnv
eAppDef :: (Maybe QName -> f (Maybe QName)) -> TCEnv -> f TCEnv
eAppDef Maybe QName -> f (Maybe QName)
f TCEnv
e = Maybe QName -> f (Maybe QName)
f (TCEnv -> Maybe QName
envAppDef TCEnv
e) f (Maybe QName) -> (Maybe QName -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Maybe QName
x -> TCEnv
e { envAppDef :: Maybe QName
envAppDef = Maybe QName
x }

eSimplification :: Lens' Simplification TCEnv
eSimplification :: (Simplification -> f Simplification) -> TCEnv -> f TCEnv
eSimplification Simplification -> f Simplification
f TCEnv
e = Simplification -> f Simplification
f (TCEnv -> Simplification
envSimplification TCEnv
e) f Simplification -> (Simplification -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Simplification
x -> TCEnv
e { envSimplification :: Simplification
envSimplification = Simplification
x }

eAllowedReductions :: Lens' AllowedReductions TCEnv
eAllowedReductions :: (AllowedReductions -> f AllowedReductions) -> TCEnv -> f TCEnv
eAllowedReductions AllowedReductions -> f AllowedReductions
f TCEnv
e = AllowedReductions -> f AllowedReductions
f (TCEnv -> AllowedReductions
envAllowedReductions TCEnv
e) f AllowedReductions -> (AllowedReductions -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ AllowedReductions
x -> TCEnv
e { envAllowedReductions :: AllowedReductions
envAllowedReductions = AllowedReductions
x }

eInjectivityDepth :: Lens' Int TCEnv
eInjectivityDepth :: (Int -> f Int) -> TCEnv -> f TCEnv
eInjectivityDepth Int -> f Int
f TCEnv
e = Int -> f Int
f (TCEnv -> Int
envInjectivityDepth TCEnv
e) f Int -> (Int -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Int
x -> TCEnv
e { envInjectivityDepth :: Int
envInjectivityDepth = Int
x }

eCompareBlocked :: Lens' Bool TCEnv
eCompareBlocked :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eCompareBlocked Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envCompareBlocked TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envCompareBlocked :: Bool
envCompareBlocked = Bool
x }

ePrintDomainFreePi :: Lens' Bool TCEnv
ePrintDomainFreePi :: (Bool -> f Bool) -> TCEnv -> f TCEnv
ePrintDomainFreePi Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envPrintDomainFreePi TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envPrintDomainFreePi :: Bool
envPrintDomainFreePi = Bool
x }

eInsideDotPattern :: Lens' Bool TCEnv
eInsideDotPattern :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eInsideDotPattern Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envInsideDotPattern TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envInsideDotPattern :: Bool
envInsideDotPattern = Bool
x }

eUnquoteFlags :: Lens' UnquoteFlags TCEnv
eUnquoteFlags :: (UnquoteFlags -> f UnquoteFlags) -> TCEnv -> f TCEnv
eUnquoteFlags UnquoteFlags -> f UnquoteFlags
f TCEnv
e = UnquoteFlags -> f UnquoteFlags
f (TCEnv -> UnquoteFlags
envUnquoteFlags TCEnv
e) f UnquoteFlags -> (UnquoteFlags -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ UnquoteFlags
x -> TCEnv
e { envUnquoteFlags :: UnquoteFlags
envUnquoteFlags = UnquoteFlags
x }

eInstanceDepth :: Lens' Int TCEnv
eInstanceDepth :: (Int -> f Int) -> TCEnv -> f TCEnv
eInstanceDepth Int -> f Int
f TCEnv
e = Int -> f Int
f (TCEnv -> Int
envInstanceDepth TCEnv
e) f Int -> (Int -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Int
x -> TCEnv
e { envInstanceDepth :: Int
envInstanceDepth = Int
x }

eIsDebugPrinting :: Lens' Bool TCEnv
eIsDebugPrinting :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eIsDebugPrinting Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envIsDebugPrinting TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envIsDebugPrinting :: Bool
envIsDebugPrinting = Bool
x }

ePrintingPatternLambdas :: Lens' [QName] TCEnv
ePrintingPatternLambdas :: ([QName] -> f [QName]) -> TCEnv -> f TCEnv
ePrintingPatternLambdas [QName] -> f [QName]
f TCEnv
e = [QName] -> f [QName]
f (TCEnv -> [QName]
envPrintingPatternLambdas TCEnv
e) f [QName] -> ([QName] -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ [QName]
x -> TCEnv
e { envPrintingPatternLambdas :: [QName]
envPrintingPatternLambdas = [QName]
x }

eCallByNeed :: Lens' Bool TCEnv
eCallByNeed :: (Bool -> f Bool) -> TCEnv -> f TCEnv
eCallByNeed Bool -> f Bool
f TCEnv
e = Bool -> f Bool
f (TCEnv -> Bool
envCallByNeed TCEnv
e) f Bool -> (Bool -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Bool
x -> TCEnv
e { envCallByNeed :: Bool
envCallByNeed = Bool
x }

eCurrentCheckpoint :: Lens' CheckpointId TCEnv
eCurrentCheckpoint :: (CheckpointId -> f CheckpointId) -> TCEnv -> f TCEnv
eCurrentCheckpoint CheckpointId -> f CheckpointId
f TCEnv
e = CheckpointId -> f CheckpointId
f (TCEnv -> CheckpointId
envCurrentCheckpoint TCEnv
e) f CheckpointId -> (CheckpointId -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ CheckpointId
x -> TCEnv
e { envCurrentCheckpoint :: CheckpointId
envCurrentCheckpoint = CheckpointId
x }

eCheckpoints :: Lens' (Map CheckpointId Substitution) TCEnv
eCheckpoints :: (Map CheckpointId Substitution
 -> f (Map CheckpointId Substitution))
-> TCEnv -> f TCEnv
eCheckpoints Map CheckpointId Substitution -> f (Map CheckpointId Substitution)
f TCEnv
e = Map CheckpointId Substitution -> f (Map CheckpointId Substitution)
f (TCEnv -> Map CheckpointId Substitution
envCheckpoints TCEnv
e) f (Map CheckpointId Substitution)
-> (Map CheckpointId Substitution -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Map CheckpointId Substitution
x -> TCEnv
e { envCheckpoints :: Map CheckpointId Substitution
envCheckpoints = Map CheckpointId Substitution
x }

eGeneralizeMetas :: Lens' DoGeneralize TCEnv
eGeneralizeMetas :: (DoGeneralize -> f DoGeneralize) -> TCEnv -> f TCEnv
eGeneralizeMetas DoGeneralize -> f DoGeneralize
f TCEnv
e = DoGeneralize -> f DoGeneralize
f (TCEnv -> DoGeneralize
envGeneralizeMetas TCEnv
e) f DoGeneralize -> (DoGeneralize -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ DoGeneralize
x -> TCEnv
e { envGeneralizeMetas :: DoGeneralize
envGeneralizeMetas = DoGeneralize
x }

eGeneralizedVars :: Lens' (Map QName GeneralizedValue) TCEnv
eGeneralizedVars :: (Map QName GeneralizedValue -> f (Map QName GeneralizedValue))
-> TCEnv -> f TCEnv
eGeneralizedVars Map QName GeneralizedValue -> f (Map QName GeneralizedValue)
f TCEnv
e = Map QName GeneralizedValue -> f (Map QName GeneralizedValue)
f (TCEnv -> Map QName GeneralizedValue
envGeneralizedVars TCEnv
e) f (Map QName GeneralizedValue)
-> (Map QName GeneralizedValue -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Map QName GeneralizedValue
x -> TCEnv
e { envGeneralizedVars :: Map QName GeneralizedValue
envGeneralizedVars = Map QName GeneralizedValue
x }

eActiveBackendName :: Lens' (Maybe BackendName) TCEnv
eActiveBackendName :: (Maybe String -> f (Maybe String)) -> TCEnv -> f TCEnv
eActiveBackendName Maybe String -> f (Maybe String)
f TCEnv
e = Maybe String -> f (Maybe String)
f (TCEnv -> Maybe String
envActiveBackendName TCEnv
e) f (Maybe String) -> (Maybe String -> TCEnv) -> f TCEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Maybe String
x -> TCEnv
e { envActiveBackendName :: Maybe String
envActiveBackendName = Maybe String
x }

---------------------------------------------------------------------------
-- ** Context
---------------------------------------------------------------------------

-- | The @Context@ is a stack of 'ContextEntry's.
type Context      = [ContextEntry]
type ContextEntry = Dom (Name, Type)

---------------------------------------------------------------------------
-- ** Let bindings
---------------------------------------------------------------------------

type LetBindings = Map Name (Open (Term, Dom Type))

---------------------------------------------------------------------------
-- ** Abstract mode
---------------------------------------------------------------------------

data AbstractMode
  = AbstractMode        -- ^ Abstract things in the current module can be accessed.
  | ConcreteMode        -- ^ No abstract things can be accessed.
  | IgnoreAbstractMode  -- ^ All abstract things can be accessed.
  deriving (Typeable AbstractMode
DataType
Constr
Typeable AbstractMode
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> AbstractMode -> c AbstractMode)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c AbstractMode)
-> (AbstractMode -> Constr)
-> (AbstractMode -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c AbstractMode))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c AbstractMode))
-> ((forall b. Data b => b -> b) -> AbstractMode -> AbstractMode)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> AbstractMode -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> AbstractMode -> r)
-> (forall u. (forall d. Data d => d -> u) -> AbstractMode -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> AbstractMode -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode)
-> Data AbstractMode
AbstractMode -> DataType
AbstractMode -> Constr
(forall b. Data b => b -> b) -> AbstractMode -> AbstractMode
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractMode -> c AbstractMode
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractMode
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) -> AbstractMode -> u
forall u. (forall d. Data d => d -> u) -> AbstractMode -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractMode -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractMode -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractMode
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractMode -> c AbstractMode
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AbstractMode)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractMode)
$cIgnoreAbstractMode :: Constr
$cConcreteMode :: Constr
$cAbstractMode :: Constr
$tAbstractMode :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode
gmapMp :: (forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode
gmapM :: (forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AbstractMode -> m AbstractMode
gmapQi :: Int -> (forall d. Data d => d -> u) -> AbstractMode -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AbstractMode -> u
gmapQ :: (forall d. Data d => d -> u) -> AbstractMode -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AbstractMode -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractMode -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractMode -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractMode -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AbstractMode -> r
gmapT :: (forall b. Data b => b -> b) -> AbstractMode -> AbstractMode
$cgmapT :: (forall b. Data b => b -> b) -> AbstractMode -> AbstractMode
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractMode)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AbstractMode)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c AbstractMode)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AbstractMode)
dataTypeOf :: AbstractMode -> DataType
$cdataTypeOf :: AbstractMode -> DataType
toConstr :: AbstractMode -> Constr
$ctoConstr :: AbstractMode -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractMode
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AbstractMode
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractMode -> c AbstractMode
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AbstractMode -> c AbstractMode
$cp1Data :: Typeable AbstractMode
Data, Int -> AbstractMode -> ShowS
[AbstractMode] -> ShowS
AbstractMode -> String
(Int -> AbstractMode -> ShowS)
-> (AbstractMode -> String)
-> ([AbstractMode] -> ShowS)
-> Show AbstractMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbstractMode] -> ShowS
$cshowList :: [AbstractMode] -> ShowS
show :: AbstractMode -> String
$cshow :: AbstractMode -> String
showsPrec :: Int -> AbstractMode -> ShowS
$cshowsPrec :: Int -> AbstractMode -> ShowS
Show, AbstractMode -> AbstractMode -> Bool
(AbstractMode -> AbstractMode -> Bool)
-> (AbstractMode -> AbstractMode -> Bool) -> Eq AbstractMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbstractMode -> AbstractMode -> Bool
$c/= :: AbstractMode -> AbstractMode -> Bool
== :: AbstractMode -> AbstractMode -> Bool
$c== :: AbstractMode -> AbstractMode -> Bool
Eq)

aDefToMode :: IsAbstract -> AbstractMode
aDefToMode :: IsAbstract -> AbstractMode
aDefToMode IsAbstract
AbstractDef = AbstractMode
AbstractMode
aDefToMode IsAbstract
ConcreteDef = AbstractMode
ConcreteMode

aModeToDef :: AbstractMode -> Maybe IsAbstract
aModeToDef :: AbstractMode -> Maybe IsAbstract
aModeToDef AbstractMode
AbstractMode = IsAbstract -> Maybe IsAbstract
forall a. a -> Maybe a
Just IsAbstract
AbstractDef
aModeToDef AbstractMode
ConcreteMode = IsAbstract -> Maybe IsAbstract
forall a. a -> Maybe a
Just IsAbstract
ConcreteDef
aModeToDef AbstractMode
_ = Maybe IsAbstract
forall a. Maybe a
Nothing

---------------------------------------------------------------------------
-- ** Insertion of implicit arguments
---------------------------------------------------------------------------

data ExpandHidden
  = ExpandLast      -- ^ Add implicit arguments in the end until type is no longer hidden 'Pi'.
  | DontExpandLast  -- ^ Do not append implicit arguments.
  | ReallyDontExpandLast -- ^ Makes 'doExpandLast' have no effect. Used to avoid implicit insertion of arguments to metavariables.
  deriving (ExpandHidden -> ExpandHidden -> Bool
(ExpandHidden -> ExpandHidden -> Bool)
-> (ExpandHidden -> ExpandHidden -> Bool) -> Eq ExpandHidden
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExpandHidden -> ExpandHidden -> Bool
$c/= :: ExpandHidden -> ExpandHidden -> Bool
== :: ExpandHidden -> ExpandHidden -> Bool
$c== :: ExpandHidden -> ExpandHidden -> Bool
Eq, Typeable ExpandHidden
DataType
Constr
Typeable ExpandHidden
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ExpandHidden -> c ExpandHidden)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ExpandHidden)
-> (ExpandHidden -> Constr)
-> (ExpandHidden -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ExpandHidden))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ExpandHidden))
-> ((forall b. Data b => b -> b) -> ExpandHidden -> ExpandHidden)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ExpandHidden -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ExpandHidden -> r)
-> (forall u. (forall d. Data d => d -> u) -> ExpandHidden -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ExpandHidden -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden)
-> Data ExpandHidden
ExpandHidden -> DataType
ExpandHidden -> Constr
(forall b. Data b => b -> b) -> ExpandHidden -> ExpandHidden
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExpandHidden -> c ExpandHidden
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExpandHidden
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) -> ExpandHidden -> u
forall u. (forall d. Data d => d -> u) -> ExpandHidden -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExpandHidden -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExpandHidden -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExpandHidden
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExpandHidden -> c ExpandHidden
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExpandHidden)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ExpandHidden)
$cReallyDontExpandLast :: Constr
$cDontExpandLast :: Constr
$cExpandLast :: Constr
$tExpandHidden :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden
gmapMp :: (forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden
gmapM :: (forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ExpandHidden -> m ExpandHidden
gmapQi :: Int -> (forall d. Data d => d -> u) -> ExpandHidden -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ExpandHidden -> u
gmapQ :: (forall d. Data d => d -> u) -> ExpandHidden -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ExpandHidden -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExpandHidden -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExpandHidden -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExpandHidden -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExpandHidden -> r
gmapT :: (forall b. Data b => b -> b) -> ExpandHidden -> ExpandHidden
$cgmapT :: (forall b. Data b => b -> b) -> ExpandHidden -> ExpandHidden
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ExpandHidden)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ExpandHidden)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ExpandHidden)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExpandHidden)
dataTypeOf :: ExpandHidden -> DataType
$cdataTypeOf :: ExpandHidden -> DataType
toConstr :: ExpandHidden -> Constr
$ctoConstr :: ExpandHidden -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExpandHidden
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExpandHidden
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExpandHidden -> c ExpandHidden
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExpandHidden -> c ExpandHidden
$cp1Data :: Typeable ExpandHidden
Data)

isDontExpandLast :: ExpandHidden -> Bool
isDontExpandLast :: ExpandHidden -> Bool
isDontExpandLast ExpandHidden
ExpandLast           = Bool
False
isDontExpandLast ExpandHidden
DontExpandLast       = Bool
True
isDontExpandLast ExpandHidden
ReallyDontExpandLast = Bool
True

-- | A candidate solution for an instance meta is a term with its type.
--   It may be the case that the candidate is not fully applied yet or
--   of the wrong type, hence the need for the type.
data Candidate  = Candidate { Candidate -> Term
candidateTerm :: Term
                            , Candidate -> Type
candidateType :: Type
                            , Candidate -> Bool
candidateOverlappable :: Bool
                            }
  deriving (Int -> Candidate -> ShowS
[Candidate] -> ShowS
Candidate -> String
(Int -> Candidate -> ShowS)
-> (Candidate -> String)
-> ([Candidate] -> ShowS)
-> Show Candidate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Candidate] -> ShowS
$cshowList :: [Candidate] -> ShowS
show :: Candidate -> String
$cshow :: Candidate -> String
showsPrec :: Int -> Candidate -> ShowS
$cshowsPrec :: Int -> Candidate -> ShowS
Show, Typeable Candidate
DataType
Constr
Typeable Candidate
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Candidate -> c Candidate)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Candidate)
-> (Candidate -> Constr)
-> (Candidate -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Candidate))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Candidate))
-> ((forall b. Data b => b -> b) -> Candidate -> Candidate)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Candidate -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Candidate -> r)
-> (forall u. (forall d. Data d => d -> u) -> Candidate -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Candidate -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Candidate -> m Candidate)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Candidate -> m Candidate)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Candidate -> m Candidate)
-> Data Candidate
Candidate -> DataType
Candidate -> Constr
(forall b. Data b => b -> b) -> Candidate -> Candidate
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Candidate -> c Candidate
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Candidate
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) -> Candidate -> u
forall u. (forall d. Data d => d -> u) -> Candidate -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Candidate -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Candidate -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Candidate -> m Candidate
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Candidate -> m Candidate
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Candidate
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Candidate -> c Candidate
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Candidate)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Candidate)
$cCandidate :: Constr
$tCandidate :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Candidate -> m Candidate
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Candidate -> m Candidate
gmapMp :: (forall d. Data d => d -> m d) -> Candidate -> m Candidate
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Candidate -> m Candidate
gmapM :: (forall d. Data d => d -> m d) -> Candidate -> m Candidate
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Candidate -> m Candidate
gmapQi :: Int -> (forall d. Data d => d -> u) -> Candidate -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Candidate -> u
gmapQ :: (forall d. Data d => d -> u) -> Candidate -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Candidate -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Candidate -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Candidate -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Candidate -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Candidate -> r
gmapT :: (forall b. Data b => b -> b) -> Candidate -> Candidate
$cgmapT :: (forall b. Data b => b -> b) -> Candidate -> Candidate
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Candidate)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Candidate)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Candidate)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Candidate)
dataTypeOf :: Candidate -> DataType
$cdataTypeOf :: Candidate -> DataType
toConstr :: Candidate -> Constr
$ctoConstr :: Candidate -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Candidate
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Candidate
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Candidate -> c Candidate
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Candidate -> c Candidate
$cp1Data :: Typeable Candidate
Data)

instance Free Candidate where
  freeVars' :: Candidate -> FreeM a c
freeVars' (Candidate Term
t Type
u Bool
_) = (Term, Type) -> FreeM a c
forall t a c. (Free t, IsVarSet a c) => t -> FreeM a c
freeVars' (Term
t, Type
u)

---------------------------------------------------------------------------
-- * Type checking warnings (aka non-fatal errors)
---------------------------------------------------------------------------

-- | A non-fatal error is an error which does not prevent us from
-- checking the document further and interacting with the user.

data Warning
  = NicifierIssue            DeclarationWarning
  | TerminationIssue         [TerminationError]
  | UnreachableClauses       QName [Range]
  -- ^ `UnreachableClauses f rs` means that the clauses in `f` whose ranges are rs
  --   are unreachable
  | CoverageIssue            QName [(Telescope, [NamedArg DeBruijnPattern])]
  -- ^ `CoverageIssue f pss` means that `pss` are not covered in `f`
  | CoverageNoExactSplit     QName [Clause]
  | NotStrictlyPositive      QName (Seq OccursWhere)
  | UnsolvedMetaVariables    [Range]  -- ^ Do not use directly with 'warning'
  | UnsolvedInteractionMetas [Range]  -- ^ Do not use directly with 'warning'
  | UnsolvedConstraints      Constraints
    -- ^ Do not use directly with 'warning'
  | CantGeneralizeOverSorts [MetaId]
  | AbsurdPatternRequiresNoRHS [NamedArg DeBruijnPattern]
  | OldBuiltin               String String
    -- ^ In `OldBuiltin old new`, the BUILTIN old has been replaced by new
  | EmptyRewritePragma
    -- ^ If the user wrote just @{-\# REWRITE \#-}@.
  | IllformedAsClause String
    -- ^ If the user wrote something other than an unqualified name
    --   in the @as@ clause of an @import@ statement.
    --   The 'String' gives optionally extra explanation.
  | ClashesViaRenaming NameOrModule [C.Name]
    -- ^ If a `renaming' import directive introduces a name or module name clash
    --   in the exported names of a module.
    --   (See issue #4154.)
  | UselessPublic
    -- ^ If the user opens a module public before the module header.
    --   (See issue #2377.)
  | UselessInline            QName
  | WrongInstanceDeclaration
  | InstanceWithExplicitArg  QName
  -- ^ An instance was declared with an implicit argument, which means it
  --   will never actually be considered by instance search.
  | InstanceNoOutputTypeName Doc
  -- ^ The type of an instance argument doesn't end in a named or
  -- variable type, so it will never be considered by instance search.
  | InstanceArgWithExplicitArg Doc
  -- ^ As InstanceWithExplicitArg, but for local bindings rather than
  --   top-level instances.
  | InversionDepthReached    QName
  -- ^ The --inversion-max-depth was reached.
  -- Generic warnings for one-off things
  | GenericWarning           Doc
    -- ^ Harmless generic warning (not an error)
  | GenericNonFatalError     Doc
    -- ^ Generic error which doesn't abort proceedings (not a warning)
  -- Safe flag errors
  | SafeFlagPostulate C.Name
  | SafeFlagPragma [String]                -- ^ Unsafe OPTIONS.
  | SafeFlagNonTerminating
  | SafeFlagTerminating
  | SafeFlagWithoutKFlagPrimEraseEquality
  | WithoutKFlagPrimEraseEquality
  | SafeFlagNoPositivityCheck
  | SafeFlagPolarity
  | SafeFlagNoUniverseCheck
  | SafeFlagNoCoverageCheck
  | SafeFlagInjective
  | SafeFlagEta                            -- ^ ETA pragma is unsafe.
  | ParseWarning             ParseWarning
  | LibraryWarning           LibWarning
  | DeprecationWarning String String String
    -- ^ `DeprecationWarning old new version`:
    --   `old` is deprecated, use `new` instead. This will be an error in Agda `version`.
  | UserWarning String
    -- ^ User-defined warning (e.g. to mention that a name is deprecated)
  | FixityInRenamingModule (NonEmpty Range)
    -- ^ Fixity of modules cannot be changed via renaming (since modules have no fixity).
  | ModuleDoesntExport C.QName [C.ImportedName]
    -- ^ Some imported names are not actually exported by the source module
  | InfectiveImport String ModuleName
    -- ^ Importing a file using an infective option into one which doesn't
  | CoInfectiveImport String ModuleName
    -- ^ Importing a file not using a coinfective option from one which does
  | RewriteNonConfluent Term Term Term Doc
    -- ^ Confluence checker found critical pair and equality checking
    --   resulted in a type error
  | RewriteMaybeNonConfluent Term Term [Doc]
    -- ^ Confluence checker got stuck on computing overlap between two
    --   rewrite rules
  | PragmaCompileErased BackendName QName
    -- ^ COMPILE directive for an erased symbol
  | NotInScopeW [C.QName]
    -- ^ Out of scope error we can recover from
  deriving (Int -> Warning -> ShowS
[Warning] -> ShowS
Warning -> String
(Int -> Warning -> ShowS)
-> (Warning -> String) -> ([Warning] -> ShowS) -> Show Warning
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Warning] -> ShowS
$cshowList :: [Warning] -> ShowS
show :: Warning -> String
$cshow :: Warning -> String
showsPrec :: Int -> Warning -> ShowS
$cshowsPrec :: Int -> Warning -> ShowS
Show , Typeable Warning
DataType
Constr
Typeable Warning
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Warning -> c Warning)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Warning)
-> (Warning -> Constr)
-> (Warning -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Warning))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Warning))
-> ((forall b. Data b => b -> b) -> Warning -> Warning)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Warning -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Warning -> r)
-> (forall u. (forall d. Data d => d -> u) -> Warning -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Warning -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Warning -> m Warning)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Warning -> m Warning)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Warning -> m Warning)
-> Data Warning
Warning -> DataType
Warning -> Constr
(forall b. Data b => b -> b) -> Warning -> Warning
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Warning -> c Warning
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Warning
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) -> Warning -> u
forall u. (forall d. Data d => d -> u) -> Warning -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Warning -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Warning -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Warning -> m Warning
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Warning -> m Warning
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Warning
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Warning -> c Warning
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Warning)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Warning)
$cNotInScopeW :: Constr
$cPragmaCompileErased :: Constr
$cRewriteMaybeNonConfluent :: Constr
$cRewriteNonConfluent :: Constr
$cCoInfectiveImport :: Constr
$cInfectiveImport :: Constr
$cModuleDoesntExport :: Constr
$cFixityInRenamingModule :: Constr
$cUserWarning :: Constr
$cDeprecationWarning :: Constr
$cLibraryWarning :: Constr
$cParseWarning :: Constr
$cSafeFlagEta :: Constr
$cSafeFlagInjective :: Constr
$cSafeFlagNoCoverageCheck :: Constr
$cSafeFlagNoUniverseCheck :: Constr
$cSafeFlagPolarity :: Constr
$cSafeFlagNoPositivityCheck :: Constr
$cWithoutKFlagPrimEraseEquality :: Constr
$cSafeFlagWithoutKFlagPrimEraseEquality :: Constr
$cSafeFlagTerminating :: Constr
$cSafeFlagNonTerminating :: Constr
$cSafeFlagPragma :: Constr
$cSafeFlagPostulate :: Constr
$cGenericNonFatalError :: Constr
$cGenericWarning :: Constr
$cInversionDepthReached :: Constr
$cInstanceArgWithExplicitArg :: Constr
$cInstanceNoOutputTypeName :: Constr
$cInstanceWithExplicitArg :: Constr
$cWrongInstanceDeclaration :: Constr
$cUselessInline :: Constr
$cUselessPublic :: Constr
$cClashesViaRenaming :: Constr
$cIllformedAsClause :: Constr
$cEmptyRewritePragma :: Constr
$cOldBuiltin :: Constr
$cAbsurdPatternRequiresNoRHS :: Constr
$cCantGeneralizeOverSorts :: Constr
$cUnsolvedConstraints :: Constr
$cUnsolvedInteractionMetas :: Constr
$cUnsolvedMetaVariables :: Constr
$cNotStrictlyPositive :: Constr
$cCoverageNoExactSplit :: Constr
$cCoverageIssue :: Constr
$cUnreachableClauses :: Constr
$cTerminationIssue :: Constr
$cNicifierIssue :: Constr
$tWarning :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Warning -> m Warning
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Warning -> m Warning
gmapMp :: (forall d. Data d => d -> m d) -> Warning -> m Warning
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Warning -> m Warning
gmapM :: (forall d. Data d => d -> m d) -> Warning -> m Warning
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Warning -> m Warning
gmapQi :: Int -> (forall d. Data d => d -> u) -> Warning -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Warning -> u
gmapQ :: (forall d. Data d => d -> u) -> Warning -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Warning -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Warning -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Warning -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Warning -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Warning -> r
gmapT :: (forall b. Data b => b -> b) -> Warning -> Warning
$cgmapT :: (forall b. Data b => b -> b) -> Warning -> Warning
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Warning)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Warning)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Warning)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Warning)
dataTypeOf :: Warning -> DataType
$cdataTypeOf :: Warning -> DataType
toConstr :: Warning -> Constr
$ctoConstr :: Warning -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Warning
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Warning
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Warning -> c Warning
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Warning -> c Warning
$cp1Data :: Typeable Warning
Data)


warningName :: Warning -> WarningName
warningName :: Warning -> WarningName
warningName = \case
  -- special cases
  NicifierIssue DeclarationWarning
dw             -> DeclarationWarning -> WarningName
declarationWarningName DeclarationWarning
dw
  ParseWarning ParseWarning
pw              -> ParseWarning -> WarningName
parseWarningName ParseWarning
pw
  LibraryWarning LibWarning
lw            -> LibWarning -> WarningName
libraryWarningName LibWarning
lw
  -- typechecking errors
  CantGeneralizeOverSorts{}    -> WarningName
CantGeneralizeOverSorts_
  AbsurdPatternRequiresNoRHS{} -> WarningName
AbsurdPatternRequiresNoRHS_
  CoverageIssue{}              -> WarningName
CoverageIssue_
  CoverageNoExactSplit{}       -> WarningName
CoverageNoExactSplit_
  DeprecationWarning{}         -> WarningName
DeprecationWarning_
  Warning
EmptyRewritePragma           -> WarningName
EmptyRewritePragma_
  IllformedAsClause{}          -> WarningName
IllformedAsClause_
  WrongInstanceDeclaration{}   -> WarningName
WrongInstanceDeclaration_
  InstanceWithExplicitArg{}    -> WarningName
InstanceWithExplicitArg_
  InstanceNoOutputTypeName{}   -> WarningName
InstanceNoOutputTypeName_
  InstanceArgWithExplicitArg{} -> WarningName
InstanceArgWithExplicitArg_
  FixityInRenamingModule{}     -> WarningName
FixityInRenamingModule_
  GenericNonFatalError{}       -> WarningName
GenericNonFatalError_
  GenericWarning{}             -> WarningName
GenericWarning_
  InversionDepthReached{}      -> WarningName
InversionDepthReached_
  ModuleDoesntExport{}         -> WarningName
ModuleDoesntExport_
  NotInScopeW{}                -> WarningName
NotInScope_
  NotStrictlyPositive{}        -> WarningName
NotStrictlyPositive_
  OldBuiltin{}                 -> WarningName
OldBuiltin_
  Warning
SafeFlagNoPositivityCheck    -> WarningName
SafeFlagNoPositivityCheck_
  Warning
SafeFlagNonTerminating       -> WarningName
SafeFlagNonTerminating_
  Warning
SafeFlagNoUniverseCheck      -> WarningName
SafeFlagNoUniverseCheck_
  Warning
SafeFlagPolarity             -> WarningName
SafeFlagPolarity_
  SafeFlagPostulate{}          -> WarningName
SafeFlagPostulate_
  SafeFlagPragma{}             -> WarningName
SafeFlagPragma_
  Warning
SafeFlagEta                  -> WarningName
SafeFlagEta_
  Warning
SafeFlagInjective            -> WarningName
SafeFlagInjective_
  Warning
SafeFlagNoCoverageCheck      -> WarningName
SafeFlagNoCoverageCheck_
  Warning
SafeFlagWithoutKFlagPrimEraseEquality -> WarningName
SafeFlagWithoutKFlagPrimEraseEquality_
  Warning
WithoutKFlagPrimEraseEquality -> WarningName
WithoutKFlagPrimEraseEquality_
  Warning
SafeFlagTerminating          -> WarningName
SafeFlagTerminating_
  TerminationIssue{}           -> WarningName
TerminationIssue_
  UnreachableClauses{}         -> WarningName
UnreachableClauses_
  UnsolvedInteractionMetas{}   -> WarningName
UnsolvedInteractionMetas_
  UnsolvedConstraints{}        -> WarningName
UnsolvedConstraints_
  UnsolvedMetaVariables{}      -> WarningName
UnsolvedMetaVariables_
  UselessInline{}              -> WarningName
UselessInline_
  UselessPublic{}              -> WarningName
UselessPublic_
  ClashesViaRenaming{}         -> WarningName
ClashesViaRenaming_
  UserWarning{}                -> WarningName
UserWarning_
  InfectiveImport{}            -> WarningName
InfectiveImport_
  CoInfectiveImport{}          -> WarningName
CoInfectiveImport_
  RewriteNonConfluent{}        -> WarningName
RewriteNonConfluent_
  RewriteMaybeNonConfluent{}   -> WarningName
RewriteMaybeNonConfluent_
  PragmaCompileErased{}        -> WarningName
PragmaCompileErased_

data TCWarning
  = TCWarning
    { TCWarning -> Range
tcWarningRange :: Range
        -- ^ Range where the warning was raised
    , TCWarning -> Warning
tcWarning   :: Warning
        -- ^ The warning itself
    , TCWarning -> Doc
tcWarningPrintedWarning :: Doc
        -- ^ The warning printed in the state and environment where it was raised
    , TCWarning -> Bool
tcWarningCached :: Bool
        -- ^ Should the warning be affected by caching.
    }
  deriving Int -> TCWarning -> ShowS
[TCWarning] -> ShowS
TCWarning -> String
(Int -> TCWarning -> ShowS)
-> (TCWarning -> String)
-> ([TCWarning] -> ShowS)
-> Show TCWarning
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TCWarning] -> ShowS
$cshowList :: [TCWarning] -> ShowS
show :: TCWarning -> String
$cshow :: TCWarning -> String
showsPrec :: Int -> TCWarning -> ShowS
$cshowsPrec :: Int -> TCWarning -> ShowS
Show


tcWarningOrigin :: TCWarning -> SrcFile
tcWarningOrigin :: TCWarning -> SrcFile
tcWarningOrigin = Range -> SrcFile
rangeFile (Range -> SrcFile) -> (TCWarning -> Range) -> TCWarning -> SrcFile
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCWarning -> Range
tcWarningRange

instance HasRange TCWarning where
  getRange :: TCWarning -> Range
getRange = TCWarning -> Range
tcWarningRange

-- used for merging lists of warnings
instance Eq TCWarning where
  == :: TCWarning -> TCWarning -> Bool
(==) = Doc -> Doc -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Doc -> Doc -> Bool)
-> (TCWarning -> Doc) -> TCWarning -> TCWarning -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` TCWarning -> Doc
tcWarningPrintedWarning

---------------------------------------------------------------------------
-- * Type checking errors
---------------------------------------------------------------------------

-- | Information about a call.

data CallInfo = CallInfo
  { CallInfo -> QName
callInfoTarget :: QName
    -- ^ Target function name.
  , CallInfo -> Range
callInfoRange :: Range
    -- ^ Range of the target function.
  , CallInfo -> Closure Term
callInfoCall :: Closure Term
    -- ^ To be formatted representation of the call.
  } deriving (Typeable CallInfo
DataType
Constr
Typeable CallInfo
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> CallInfo -> c CallInfo)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CallInfo)
-> (CallInfo -> Constr)
-> (CallInfo -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CallInfo))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CallInfo))
-> ((forall b. Data b => b -> b) -> CallInfo -> CallInfo)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CallInfo -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CallInfo -> r)
-> (forall u. (forall d. Data d => d -> u) -> CallInfo -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> CallInfo -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CallInfo -> m CallInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CallInfo -> m CallInfo)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CallInfo -> m CallInfo)
-> Data CallInfo
CallInfo -> DataType
CallInfo -> Constr
(forall b. Data b => b -> b) -> CallInfo -> CallInfo
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CallInfo -> c CallInfo
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CallInfo
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) -> CallInfo -> u
forall u. (forall d. Data d => d -> u) -> CallInfo -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CallInfo -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CallInfo -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CallInfo -> m CallInfo
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CallInfo -> m CallInfo
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CallInfo
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CallInfo -> c CallInfo
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CallInfo)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CallInfo)
$cCallInfo :: Constr
$tCallInfo :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> CallInfo -> m CallInfo
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CallInfo -> m CallInfo
gmapMp :: (forall d. Data d => d -> m d) -> CallInfo -> m CallInfo
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CallInfo -> m CallInfo
gmapM :: (forall d. Data d => d -> m d) -> CallInfo -> m CallInfo
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CallInfo -> m CallInfo
gmapQi :: Int -> (forall d. Data d => d -> u) -> CallInfo -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CallInfo -> u
gmapQ :: (forall d. Data d => d -> u) -> CallInfo -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CallInfo -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CallInfo -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CallInfo -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CallInfo -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CallInfo -> r
gmapT :: (forall b. Data b => b -> b) -> CallInfo -> CallInfo
$cgmapT :: (forall b. Data b => b -> b) -> CallInfo -> CallInfo
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CallInfo)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CallInfo)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CallInfo)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CallInfo)
dataTypeOf :: CallInfo -> DataType
$cdataTypeOf :: CallInfo -> DataType
toConstr :: CallInfo -> Constr
$ctoConstr :: CallInfo -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CallInfo
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CallInfo
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CallInfo -> c CallInfo
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CallInfo -> c CallInfo
$cp1Data :: Typeable CallInfo
Data, Int -> CallInfo -> ShowS
[CallInfo] -> ShowS
CallInfo -> String
(Int -> CallInfo -> ShowS)
-> (CallInfo -> String) -> ([CallInfo] -> ShowS) -> Show CallInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CallInfo] -> ShowS
$cshowList :: [CallInfo] -> ShowS
show :: CallInfo -> String
$cshow :: CallInfo -> String
showsPrec :: Int -> CallInfo -> ShowS
$cshowsPrec :: Int -> CallInfo -> ShowS
Show)

-- no Eq, Ord instances: too expensive! (see issues 851, 852)

-- | We only 'show' the name of the callee.
instance Pretty CallInfo where pretty :: CallInfo -> Doc
pretty = QName -> Doc
forall a. Pretty a => a -> Doc
pretty (QName -> Doc) -> (CallInfo -> QName) -> CallInfo -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CallInfo -> QName
callInfoTarget
instance AllNames CallInfo where allNames :: CallInfo -> Seq QName
allNames = QName -> Seq QName
forall el coll. Singleton el coll => el -> coll
singleton (QName -> Seq QName)
-> (CallInfo -> QName) -> CallInfo -> Seq QName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CallInfo -> QName
callInfoTarget

-- UNUSED, but keep!
-- -- | Call pathes are sequences of 'CallInfo's starting from a 'callSource'.
-- data CallPath = CallPath
--   { callSource :: QName
--     -- ^ The originator of the first call.
--   , callInfos :: [CallInfo]
--     -- ^ The calls, in order from source to final target.
--   }
--   deriving (Show)

-- -- | 'CallPath'es can be connected, but there is no empty callpath.
-- --   Thus, they form a semigroup, but we choose to abuse 'Monoid'.
-- instance Monoid CallPath where
--   mempty = __IMPOSSIBLE__
--   mappend (CallPath src cs) (CallPath _ cs') = CallPath src $ cs ++ cs'

-- | Information about a mutual block which did not pass the
-- termination checker.

data TerminationError = TerminationError
  { TerminationError -> [QName]
termErrFunctions :: [QName]
    -- ^ The functions which failed to check. (May not include
    -- automatically generated functions.)
  , TerminationError -> [CallInfo]
termErrCalls :: [CallInfo]
    -- ^ The problematic call sites.
  } deriving (Typeable TerminationError
DataType
Constr
Typeable TerminationError
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TerminationError -> c TerminationError)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TerminationError)
-> (TerminationError -> Constr)
-> (TerminationError -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TerminationError))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c TerminationError))
-> ((forall b. Data b => b -> b)
    -> TerminationError -> TerminationError)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TerminationError -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TerminationError -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> TerminationError -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> TerminationError -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> TerminationError -> m TerminationError)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> TerminationError -> m TerminationError)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> TerminationError -> m TerminationError)
-> Data TerminationError
TerminationError -> DataType
TerminationError -> Constr
(forall b. Data b => b -> b)
-> TerminationError -> TerminationError
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TerminationError -> c TerminationError
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TerminationError
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) -> TerminationError -> u
forall u. (forall d. Data d => d -> u) -> TerminationError -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TerminationError -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TerminationError -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> TerminationError -> m TerminationError
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TerminationError -> m TerminationError
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TerminationError
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TerminationError -> c TerminationError
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TerminationError)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TerminationError)
$cTerminationError :: Constr
$tTerminationError :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> TerminationError -> m TerminationError
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TerminationError -> m TerminationError
gmapMp :: (forall d. Data d => d -> m d)
-> TerminationError -> m TerminationError
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TerminationError -> m TerminationError
gmapM :: (forall d. Data d => d -> m d)
-> TerminationError -> m TerminationError
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> TerminationError -> m TerminationError
gmapQi :: Int -> (forall d. Data d => d -> u) -> TerminationError -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> TerminationError -> u
gmapQ :: (forall d. Data d => d -> u) -> TerminationError -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TerminationError -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TerminationError -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TerminationError -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TerminationError -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TerminationError -> r
gmapT :: (forall b. Data b => b -> b)
-> TerminationError -> TerminationError
$cgmapT :: (forall b. Data b => b -> b)
-> TerminationError -> TerminationError
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TerminationError)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TerminationError)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c TerminationError)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TerminationError)
dataTypeOf :: TerminationError -> DataType
$cdataTypeOf :: TerminationError -> DataType
toConstr :: TerminationError -> Constr
$ctoConstr :: TerminationError -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TerminationError
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TerminationError
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TerminationError -> c TerminationError
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TerminationError -> c TerminationError
$cp1Data :: Typeable TerminationError
Data, Int -> TerminationError -> ShowS
[TerminationError] -> ShowS
TerminationError -> String
(Int -> TerminationError -> ShowS)
-> (TerminationError -> String)
-> ([TerminationError] -> ShowS)
-> Show TerminationError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TerminationError] -> ShowS
$cshowList :: [TerminationError] -> ShowS
show :: TerminationError -> String
$cshow :: TerminationError -> String
showsPrec :: Int -> TerminationError -> ShowS
$cshowsPrec :: Int -> TerminationError -> ShowS
Show)

-- | Error when splitting a pattern variable into possible constructor patterns.
data SplitError
  = NotADatatype        (Closure Type)  -- ^ Neither data type nor record.
  | IrrelevantDatatype  (Closure Type)  -- ^ Data type, but in irrelevant position.
  | ErasedDatatype Bool (Closure Type)  -- ^ Data type, but in erased position.
                                        --   If the boolean is 'True',
                                        --   then the reason for the
                                        --   error is that the K rule
                                        --   is turned off.
  | CoinductiveDatatype (Closure Type)  -- ^ Split on codata not allowed.
  -- UNUSED, but keep!
  -- -- | NoRecordConstructor Type  -- ^ record type, but no constructor
  | UnificationStuck
    { SplitError -> QName
cantSplitConName  :: QName        -- ^ Constructor.
    , SplitError -> Telescope
cantSplitTel      :: Telescope    -- ^ Context for indices.
    , SplitError -> [Arg Term]
cantSplitConIdx   :: Args         -- ^ Inferred indices (from type of constructor).
    , SplitError -> [Arg Term]
cantSplitGivenIdx :: Args         -- ^ Expected indices (from checking pattern).
    , SplitError -> [UnificationFailure]
cantSplitFailures :: [UnificationFailure] -- ^ Reason(s) why unification got stuck.
    }
  | CosplitCatchall
      -- ^ Copattern split with a catchall
  | CosplitNoTarget
      -- ^ We do not know the target type of the clause.
  | CosplitNoRecordType (Closure Type)
      -- ^ Target type is not a record type.
  | CannotCreateMissingClause QName (Telescope,[NamedArg DeBruijnPattern]) Doc (Closure (Abs Type))

  | GenericSplitError String
  deriving (Int -> SplitError -> ShowS
[SplitError] -> ShowS
SplitError -> String
(Int -> SplitError -> ShowS)
-> (SplitError -> String)
-> ([SplitError] -> ShowS)
-> Show SplitError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SplitError] -> ShowS
$cshowList :: [SplitError] -> ShowS
show :: SplitError -> String
$cshow :: SplitError -> String
showsPrec :: Int -> SplitError -> ShowS
$cshowsPrec :: Int -> SplitError -> ShowS
Show)

data NegativeUnification
  = UnifyConflict Telescope Term Term
  | UnifyCycle Telescope Int Term
  deriving (Int -> NegativeUnification -> ShowS
[NegativeUnification] -> ShowS
NegativeUnification -> String
(Int -> NegativeUnification -> ShowS)
-> (NegativeUnification -> String)
-> ([NegativeUnification] -> ShowS)
-> Show NegativeUnification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NegativeUnification] -> ShowS
$cshowList :: [NegativeUnification] -> ShowS
show :: NegativeUnification -> String
$cshow :: NegativeUnification -> String
showsPrec :: Int -> NegativeUnification -> ShowS
$cshowsPrec :: Int -> NegativeUnification -> ShowS
Show)

data UnificationFailure
  = UnifyIndicesNotVars Telescope Type Term Term Args -- ^ Failed to apply injectivity to constructor of indexed datatype
  | UnifyRecursiveEq Telescope Type Int Term          -- ^ Can't solve equation because variable occurs in (type of) lhs
  | UnifyReflexiveEq Telescope Type Term              -- ^ Can't solve reflexive equation because --without-K is enabled
  | UnifyUnusableModality Telescope Type Int Term Modality  -- ^ Can't solve equation because solution modality is less "usable"
  deriving (Int -> UnificationFailure -> ShowS
[UnificationFailure] -> ShowS
UnificationFailure -> String
(Int -> UnificationFailure -> ShowS)
-> (UnificationFailure -> String)
-> ([UnificationFailure] -> ShowS)
-> Show UnificationFailure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnificationFailure] -> ShowS
$cshowList :: [UnificationFailure] -> ShowS
show :: UnificationFailure -> String
$cshow :: UnificationFailure -> String
showsPrec :: Int -> UnificationFailure -> ShowS
$cshowsPrec :: Int -> UnificationFailure -> ShowS
Show)

data UnquoteError
  = BadVisibility String (Arg I.Term)
  | ConInsteadOfDef QName String String
  | DefInsteadOfCon QName String String
  | NonCanonical String I.Term
  | BlockedOnMeta TCState MetaId
  | UnquotePanic String
  deriving (Int -> UnquoteError -> ShowS
[UnquoteError] -> ShowS
UnquoteError -> String
(Int -> UnquoteError -> ShowS)
-> (UnquoteError -> String)
-> ([UnquoteError] -> ShowS)
-> Show UnquoteError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnquoteError] -> ShowS
$cshowList :: [UnquoteError] -> ShowS
show :: UnquoteError -> String
$cshow :: UnquoteError -> String
showsPrec :: Int -> UnquoteError -> ShowS
$cshowsPrec :: Int -> UnquoteError -> ShowS
Show)

data TypeError
        = InternalError String
        | NotImplemented String
        | NotSupported String
        | CompilationError String
        | PropMustBeSingleton
        | DataMustEndInSort Term
{- UNUSED
        | DataTooManyParameters
            -- ^ In @data D xs where@ the number of parameters @xs@ does not fit the
            --   the parameters given in the forward declaraion @data D Gamma : T@.
-}
        | ShouldEndInApplicationOfTheDatatype Type
            -- ^ The target of a constructor isn't an application of its
            -- datatype. The 'Type' records what it does target.
        | ShouldBeAppliedToTheDatatypeParameters Term Term
            -- ^ The target of a constructor isn't its datatype applied to
            --   something that isn't the parameters. First term is the correct
            --   target and the second term is the actual target.
        | ShouldBeApplicationOf Type QName
            -- ^ Expected a type to be an application of a particular datatype.
        | ConstructorPatternInWrongDatatype QName QName -- ^ constructor, datatype
        | CantResolveOverloadedConstructorsTargetingSameDatatype QName [QName]
          -- ^ Datatype, constructors.
        | DoesNotConstructAnElementOf QName Type -- ^ constructor, type
        | WrongHidingInLHS
            -- ^ The left hand side of a function definition has a hidden argument
            --   where a non-hidden was expected.
        | WrongHidingInLambda Type
            -- ^ Expected a non-hidden function and found a hidden lambda.
        | WrongHidingInApplication Type
            -- ^ A function is applied to a hidden argument where a non-hidden was expected.
        | WrongNamedArgument (NamedArg A.Expr) [NamedName]
            -- ^ A function is applied to a hidden named argument it does not have.
            -- The list contains names of possible hidden arguments at this point.
        | WrongIrrelevanceInLambda
            -- ^ Wrong user-given relevance annotation in lambda.
        | WrongQuantityInLambda
            -- ^ Wrong user-given quantity annotation in lambda.
        | WrongCohesionInLambda
            -- ^ Wrong user-given cohesion annotation in lambda.
        | QuantityMismatch Quantity Quantity
            -- ^ The given quantity does not correspond to the expected quantity.
        | HidingMismatch Hiding Hiding
            -- ^ The given hiding does not correspond to the expected hiding.
        | RelevanceMismatch Relevance Relevance
            -- ^ The given relevance does not correspond to the expected relevane.
        | UninstantiatedDotPattern A.Expr
        | ForcedConstructorNotInstantiated A.Pattern
        | IlltypedPattern A.Pattern Type
        | IllformedProjectionPattern A.Pattern
        | CannotEliminateWithPattern (NamedArg A.Pattern) Type
        | WrongNumberOfConstructorArguments QName Nat Nat
        | ShouldBeEmpty Type [DeBruijnPattern]
        | ShouldBeASort Type
            -- ^ The given type should have been a sort.
        | ShouldBePi Type
            -- ^ The given type should have been a pi.
        | ShouldBePath Type
        | ShouldBeRecordType Type
        | ShouldBeRecordPattern DeBruijnPattern
        | NotAProjectionPattern (NamedArg A.Pattern)
        | NotAProperTerm
        | InvalidTypeSort Sort
            -- ^ This sort is not a type expression.
        | InvalidType Term
            -- ^ This term is not a type expression.
        | FunctionTypeInSizeUniv Term
            -- ^ This term, a function type constructor, lives in
            --   @SizeUniv@, which is not allowed.
        | SplitOnIrrelevant (Dom Type)
        | SplitOnUnusableCohesion (Dom Type)
        -- UNUSED: -- | SplitOnErased (Dom Type)
        | SplitOnNonVariable Term Type
        | DefinitionIsIrrelevant QName
        | DefinitionIsErased QName
        | VariableIsIrrelevant Name
        | VariableIsErased Name
        | VariableIsOfUnusableCohesion Name Cohesion
        | UnequalLevel Comparison Level Level
        | UnequalTerms Comparison Term Term CompareAs
        | UnequalTypes Comparison Type Type
--      | UnequalTelescopes Comparison Telescope Telescope -- UNUSED
        | UnequalRelevance Comparison Term Term
            -- ^ The two function types have different relevance.
        | UnequalQuantity Comparison Term Term
            -- ^ The two function types have different relevance.
        | UnequalCohesion Comparison Term Term
            -- ^ The two function types have different cohesion.
        | UnequalHiding Term Term
            -- ^ The two function types have different hiding.
        | UnequalSorts Sort Sort
        | UnequalBecauseOfUniverseConflict Comparison Term Term
        | NotLeqSort Sort Sort
        | MetaCannotDependOn MetaId Nat
            -- ^ The arguments are the meta variable and the parameter that it wants to depend on.
        | MetaOccursInItself MetaId
        | MetaIrrelevantSolution MetaId Term
        | MetaErasedSolution MetaId Term
        | GenericError String
        | GenericDocError Doc
        | BuiltinMustBeConstructor String A.Expr
        | NoSuchBuiltinName String
        | DuplicateBuiltinBinding String Term Term
        | NoBindingForBuiltin String
        | NoSuchPrimitiveFunction String
        | DuplicatePrimitiveBinding String QName QName
        | ShadowedModule C.Name [A.ModuleName]
        | BuiltinInParameterisedModule String
        | IllegalLetInTelescope C.TypedBinding
        | IllegalPatternInTelescope C.Binder
        | NoRHSRequiresAbsurdPattern [NamedArg A.Pattern]
        | TooManyFields QName [C.Name] [C.Name]
          -- ^ Record type, fields not supplied by user, non-fields not supplied.
        | DuplicateFields [C.Name]
        | DuplicateConstructors [C.Name]
        | WithOnFreeVariable A.Expr Term
        | UnexpectedWithPatterns [A.Pattern]
        | WithClausePatternMismatch A.Pattern (NamedArg DeBruijnPattern)
        | FieldOutsideRecord
        | ModuleArityMismatch A.ModuleName Telescope [NamedArg A.Expr]
        | GeneralizeCyclicDependency
        | GeneralizeUnsolvedMeta
    -- Coverage errors
-- UNUSED:        | IncompletePatternMatching Term [Elim] -- can only happen if coverage checking is switched off
        | SplitError SplitError
        | ImpossibleConstructor QName NegativeUnification
    -- Positivity errors
        | TooManyPolarities QName Int
    -- Import errors
        | LocalVsImportedModuleClash ModuleName
        | SolvedButOpenHoles
          -- ^ Some interaction points (holes) have not been filled by user.
          --   There are not 'UnsolvedMetas' since unification solved them.
          --   This is an error, since interaction points are never filled
          --   without user interaction.
        | CyclicModuleDependency [C.TopLevelModuleName]
        | FileNotFound C.TopLevelModuleName [AbsolutePath]
        | OverlappingProjects AbsolutePath C.TopLevelModuleName C.TopLevelModuleName
        | AmbiguousTopLevelModuleName C.TopLevelModuleName [AbsolutePath]
        | ModuleNameUnexpected C.TopLevelModuleName C.TopLevelModuleName
          -- ^ Found module name, expected module name.
        | ModuleNameDoesntMatchFileName C.TopLevelModuleName [AbsolutePath]
        | ClashingFileNamesFor ModuleName [AbsolutePath]
        | ModuleDefinedInOtherFile C.TopLevelModuleName AbsolutePath AbsolutePath
          -- ^ Module name, file from which it was loaded, file which
          -- the include path says contains the module.
    -- Scope errors
        | BothWithAndRHS
        | AbstractConstructorNotInScope A.QName
        | NotInScope [C.QName]
        | NoSuchModule C.QName
        | AmbiguousName C.QName (NonEmpty A.QName)
        | AmbiguousModule C.QName (NonEmpty A.ModuleName)
        | ClashingDefinition C.QName A.QName
        | ClashingModule A.ModuleName A.ModuleName
        | ClashingImport C.Name A.QName
        | ClashingModuleImport C.Name A.ModuleName
        | PatternShadowsConstructor C.Name A.QName
        | DuplicateImports C.QName [C.ImportedName]
        | InvalidPattern C.Pattern
        | RepeatedVariablesInPattern [C.Name]
        | GeneralizeNotSupportedHere A.QName
        | MultipleFixityDecls [(C.Name, [Fixity'])]
        | MultiplePolarityPragmas [C.Name]
    -- Concrete to Abstract errors
        | NotAModuleExpr C.Expr
            -- ^ The expr was used in the right hand side of an implicit module
            --   definition, but it wasn't of the form @m Delta@.
        | NotAnExpression C.Expr
        | NotAValidLetBinding NiceDeclaration
        | NotValidBeforeField NiceDeclaration
        | NothingAppliedToHiddenArg C.Expr
        | NothingAppliedToInstanceArg C.Expr
    -- Pattern synonym errors
        | BadArgumentsToPatternSynonym A.AmbiguousQName
        | TooFewArgumentsToPatternSynonym A.AmbiguousQName
        | CannotResolveAmbiguousPatternSynonym (NonEmpty (A.QName, A.PatternSynDefn))
        | UnusedVariableInPatternSynonym
    -- Operator errors
        | NoParseForApplication [C.Expr]
        | AmbiguousParseForApplication [C.Expr] [C.Expr]
        | NoParseForLHS LHSOrPatSyn C.Pattern
        | AmbiguousParseForLHS LHSOrPatSyn C.Pattern [C.Pattern]
        | OperatorInformation [NotationSection] TypeError
{- UNUSED
        | NoParseForPatternSynonym C.Pattern
        | AmbiguousParseForPatternSynonym C.Pattern [C.Pattern]
-}
    -- Usage errors
    -- Instance search errors
        | InstanceNoCandidate Type [(Term, TCErr)]
    -- Reflection errors
        | UnquoteFailed UnquoteError
        | DeBruijnIndexOutOfScope Nat Telescope [Name]
    -- Language option errors
        | NeedOptionCopatterns
        | NeedOptionRewriting
        | NeedOptionProp
    -- Failure associated to warnings
        | NonFatalErrors [TCWarning]
    -- Instance search errors
        | InstanceSearchDepthExhausted Term Type Int
        | TriedToCopyConstrainedPrim QName
          deriving Int -> TypeError -> ShowS
[TypeError] -> ShowS
TypeError -> String
(Int -> TypeError -> ShowS)
-> (TypeError -> String)
-> ([TypeError] -> ShowS)
-> Show TypeError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TypeError] -> ShowS
$cshowList :: [TypeError] -> ShowS
show :: TypeError -> String
$cshow :: TypeError -> String
showsPrec :: Int -> TypeError -> ShowS
$cshowsPrec :: Int -> TypeError -> ShowS
Show

-- | Distinguish error message when parsing lhs or pattern synonym, resp.
data LHSOrPatSyn = IsLHS | IsPatSyn deriving (LHSOrPatSyn -> LHSOrPatSyn -> Bool
(LHSOrPatSyn -> LHSOrPatSyn -> Bool)
-> (LHSOrPatSyn -> LHSOrPatSyn -> Bool) -> Eq LHSOrPatSyn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LHSOrPatSyn -> LHSOrPatSyn -> Bool
$c/= :: LHSOrPatSyn -> LHSOrPatSyn -> Bool
== :: LHSOrPatSyn -> LHSOrPatSyn -> Bool
$c== :: LHSOrPatSyn -> LHSOrPatSyn -> Bool
Eq, Int -> LHSOrPatSyn -> ShowS
[LHSOrPatSyn] -> ShowS
LHSOrPatSyn -> String
(Int -> LHSOrPatSyn -> ShowS)
-> (LHSOrPatSyn -> String)
-> ([LHSOrPatSyn] -> ShowS)
-> Show LHSOrPatSyn
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LHSOrPatSyn] -> ShowS
$cshowList :: [LHSOrPatSyn] -> ShowS
show :: LHSOrPatSyn -> String
$cshow :: LHSOrPatSyn -> String
showsPrec :: Int -> LHSOrPatSyn -> ShowS
$cshowsPrec :: Int -> LHSOrPatSyn -> ShowS
Show)

-- | Type-checking errors.

data TCErr
  = TypeError
    { TCErr -> TCState
tcErrState   :: TCState
        -- ^ The state in which the error was raised.
    , TCErr -> Closure TypeError
tcErrClosErr :: Closure TypeError
        -- ^ The environment in which the error as raised plus the error.
    }
  | Exception Range Doc
  | IOException TCState Range E.IOException
    -- ^ The first argument is the state in which the error was
    -- raised.
  | PatternErr
      -- ^ The exception which is usually caught.
      --   Raised for pattern violations during unification ('assignV')
      --   but also in other situations where we want to backtrack.

instance Error TCErr where
  strMsg :: String -> TCErr
strMsg = Range -> Doc -> TCErr
Exception Range
forall a. Range' a
noRange (Doc -> TCErr) -> (String -> Doc) -> String -> TCErr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc
text (String -> Doc) -> ShowS -> String -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
forall a. Error a => String -> a
strMsg

instance Show TCErr where
  show :: TCErr -> String
show (TypeError TCState
_ Closure TypeError
e)     = Range -> String
forall a. Show a => a -> String
show (TCEnv -> Range
envRange (TCEnv -> Range) -> TCEnv -> Range
forall a b. (a -> b) -> a -> b
$ Closure TypeError -> TCEnv
forall a. Closure a -> TCEnv
clEnv Closure TypeError
e) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
": " String -> ShowS
forall a. [a] -> [a] -> [a]
++ TypeError -> String
forall a. Show a => a -> String
show (Closure TypeError -> TypeError
forall a. Closure a -> a
clValue Closure TypeError
e)
  show (Exception Range
r Doc
d)     = Range -> String
forall a. Show a => a -> String
show Range
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
": " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Doc -> String
render Doc
d
  show (IOException TCState
_ Range
r IOException
e) = Range -> String
forall a. Show a => a -> String
show Range
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
": " String -> ShowS
forall a. [a] -> [a] -> [a]
++ IOException -> String
forall a. Show a => a -> String
show IOException
e
  show PatternErr{}        = String
"Pattern violation (you shouldn't see this)"

instance HasRange TCErr where
  getRange :: TCErr -> Range
getRange (TypeError TCState
_ Closure TypeError
cl)    = TCEnv -> Range
envRange (TCEnv -> Range) -> TCEnv -> Range
forall a b. (a -> b) -> a -> b
$ Closure TypeError -> TCEnv
forall a. Closure a -> TCEnv
clEnv Closure TypeError
cl
  getRange (Exception Range
r Doc
_)     = Range
r
  getRange (IOException TCState
s Range
r IOException
_) = Range
r
  getRange PatternErr{}        = Range
forall a. Range' a
noRange

instance E.Exception TCErr

-----------------------------------------------------------------------------
-- * Accessing options
-----------------------------------------------------------------------------

class (Functor m, Applicative m, Monad m) => HasOptions m where
  -- | Returns the pragma options which are currently in effect.
  pragmaOptions      :: m PragmaOptions
  -- | Returns the command line options which are currently in effect.
  commandLineOptions :: m CommandLineOptions

  default pragmaOptions :: (HasOptions n, MonadTrans t, m ~ t n) => m PragmaOptions
  pragmaOptions      = n PragmaOptions -> t n PragmaOptions
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift n PragmaOptions
forall (m :: * -> *). HasOptions m => m PragmaOptions
pragmaOptions

  default commandLineOptions :: (HasOptions n, MonadTrans t, m ~ t n) => m CommandLineOptions
  commandLineOptions = n CommandLineOptions -> t n CommandLineOptions
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift n CommandLineOptions
forall (m :: * -> *). HasOptions m => m CommandLineOptions
commandLineOptions

instance MonadIO m => HasOptions (TCMT m) where
  pragmaOptions :: TCMT m PragmaOptions
pragmaOptions = Lens' PragmaOptions TCState -> TCMT m PragmaOptions
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useTC Lens' PragmaOptions TCState
stPragmaOptions

  commandLineOptions :: TCMT m CommandLineOptions
commandLineOptions = do
    PragmaOptions
p  <- Lens' PragmaOptions TCState -> TCMT m PragmaOptions
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useTC Lens' PragmaOptions TCState
stPragmaOptions
    CommandLineOptions
cl <- PersistentTCState -> CommandLineOptions
stPersistentOptions (PersistentTCState -> CommandLineOptions)
-> (TCState -> PersistentTCState) -> TCState -> CommandLineOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> PersistentTCState
stPersistentState (TCState -> CommandLineOptions)
-> TCMT m TCState -> TCMT m CommandLineOptions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TCMT m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
    CommandLineOptions -> TCMT m CommandLineOptions
forall (m :: * -> *) a. Monad m => a -> m a
return (CommandLineOptions -> TCMT m CommandLineOptions)
-> CommandLineOptions -> TCMT m CommandLineOptions
forall a b. (a -> b) -> a -> b
$ CommandLineOptions
cl { optPragmaOptions :: PragmaOptions
optPragmaOptions = PragmaOptions
p }

-- HasOptions lifts through monad transformers
-- (see default signatures in the HasOptions class).

instance HasOptions m => HasOptions (ChangeT m)
instance HasOptions m => HasOptions (ExceptT e m)
instance HasOptions m => HasOptions (IdentityT m)
instance HasOptions m => HasOptions (ListT m)
instance HasOptions m => HasOptions (MaybeT m)
instance HasOptions m => HasOptions (ReaderT r m)
instance HasOptions m => HasOptions (StateT s m)
instance (HasOptions m, Monoid w) => HasOptions (WriterT w m)

-- Ternary options are annoying to deal with so we provide auxiliary
-- definitions using @collapseDefault@.

sizedTypesOption :: HasOptions m => m Bool
sizedTypesOption :: m Bool
sizedTypesOption = WithDefault 'True -> Bool
forall (b :: Bool). KnownBool b => WithDefault b -> Bool
collapseDefault (WithDefault 'True -> Bool)
-> (PragmaOptions -> WithDefault 'True) -> PragmaOptions -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PragmaOptions -> WithDefault 'True
optSizedTypes (PragmaOptions -> Bool) -> m PragmaOptions -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m PragmaOptions
forall (m :: * -> *). HasOptions m => m PragmaOptions
pragmaOptions

guardednessOption :: HasOptions m => m Bool
guardednessOption :: m Bool
guardednessOption = WithDefault 'True -> Bool
forall (b :: Bool). KnownBool b => WithDefault b -> Bool
collapseDefault (WithDefault 'True -> Bool)
-> (PragmaOptions -> WithDefault 'True) -> PragmaOptions -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PragmaOptions -> WithDefault 'True
optGuardedness (PragmaOptions -> Bool) -> m PragmaOptions -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m PragmaOptions
forall (m :: * -> *). HasOptions m => m PragmaOptions
pragmaOptions

withoutKOption :: HasOptions m => m Bool
withoutKOption :: m Bool
withoutKOption = WithDefault 'False -> Bool
forall (b :: Bool). KnownBool b => WithDefault b -> Bool
collapseDefault (WithDefault 'False -> Bool)
-> (PragmaOptions -> WithDefault 'False) -> PragmaOptions -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PragmaOptions -> WithDefault 'False
optWithoutK (PragmaOptions -> Bool) -> m PragmaOptions -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m PragmaOptions
forall (m :: * -> *). HasOptions m => m PragmaOptions
pragmaOptions

-- | Gets the include directories.
--
-- Precondition: 'optAbsoluteIncludePaths' must be nonempty (i.e.
-- 'setCommandLineOptions' must have run).

getIncludeDirs :: HasOptions m => m [AbsolutePath]
getIncludeDirs :: m [AbsolutePath]
getIncludeDirs = do
  [AbsolutePath]
incs <- CommandLineOptions -> [AbsolutePath]
optAbsoluteIncludePaths (CommandLineOptions -> [AbsolutePath])
-> m CommandLineOptions -> m [AbsolutePath]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m CommandLineOptions
forall (m :: * -> *). HasOptions m => m CommandLineOptions
commandLineOptions
  case [AbsolutePath]
incs of
    [] -> m [AbsolutePath]
forall a. HasCallStack => a
__IMPOSSIBLE__
    [AbsolutePath]
_  -> [AbsolutePath] -> m [AbsolutePath]
forall (m :: * -> *) a. Monad m => a -> m a
return [AbsolutePath]
incs

enableCaching :: HasOptions m => m Bool
enableCaching :: m Bool
enableCaching = PragmaOptions -> Bool
optCaching (PragmaOptions -> Bool) -> m PragmaOptions -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m PragmaOptions
forall (m :: * -> *). HasOptions m => m PragmaOptions
pragmaOptions
-----------------------------------------------------------------------------
-- * The reduce monad
-----------------------------------------------------------------------------

-- | Environment of the reduce monad.
data ReduceEnv = ReduceEnv
  { ReduceEnv -> TCEnv
redEnv :: TCEnv    -- ^ Read only access to environment.
  , ReduceEnv -> TCState
redSt  :: TCState  -- ^ Read only access to state (signature, metas...).
  }

mapRedEnv :: (TCEnv -> TCEnv) -> ReduceEnv -> ReduceEnv
mapRedEnv :: (TCEnv -> TCEnv) -> ReduceEnv -> ReduceEnv
mapRedEnv TCEnv -> TCEnv
f ReduceEnv
s = ReduceEnv
s { redEnv :: TCEnv
redEnv = TCEnv -> TCEnv
f (ReduceEnv -> TCEnv
redEnv ReduceEnv
s) }

mapRedSt :: (TCState -> TCState) -> ReduceEnv -> ReduceEnv
mapRedSt :: (TCState -> TCState) -> ReduceEnv -> ReduceEnv
mapRedSt TCState -> TCState
f ReduceEnv
s = ReduceEnv
s { redSt :: TCState
redSt = TCState -> TCState
f (ReduceEnv -> TCState
redSt ReduceEnv
s) }

mapRedEnvSt :: (TCEnv -> TCEnv) -> (TCState -> TCState) -> ReduceEnv
            -> ReduceEnv
mapRedEnvSt :: (TCEnv -> TCEnv) -> (TCState -> TCState) -> ReduceEnv -> ReduceEnv
mapRedEnvSt TCEnv -> TCEnv
f TCState -> TCState
g (ReduceEnv TCEnv
e TCState
s) = TCEnv -> TCState -> ReduceEnv
ReduceEnv (TCEnv -> TCEnv
f TCEnv
e) (TCState -> TCState
g TCState
s)

-- Lenses
reduceEnv :: Lens' TCEnv ReduceEnv
reduceEnv :: (TCEnv -> f TCEnv) -> ReduceEnv -> f ReduceEnv
reduceEnv TCEnv -> f TCEnv
f ReduceEnv
s = TCEnv -> f TCEnv
f (ReduceEnv -> TCEnv
redEnv ReduceEnv
s) f TCEnv -> (TCEnv -> ReduceEnv) -> f ReduceEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ TCEnv
e -> ReduceEnv
s { redEnv :: TCEnv
redEnv = TCEnv
e }

reduceSt :: Lens' TCState ReduceEnv
reduceSt :: (TCState -> f TCState) -> ReduceEnv -> f ReduceEnv
reduceSt TCState -> f TCState
f ReduceEnv
s = TCState -> f TCState
f (ReduceEnv -> TCState
redSt ReduceEnv
s) f TCState -> (TCState -> ReduceEnv) -> f ReduceEnv
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ TCState
e -> ReduceEnv
s { redSt :: TCState
redSt = TCState
e }

newtype ReduceM a = ReduceM { ReduceM a -> ReduceEnv -> a
unReduceM :: ReduceEnv -> a }
--  deriving (Functor, Applicative, Monad)

onReduceEnv :: (ReduceEnv -> ReduceEnv) -> ReduceM a -> ReduceM a
onReduceEnv :: (ReduceEnv -> ReduceEnv) -> ReduceM a -> ReduceM a
onReduceEnv ReduceEnv -> ReduceEnv
f (ReduceM ReduceEnv -> a
m) = (ReduceEnv -> a) -> ReduceM a
forall a. (ReduceEnv -> a) -> ReduceM a
ReduceM (ReduceEnv -> a
m (ReduceEnv -> a) -> (ReduceEnv -> ReduceEnv) -> ReduceEnv -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReduceEnv -> ReduceEnv
f)

fmapReduce :: (a -> b) -> ReduceM a -> ReduceM b
fmapReduce :: (a -> b) -> ReduceM a -> ReduceM b
fmapReduce a -> b
f (ReduceM ReduceEnv -> a
m) = (ReduceEnv -> b) -> ReduceM b
forall a. (ReduceEnv -> a) -> ReduceM a
ReduceM ((ReduceEnv -> b) -> ReduceM b) -> (ReduceEnv -> b) -> ReduceM b
forall a b. (a -> b) -> a -> b
$ \ ReduceEnv
e -> a -> b
f (a -> b) -> a -> b
forall a b. (a -> b) -> a -> b
$! ReduceEnv -> a
m ReduceEnv
e
{-# INLINE fmapReduce #-}

apReduce :: ReduceM (a -> b) -> ReduceM a -> ReduceM b
apReduce :: ReduceM (a -> b) -> ReduceM a -> ReduceM b
apReduce (ReduceM ReduceEnv -> a -> b
f) (ReduceM ReduceEnv -> a
x) = (ReduceEnv -> b) -> ReduceM b
forall a. (ReduceEnv -> a) -> ReduceM a
ReduceM ((ReduceEnv -> b) -> ReduceM b) -> (ReduceEnv -> b) -> ReduceM b
forall a b. (a -> b) -> a -> b
$ \ ReduceEnv
e -> ReduceEnv -> a -> b
f ReduceEnv
e (a -> b) -> a -> b
forall a b. (a -> b) -> a -> b
$! ReduceEnv -> a
x ReduceEnv
e
{-# INLINE apReduce #-}

bindReduce :: ReduceM a -> (a -> ReduceM b) -> ReduceM b
bindReduce :: ReduceM a -> (a -> ReduceM b) -> ReduceM b
bindReduce (ReduceM ReduceEnv -> a
m) a -> ReduceM b
f = (ReduceEnv -> b) -> ReduceM b
forall a. (ReduceEnv -> a) -> ReduceM a
ReduceM ((ReduceEnv -> b) -> ReduceM b) -> (ReduceEnv -> b) -> ReduceM b
forall a b. (a -> b) -> a -> b
$ \ ReduceEnv
e -> ReduceM b -> ReduceEnv -> b
forall a. ReduceM a -> ReduceEnv -> a
unReduceM (a -> ReduceM b
f (a -> ReduceM b) -> a -> ReduceM b
forall a b. (a -> b) -> a -> b
$! ReduceEnv -> a
m ReduceEnv
e) ReduceEnv
e
{-# INLINE bindReduce #-}

instance Functor ReduceM where
  fmap :: (a -> b) -> ReduceM a -> ReduceM b
fmap = (a -> b) -> ReduceM a -> ReduceM b
forall a b. (a -> b) -> ReduceM a -> ReduceM b
fmapReduce

instance Applicative ReduceM where
  pure :: a -> ReduceM a
pure a
x = (ReduceEnv -> a) -> ReduceM a
forall a. (ReduceEnv -> a) -> ReduceM a
ReduceM (a -> ReduceEnv -> a
forall a b. a -> b -> a
const a
x)
  <*> :: ReduceM (a -> b) -> ReduceM a -> ReduceM b
(<*>) = ReduceM (a -> b) -> ReduceM a -> ReduceM b
forall a b. ReduceM (a -> b) -> ReduceM a -> ReduceM b
apReduce

instance Monad ReduceM where
  return :: a -> ReduceM a
return = a -> ReduceM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
  >>= :: ReduceM a -> (a -> ReduceM b) -> ReduceM b
(>>=) = ReduceM a -> (a -> ReduceM b) -> ReduceM b
forall a b. ReduceM a -> (a -> ReduceM b) -> ReduceM b
bindReduce
  >> :: ReduceM a -> ReduceM b -> ReduceM b
(>>) = ReduceM a -> ReduceM b -> ReduceM b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
#if __GLASGOW_HASKELL__ < 808
  fail = Fail.fail
#endif

instance Fail.MonadFail ReduceM where
  fail :: String -> ReduceM a
fail = String -> ReduceM a
forall a. HasCallStack => String -> a
error

instance ReadTCState ReduceM where
  getTCState :: ReduceM TCState
getTCState = (ReduceEnv -> TCState) -> ReduceM TCState
forall a. (ReduceEnv -> a) -> ReduceM a
ReduceM ReduceEnv -> TCState
redSt
  locallyTCState :: Lens' a TCState -> (a -> a) -> ReduceM b -> ReduceM b
locallyTCState Lens' a TCState
l a -> a
f = (ReduceEnv -> ReduceEnv) -> ReduceM b -> ReduceM b
forall a. (ReduceEnv -> ReduceEnv) -> ReduceM a -> ReduceM a
onReduceEnv ((ReduceEnv -> ReduceEnv) -> ReduceM b -> ReduceM b)
-> (ReduceEnv -> ReduceEnv) -> ReduceM b -> ReduceM b
forall a b. (a -> b) -> a -> b
$ (TCState -> TCState) -> ReduceEnv -> ReduceEnv
mapRedSt ((TCState -> TCState) -> ReduceEnv -> ReduceEnv)
-> (TCState -> TCState) -> ReduceEnv -> ReduceEnv
forall a b. (a -> b) -> a -> b
$ Lens' a TCState -> LensMap a TCState
forall i o. Lens' i o -> LensMap i o
over Lens' a TCState
l a -> a
f

runReduceM :: ReduceM a -> TCM a
runReduceM :: ReduceM a -> TCM a
runReduceM ReduceM a
m = do
  TCEnv
e <- TCMT IO TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  TCState
s <- TCMT IO TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  a -> TCM a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> TCM a) -> a -> TCM a
forall a b. (a -> b) -> a -> b
$! ReduceM a -> ReduceEnv -> a
forall a. ReduceM a -> ReduceEnv -> a
unReduceM ReduceM a
m (TCEnv -> TCState -> ReduceEnv
ReduceEnv TCEnv
e TCState
s)

runReduceF :: (a -> ReduceM b) -> TCM (a -> b)
runReduceF :: (a -> ReduceM b) -> TCM (a -> b)
runReduceF a -> ReduceM b
f = do
  TCEnv
e <- TCMT IO TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  TCState
s <- TCMT IO TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  (a -> b) -> TCM (a -> b)
forall (m :: * -> *) a. Monad m => a -> m a
return ((a -> b) -> TCM (a -> b)) -> (a -> b) -> TCM (a -> b)
forall a b. (a -> b) -> a -> b
$ \a
x -> ReduceM b -> ReduceEnv -> b
forall a. ReduceM a -> ReduceEnv -> a
unReduceM (a -> ReduceM b
f a
x) (TCEnv -> TCState -> ReduceEnv
ReduceEnv TCEnv
e TCState
s)

instance MonadTCEnv ReduceM where
  askTC :: ReduceM TCEnv
askTC   = (ReduceEnv -> TCEnv) -> ReduceM TCEnv
forall a. (ReduceEnv -> a) -> ReduceM a
ReduceM ReduceEnv -> TCEnv
redEnv
  localTC :: (TCEnv -> TCEnv) -> ReduceM a -> ReduceM a
localTC = (ReduceEnv -> ReduceEnv) -> ReduceM a -> ReduceM a
forall a. (ReduceEnv -> ReduceEnv) -> ReduceM a -> ReduceM a
onReduceEnv ((ReduceEnv -> ReduceEnv) -> ReduceM a -> ReduceM a)
-> ((TCEnv -> TCEnv) -> ReduceEnv -> ReduceEnv)
-> (TCEnv -> TCEnv)
-> ReduceM a
-> ReduceM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCEnv -> TCEnv) -> ReduceEnv -> ReduceEnv
mapRedEnv

-- Andrea comments (https://github.com/agda/agda/issues/1829#issuecomment-522312084):
--
--   useR forces the result of projecting the lens,
--   this usually prevents retaining the whole structure when we only need a field.
--
-- This fixes (or contributes to the fix of) the space leak issue #1829 (caching).
useR :: (ReadTCState m) => Lens' a TCState -> m a
useR :: Lens' a TCState -> m a
useR Lens' a TCState
l = do
  !a
x <- (TCState -> Lens' a TCState -> a
forall o i. o -> Lens' i o -> i
^.Lens' a TCState
l) (TCState -> a) -> m TCState -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState
  a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x

askR :: ReduceM ReduceEnv
askR :: ReduceM ReduceEnv
askR = (ReduceEnv -> ReduceEnv) -> ReduceM ReduceEnv
forall a. (ReduceEnv -> a) -> ReduceM a
ReduceM ReduceEnv -> ReduceEnv
forall r (m :: * -> *). MonadReader r m => m r
ask

localR :: (ReduceEnv -> ReduceEnv) -> ReduceM a -> ReduceM a
localR :: (ReduceEnv -> ReduceEnv) -> ReduceM a -> ReduceM a
localR ReduceEnv -> ReduceEnv
f = (ReduceEnv -> a) -> ReduceM a
forall a. (ReduceEnv -> a) -> ReduceM a
ReduceM ((ReduceEnv -> a) -> ReduceM a)
-> (ReduceM a -> ReduceEnv -> a) -> ReduceM a -> ReduceM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ReduceEnv -> ReduceEnv) -> (ReduceEnv -> a) -> ReduceEnv -> a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local ReduceEnv -> ReduceEnv
f ((ReduceEnv -> a) -> ReduceEnv -> a)
-> (ReduceM a -> ReduceEnv -> a) -> ReduceM a -> ReduceEnv -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReduceM a -> ReduceEnv -> a
forall a. ReduceM a -> ReduceEnv -> a
unReduceM

instance HasOptions ReduceM where
  pragmaOptions :: ReduceM PragmaOptions
pragmaOptions      = Lens' PragmaOptions TCState -> ReduceM PragmaOptions
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' PragmaOptions TCState
stPragmaOptions
  commandLineOptions :: ReduceM CommandLineOptions
commandLineOptions = do
    PragmaOptions
p  <- Lens' PragmaOptions TCState -> ReduceM PragmaOptions
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useR Lens' PragmaOptions TCState
stPragmaOptions
    CommandLineOptions
cl <- PersistentTCState -> CommandLineOptions
stPersistentOptions (PersistentTCState -> CommandLineOptions)
-> (TCState -> PersistentTCState) -> TCState -> CommandLineOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> PersistentTCState
stPersistentState (TCState -> CommandLineOptions)
-> ReduceM TCState -> ReduceM CommandLineOptions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReduceM TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState
    CommandLineOptions -> ReduceM CommandLineOptions
forall (m :: * -> *) a. Monad m => a -> m a
return (CommandLineOptions -> ReduceM CommandLineOptions)
-> CommandLineOptions -> ReduceM CommandLineOptions
forall a b. (a -> b) -> a -> b
$ CommandLineOptions
cl{ optPragmaOptions :: PragmaOptions
optPragmaOptions = PragmaOptions
p }

class ( Applicative m
      , MonadTCEnv m
      , ReadTCState m
      , HasOptions m
      ) => MonadReduce m where
  liftReduce :: ReduceM a -> m a

instance MonadReduce m => MonadReduce (MaybeT m) where
  liftReduce :: ReduceM a -> MaybeT m a
liftReduce = m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> MaybeT m a)
-> (ReduceM a -> m a) -> ReduceM a -> MaybeT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReduceM a -> m a
forall (m :: * -> *) a. MonadReduce m => ReduceM a -> m a
liftReduce

instance MonadReduce m => MonadReduce (ListT m) where
  liftReduce :: ReduceM a -> ListT m a
liftReduce = m a -> ListT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ListT m a) -> (ReduceM a -> m a) -> ReduceM a -> ListT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReduceM a -> m a
forall (m :: * -> *) a. MonadReduce m => ReduceM a -> m a
liftReduce

instance MonadReduce m => MonadReduce (ExceptT err m) where
  liftReduce :: ReduceM a -> ExceptT err m a
liftReduce = m a -> ExceptT err m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ExceptT err m a)
-> (ReduceM a -> m a) -> ReduceM a -> ExceptT err m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReduceM a -> m a
forall (m :: * -> *) a. MonadReduce m => ReduceM a -> m a
liftReduce

instance MonadReduce m => MonadReduce (ReaderT r m) where
  liftReduce :: ReduceM a -> ReaderT r m a
liftReduce = m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ReaderT r m a)
-> (ReduceM a -> m a) -> ReduceM a -> ReaderT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReduceM a -> m a
forall (m :: * -> *) a. MonadReduce m => ReduceM a -> m a
liftReduce

instance (Monoid w, MonadReduce m) => MonadReduce (WriterT w m) where
  liftReduce :: ReduceM a -> WriterT w m a
liftReduce = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a)
-> (ReduceM a -> m a) -> ReduceM a -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReduceM a -> m a
forall (m :: * -> *) a. MonadReduce m => ReduceM a -> m a
liftReduce

instance MonadReduce m => MonadReduce (StateT w m) where
  liftReduce :: ReduceM a -> StateT w m a
liftReduce = m a -> StateT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT w m a)
-> (ReduceM a -> m a) -> ReduceM a -> StateT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReduceM a -> m a
forall (m :: * -> *) a. MonadReduce m => ReduceM a -> m a
liftReduce

instance MonadReduce ReduceM where
  liftReduce :: ReduceM a -> ReduceM a
liftReduce = ReduceM a -> ReduceM a
forall a. a -> a
id

---------------------------------------------------------------------------
-- * Monad with read-only 'TCEnv'
---------------------------------------------------------------------------

-- | @MonadTCEnv@ made into its own dedicated service class.
--   This allows us to use 'MonadReader' for 'ReaderT' extensions of @TCM@.
class Monad m => MonadTCEnv m where
  askTC   :: m TCEnv
  localTC :: (TCEnv -> TCEnv) -> m a -> m a

instance MonadTCEnv m => MonadTCEnv (MaybeT m) where
  askTC :: MaybeT m TCEnv
askTC   = m TCEnv -> MaybeT m TCEnv
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  localTC :: (TCEnv -> TCEnv) -> MaybeT m a -> MaybeT m a
localTC = (m (Maybe a) -> m (Maybe a)) -> MaybeT m a -> MaybeT m a
forall (m :: * -> *) a (n :: * -> *) b.
(m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b
mapMaybeT ((m (Maybe a) -> m (Maybe a)) -> MaybeT m a -> MaybeT m a)
-> ((TCEnv -> TCEnv) -> m (Maybe a) -> m (Maybe a))
-> (TCEnv -> TCEnv)
-> MaybeT m a
-> MaybeT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCEnv -> TCEnv) -> m (Maybe a) -> m (Maybe a)
forall (m :: * -> *) a.
MonadTCEnv m =>
(TCEnv -> TCEnv) -> m a -> m a
localTC

instance MonadTCEnv m => MonadTCEnv (ListT m) where
  askTC :: ListT m TCEnv
askTC   = m TCEnv -> ListT m TCEnv
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  localTC :: (TCEnv -> TCEnv) -> ListT m a -> ListT m a
localTC = (m (Maybe (a, ListT m a)) -> m (Maybe (a, ListT m a)))
-> ListT m a -> ListT m a
forall (m :: * -> *) a (n :: * -> *) b.
(m (Maybe (a, ListT m a)) -> n (Maybe (b, ListT n b)))
-> ListT m a -> ListT n b
mapListT ((m (Maybe (a, ListT m a)) -> m (Maybe (a, ListT m a)))
 -> ListT m a -> ListT m a)
-> ((TCEnv -> TCEnv)
    -> m (Maybe (a, ListT m a)) -> m (Maybe (a, ListT m a)))
-> (TCEnv -> TCEnv)
-> ListT m a
-> ListT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCEnv -> TCEnv)
-> m (Maybe (a, ListT m a)) -> m (Maybe (a, ListT m a))
forall (m :: * -> *) a.
MonadTCEnv m =>
(TCEnv -> TCEnv) -> m a -> m a
localTC

instance MonadTCEnv m => MonadTCEnv (ExceptT err m) where
  askTC :: ExceptT err m TCEnv
askTC   = m TCEnv -> ExceptT err m TCEnv
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  localTC :: (TCEnv -> TCEnv) -> ExceptT err m a -> ExceptT err m a
localTC = (m (Either err a) -> m (Either err a))
-> ExceptT err m a -> ExceptT err m a
forall (m :: * -> *) e a (n :: * -> *) e' b.
(m (Either e a) -> n (Either e' b))
-> ExceptT e m a -> ExceptT e' n b
mapExceptT ((m (Either err a) -> m (Either err a))
 -> ExceptT err m a -> ExceptT err m a)
-> ((TCEnv -> TCEnv) -> m (Either err a) -> m (Either err a))
-> (TCEnv -> TCEnv)
-> ExceptT err m a
-> ExceptT err m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCEnv -> TCEnv) -> m (Either err a) -> m (Either err a)
forall (m :: * -> *) a.
MonadTCEnv m =>
(TCEnv -> TCEnv) -> m a -> m a
localTC

instance MonadTCEnv m => MonadTCEnv (ReaderT r m) where
  askTC :: ReaderT r m TCEnv
askTC   = m TCEnv -> ReaderT r m TCEnv
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  localTC :: (TCEnv -> TCEnv) -> ReaderT r m a -> ReaderT r m a
localTC = (m a -> m a) -> ReaderT r m a -> ReaderT r m a
forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT ((m a -> m a) -> ReaderT r m a -> ReaderT r m a)
-> ((TCEnv -> TCEnv) -> m a -> m a)
-> (TCEnv -> TCEnv)
-> ReaderT r m a
-> ReaderT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCEnv -> TCEnv) -> m a -> m a
forall (m :: * -> *) a.
MonadTCEnv m =>
(TCEnv -> TCEnv) -> m a -> m a
localTC

instance (Monoid w, MonadTCEnv m) => MonadTCEnv (WriterT w m) where
  askTC :: WriterT w m TCEnv
askTC   = m TCEnv -> WriterT w m TCEnv
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  localTC :: (TCEnv -> TCEnv) -> WriterT w m a -> WriterT w m a
localTC = (m (a, w) -> m (a, w)) -> WriterT w m a -> WriterT w m a
forall (m :: * -> *) a w (n :: * -> *) b w'.
(m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
mapWriterT ((m (a, w) -> m (a, w)) -> WriterT w m a -> WriterT w m a)
-> ((TCEnv -> TCEnv) -> m (a, w) -> m (a, w))
-> (TCEnv -> TCEnv)
-> WriterT w m a
-> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCEnv -> TCEnv) -> m (a, w) -> m (a, w)
forall (m :: * -> *) a.
MonadTCEnv m =>
(TCEnv -> TCEnv) -> m a -> m a
localTC

instance MonadTCEnv m => MonadTCEnv (StateT s m) where
  askTC :: StateT s m TCEnv
askTC   = m TCEnv -> StateT s m TCEnv
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  localTC :: (TCEnv -> TCEnv) -> StateT s m a -> StateT s m a
localTC = (m (a, s) -> m (a, s)) -> StateT s m a -> StateT s m a
forall (m :: * -> *) a s (n :: * -> *) b.
(m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
mapStateT ((m (a, s) -> m (a, s)) -> StateT s m a -> StateT s m a)
-> ((TCEnv -> TCEnv) -> m (a, s) -> m (a, s))
-> (TCEnv -> TCEnv)
-> StateT s m a
-> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCEnv -> TCEnv) -> m (a, s) -> m (a, s)
forall (m :: * -> *) a.
MonadTCEnv m =>
(TCEnv -> TCEnv) -> m a -> m a
localTC

instance MonadTCEnv m => MonadTCEnv (ChangeT m) where
  askTC :: ChangeT m TCEnv
askTC   = m TCEnv -> ChangeT m TCEnv
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  localTC :: (TCEnv -> TCEnv) -> ChangeT m a -> ChangeT m a
localTC = (m (a, Any) -> m (a, Any)) -> ChangeT m a -> ChangeT m a
forall (m :: * -> *) a (n :: * -> *) b.
(m (a, Any) -> n (b, Any)) -> ChangeT m a -> ChangeT n b
mapChangeT ((m (a, Any) -> m (a, Any)) -> ChangeT m a -> ChangeT m a)
-> ((TCEnv -> TCEnv) -> m (a, Any) -> m (a, Any))
-> (TCEnv -> TCEnv)
-> ChangeT m a
-> ChangeT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCEnv -> TCEnv) -> m (a, Any) -> m (a, Any)
forall (m :: * -> *) a.
MonadTCEnv m =>
(TCEnv -> TCEnv) -> m a -> m a
localTC

instance MonadTCEnv m => MonadTCEnv (IdentityT m) where
  askTC :: IdentityT m TCEnv
askTC   = m TCEnv -> IdentityT m TCEnv
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  localTC :: (TCEnv -> TCEnv) -> IdentityT m a -> IdentityT m a
localTC = (m a -> m a) -> IdentityT m a -> IdentityT m a
forall k1 k2 (m :: k1 -> *) (a :: k1) (n :: k2 -> *) (b :: k2).
(m a -> n b) -> IdentityT m a -> IdentityT n b
mapIdentityT ((m a -> m a) -> IdentityT m a -> IdentityT m a)
-> ((TCEnv -> TCEnv) -> m a -> m a)
-> (TCEnv -> TCEnv)
-> IdentityT m a
-> IdentityT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCEnv -> TCEnv) -> m a -> m a
forall (m :: * -> *) a.
MonadTCEnv m =>
(TCEnv -> TCEnv) -> m a -> m a
localTC

asksTC :: MonadTCEnv m => (TCEnv -> a) -> m a
asksTC :: (TCEnv -> a) -> m a
asksTC TCEnv -> a
f = TCEnv -> a
f (TCEnv -> a) -> m TCEnv -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC

viewTC :: MonadTCEnv m => Lens' a TCEnv -> m a
viewTC :: Lens' a TCEnv -> m a
viewTC Lens' a TCEnv
l = (TCEnv -> a) -> m a
forall (m :: * -> *) a. MonadTCEnv m => (TCEnv -> a) -> m a
asksTC (TCEnv -> Lens' a TCEnv -> a
forall o i. o -> Lens' i o -> i
^. Lens' a TCEnv
l)

-- | Modify the lens-indicated part of the @TCEnv@ in a subcomputation.
locallyTC :: MonadTCEnv m => Lens' a TCEnv -> (a -> a) -> m b -> m b
locallyTC :: Lens' a TCEnv -> (a -> a) -> m b -> m b
locallyTC Lens' a TCEnv
l = (TCEnv -> TCEnv) -> m b -> m b
forall (m :: * -> *) a.
MonadTCEnv m =>
(TCEnv -> TCEnv) -> m a -> m a
localTC ((TCEnv -> TCEnv) -> m b -> m b)
-> ((a -> a) -> TCEnv -> TCEnv) -> (a -> a) -> m b -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' a TCEnv -> (a -> a) -> TCEnv -> TCEnv
forall i o. Lens' i o -> LensMap i o
over Lens' a TCEnv
l

---------------------------------------------------------------------------
-- * Monad with mutable 'TCState'
---------------------------------------------------------------------------

-- | @MonadTCState@ made into its own dedicated service class.
--   This allows us to use 'MonadState' for 'StateT' extensions of @TCM@.
class Monad m => MonadTCState m where
  getTC :: m TCState
  putTC :: TCState -> m ()
  modifyTC :: (TCState -> TCState) -> m ()

  {-# MINIMAL getTC, (putTC | modifyTC) #-}
  putTC      = (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC ((TCState -> TCState) -> m ())
-> (TCState -> TCState -> TCState) -> TCState -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> TCState -> TCState
forall a b. a -> b -> a
const
  modifyTC TCState -> TCState
f = TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC (TCState -> m ()) -> (TCState -> TCState) -> TCState -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> TCState
f (TCState -> m ()) -> m TCState -> m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC

instance MonadTCState m => MonadTCState (MaybeT m) where
  getTC :: MaybeT m TCState
getTC    = m TCState -> MaybeT m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  putTC :: TCState -> MaybeT m ()
putTC    = m () -> MaybeT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MaybeT m ())
-> (TCState -> m ()) -> TCState -> MaybeT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC
  modifyTC :: (TCState -> TCState) -> MaybeT m ()
modifyTC = m () -> MaybeT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MaybeT m ())
-> ((TCState -> TCState) -> m ())
-> (TCState -> TCState)
-> MaybeT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC

instance MonadTCState m => MonadTCState (ListT m) where
  getTC :: ListT m TCState
getTC    = m TCState -> ListT m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  putTC :: TCState -> ListT m ()
putTC    = m () -> ListT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ListT m ()) -> (TCState -> m ()) -> TCState -> ListT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC
  modifyTC :: (TCState -> TCState) -> ListT m ()
modifyTC = m () -> ListT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ListT m ())
-> ((TCState -> TCState) -> m ())
-> (TCState -> TCState)
-> ListT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC

instance MonadTCState m => MonadTCState (ExceptT err m) where
  getTC :: ExceptT err m TCState
getTC    = m TCState -> ExceptT err m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  putTC :: TCState -> ExceptT err m ()
putTC    = m () -> ExceptT err m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT err m ())
-> (TCState -> m ()) -> TCState -> ExceptT err m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC
  modifyTC :: (TCState -> TCState) -> ExceptT err m ()
modifyTC = m () -> ExceptT err m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT err m ())
-> ((TCState -> TCState) -> m ())
-> (TCState -> TCState)
-> ExceptT err m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC

instance MonadTCState m => MonadTCState (ReaderT r m) where
  getTC :: ReaderT r m TCState
getTC    = m TCState -> ReaderT r m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  putTC :: TCState -> ReaderT r m ()
putTC    = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ())
-> (TCState -> m ()) -> TCState -> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC
  modifyTC :: (TCState -> TCState) -> ReaderT r m ()
modifyTC = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ())
-> ((TCState -> TCState) -> m ())
-> (TCState -> TCState)
-> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC

instance (Monoid w, MonadTCState m) => MonadTCState (WriterT w m) where
  getTC :: WriterT w m TCState
getTC    = m TCState -> WriterT w m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  putTC :: TCState -> WriterT w m ()
putTC    = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT w m ())
-> (TCState -> m ()) -> TCState -> WriterT w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC
  modifyTC :: (TCState -> TCState) -> WriterT w m ()
modifyTC = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT w m ())
-> ((TCState -> TCState) -> m ())
-> (TCState -> TCState)
-> WriterT w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC

instance MonadTCState m => MonadTCState (StateT s m) where
  getTC :: StateT s m TCState
getTC    = m TCState -> StateT s m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  putTC :: TCState -> StateT s m ()
putTC    = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> (TCState -> m ()) -> TCState -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC
  modifyTC :: (TCState -> TCState) -> StateT s m ()
modifyTC = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> ((TCState -> TCState) -> m ())
-> (TCState -> TCState)
-> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC

instance MonadTCState m => MonadTCState (ChangeT m) where
  getTC :: ChangeT m TCState
getTC    = m TCState -> ChangeT m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  putTC :: TCState -> ChangeT m ()
putTC    = m () -> ChangeT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ChangeT m ())
-> (TCState -> m ()) -> TCState -> ChangeT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC
  modifyTC :: (TCState -> TCState) -> ChangeT m ()
modifyTC = m () -> ChangeT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ChangeT m ())
-> ((TCState -> TCState) -> m ())
-> (TCState -> TCState)
-> ChangeT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC

instance MonadTCState m => MonadTCState (IdentityT m) where
  getTC :: IdentityT m TCState
getTC    = m TCState -> IdentityT m TCState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  putTC :: TCState -> IdentityT m ()
putTC    = m () -> IdentityT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> IdentityT m ())
-> (TCState -> m ()) -> TCState -> IdentityT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC
  modifyTC :: (TCState -> TCState) -> IdentityT m ()
modifyTC = m () -> IdentityT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> IdentityT m ())
-> ((TCState -> TCState) -> m ())
-> (TCState -> TCState)
-> IdentityT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC

-- ** @TCState@ accessors (no lenses)

getsTC :: ReadTCState m => (TCState -> a) -> m a
getsTC :: (TCState -> a) -> m a
getsTC TCState -> a
f = TCState -> a
f (TCState -> a) -> m TCState -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState

-- | A variant of 'modifyTC' in which the computation is strict in the
-- new state.
modifyTC' :: MonadTCState m => (TCState -> TCState) -> m ()
modifyTC' :: (TCState -> TCState) -> m ()
modifyTC' TCState -> TCState
f = do
  TCState
s' <- m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC (TCState -> m ()) -> TCState -> m ()
forall a b. (a -> b) -> a -> b
$! TCState -> TCState
f TCState
s'

-- SEE TC.Monad.State
-- -- | Restore the 'TCState' after computation.
-- localTCState :: MonadTCState m => m a -> m a
-- localTCState = bracket_ getTC putTC

-- ** @TCState@ accessors via lenses

useTC :: ReadTCState m => Lens' a TCState -> m a
useTC :: Lens' a TCState -> m a
useTC Lens' a TCState
l = do
  !a
x <- (TCState -> a) -> m a
forall (m :: * -> *) a. ReadTCState m => (TCState -> a) -> m a
getsTC (TCState -> Lens' a TCState -> a
forall o i. o -> Lens' i o -> i
^. Lens' a TCState
l)
  a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x

infix 4 `setTCLens`

-- | Overwrite the part of the 'TCState' focused on by the lens.
setTCLens :: MonadTCState m => Lens' a TCState -> a -> m ()
setTCLens :: Lens' a TCState -> a -> m ()
setTCLens Lens' a TCState
l = (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC ((TCState -> TCState) -> m ())
-> (a -> TCState -> TCState) -> a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' a TCState -> a -> TCState -> TCState
forall i o. Lens' i o -> LensSet i o
set Lens' a TCState
l

-- | Modify the part of the 'TCState' focused on by the lens.
modifyTCLens :: MonadTCState m => Lens' a TCState -> (a -> a) -> m ()
modifyTCLens :: Lens' a TCState -> (a -> a) -> m ()
modifyTCLens Lens' a TCState
l = (TCState -> TCState) -> m ()
forall (m :: * -> *).
MonadTCState m =>
(TCState -> TCState) -> m ()
modifyTC ((TCState -> TCState) -> m ())
-> ((a -> a) -> TCState -> TCState) -> (a -> a) -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' a TCState -> (a -> a) -> TCState -> TCState
forall i o. Lens' i o -> LensMap i o
over Lens' a TCState
l

-- | Modify a part of the state monadically.
modifyTCLensM :: MonadTCState m => Lens' a TCState -> (a -> m a) -> m ()
modifyTCLensM :: Lens' a TCState -> (a -> m a) -> m ()
modifyTCLensM Lens' a TCState
l a -> m a
f = TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC (TCState -> m ()) -> m TCState -> m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (a -> m a) -> TCState -> m TCState
Lens' a TCState
l a -> m a
f (TCState -> m TCState) -> m TCState -> m TCState
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC

-- | Modify the part of the 'TCState' focused on by the lens, and return some result.
stateTCLens :: MonadTCState m => Lens' a TCState -> (a -> (r , a)) -> m r
stateTCLens :: Lens' a TCState -> (a -> (r, a)) -> m r
stateTCLens Lens' a TCState
l a -> (r, a)
f = Lens' a TCState -> (a -> m (r, a)) -> m r
forall (m :: * -> *) a r.
MonadTCState m =>
Lens' a TCState -> (a -> m (r, a)) -> m r
stateTCLensM Lens' a TCState
l ((a -> m (r, a)) -> m r) -> (a -> m (r, a)) -> m r
forall a b. (a -> b) -> a -> b
$ (r, a) -> m (r, a)
forall (m :: * -> *) a. Monad m => a -> m a
return ((r, a) -> m (r, a)) -> (a -> (r, a)) -> a -> m (r, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> (r, a)
f

-- | Modify a part of the state monadically, and return some result.
stateTCLensM :: MonadTCState m => Lens' a TCState -> (a -> m (r , a)) -> m r
stateTCLensM :: Lens' a TCState -> (a -> m (r, a)) -> m r
stateTCLensM Lens' a TCState
l a -> m (r, a)
f = do
  TCState
s <- m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  (r
result , a
x) <- a -> m (r, a)
f (a -> m (r, a)) -> a -> m (r, a)
forall a b. (a -> b) -> a -> b
$ TCState
s TCState -> Lens' a TCState -> a
forall o i. o -> Lens' i o -> i
^. Lens' a TCState
l
  TCState -> m ()
forall (m :: * -> *). MonadTCState m => TCState -> m ()
putTC (TCState -> m ()) -> TCState -> m ()
forall a b. (a -> b) -> a -> b
$ Lens' a TCState -> LensSet a TCState
forall i o. Lens' i o -> LensSet i o
set Lens' a TCState
l a
x TCState
s
  r -> m r
forall (m :: * -> *) a. Monad m => a -> m a
return r
result

---------------------------------------------------------------------------
-- * Type checking monad transformer
---------------------------------------------------------------------------

-- | The type checking monad transformer.
-- Adds readonly 'TCEnv' and mutable 'TCState'.
newtype TCMT m a = TCM { TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM :: IORef TCState -> TCEnv -> m a }

-- | Type checking monad.
type TCM = TCMT IO

{-# SPECIALIZE INLINE mapTCMT :: (forall a. IO a -> IO a) -> TCM a -> TCM a #-}
mapTCMT :: (forall a. m a -> n a) -> TCMT m a -> TCMT n a
mapTCMT :: (forall a. m a -> n a) -> TCMT m a -> TCMT n a
mapTCMT forall a. m a -> n a
f (TCM IORef TCState -> TCEnv -> m a
m) = (IORef TCState -> TCEnv -> n a) -> TCMT n a
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> n a) -> TCMT n a)
-> (IORef TCState -> TCEnv -> n a) -> TCMT n a
forall a b. (a -> b) -> a -> b
$ \ IORef TCState
s TCEnv
e -> m a -> n a
forall a. m a -> n a
f (IORef TCState -> TCEnv -> m a
m IORef TCState
s TCEnv
e)

pureTCM :: MonadIO m => (TCState -> TCEnv -> a) -> TCMT m a
pureTCM :: (TCState -> TCEnv -> a) -> TCMT m a
pureTCM TCState -> TCEnv -> a
f = (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m a) -> TCMT m a)
-> (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall a b. (a -> b) -> a -> b
$ \ IORef TCState
r TCEnv
e -> do
  TCState
s <- IO TCState -> m TCState
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TCState -> m TCState) -> IO TCState -> m TCState
forall a b. (a -> b) -> a -> b
$ IORef TCState -> IO TCState
forall a. IORef a -> IO a
readIORef IORef TCState
r
  a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (TCState -> TCEnv -> a
f TCState
s TCEnv
e)

-- One goal of the definitions and pragmas below is to inline the
-- monad operations as much as possible. This doesn't seem to have a
-- large effect on the performance of the normal executable, but (at
-- least on one machine/configuration) it has a massive effect on the
-- performance of the profiling executable [1], and reduces the time
-- attributed to bind from over 90% to about 25%.
--
-- [1] When compiled with -auto-all and run with -p: roughly 750%
-- faster for one example.

returnTCMT :: MonadIO m => a -> TCMT m a
returnTCMT :: a -> TCMT m a
returnTCMT = \a
x -> (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m a) -> TCMT m a)
-> (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall a b. (a -> b) -> a -> b
$ \IORef TCState
_ TCEnv
_ -> a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x
{-# INLINE returnTCMT #-}

bindTCMT :: MonadIO m => TCMT m a -> (a -> TCMT m b) -> TCMT m b
bindTCMT :: TCMT m a -> (a -> TCMT m b) -> TCMT m b
bindTCMT = \(TCM IORef TCState -> TCEnv -> m a
m) a -> TCMT m b
k -> (IORef TCState -> TCEnv -> m b) -> TCMT m b
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m b) -> TCMT m b)
-> (IORef TCState -> TCEnv -> m b) -> TCMT m b
forall a b. (a -> b) -> a -> b
$ \IORef TCState
r TCEnv
e -> IORef TCState -> TCEnv -> m a
m IORef TCState
r TCEnv
e m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \a
x -> TCMT m b -> IORef TCState -> TCEnv -> m b
forall (m :: * -> *) a. TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM (a -> TCMT m b
k a
x) IORef TCState
r TCEnv
e
{-# INLINE bindTCMT #-}

thenTCMT :: MonadIO m => TCMT m a -> TCMT m b -> TCMT m b
thenTCMT :: TCMT m a -> TCMT m b -> TCMT m b
thenTCMT = \(TCM IORef TCState -> TCEnv -> m a
m1) (TCM IORef TCState -> TCEnv -> m b
m2) -> (IORef TCState -> TCEnv -> m b) -> TCMT m b
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m b) -> TCMT m b)
-> (IORef TCState -> TCEnv -> m b) -> TCMT m b
forall a b. (a -> b) -> a -> b
$ \IORef TCState
r TCEnv
e -> IORef TCState -> TCEnv -> m a
m1 IORef TCState
r TCEnv
e m a -> m b -> m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> IORef TCState -> TCEnv -> m b
m2 IORef TCState
r TCEnv
e
{-# INLINE thenTCMT #-}

instance MonadIO m => Functor (TCMT m) where
  fmap :: (a -> b) -> TCMT m a -> TCMT m b
fmap = (a -> b) -> TCMT m a -> TCMT m b
forall (m :: * -> *) a b.
MonadIO m =>
(a -> b) -> TCMT m a -> TCMT m b
fmapTCMT

fmapTCMT :: MonadIO m => (a -> b) -> TCMT m a -> TCMT m b
fmapTCMT :: (a -> b) -> TCMT m a -> TCMT m b
fmapTCMT = \a -> b
f (TCM IORef TCState -> TCEnv -> m a
m) -> (IORef TCState -> TCEnv -> m b) -> TCMT m b
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m b) -> TCMT m b)
-> (IORef TCState -> TCEnv -> m b) -> TCMT m b
forall a b. (a -> b) -> a -> b
$ \IORef TCState
r TCEnv
e -> (a -> b) -> m a -> m b
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> b
f (IORef TCState -> TCEnv -> m a
m IORef TCState
r TCEnv
e)
{-# INLINE fmapTCMT #-}

instance MonadIO m => Applicative (TCMT m) where
  pure :: a -> TCMT m a
pure  = a -> TCMT m a
forall (m :: * -> *) a. MonadIO m => a -> TCMT m a
returnTCMT
  <*> :: TCMT m (a -> b) -> TCMT m a -> TCMT m b
(<*>) = TCMT m (a -> b) -> TCMT m a -> TCMT m b
forall (m :: * -> *) a b.
MonadIO m =>
TCMT m (a -> b) -> TCMT m a -> TCMT m b
apTCMT

apTCMT :: MonadIO m => TCMT m (a -> b) -> TCMT m a -> TCMT m b
apTCMT :: TCMT m (a -> b) -> TCMT m a -> TCMT m b
apTCMT = \(TCM IORef TCState -> TCEnv -> m (a -> b)
mf) (TCM IORef TCState -> TCEnv -> m a
m) -> (IORef TCState -> TCEnv -> m b) -> TCMT m b
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m b) -> TCMT m b)
-> (IORef TCState -> TCEnv -> m b) -> TCMT m b
forall a b. (a -> b) -> a -> b
$ \IORef TCState
r TCEnv
e -> m (a -> b) -> m a -> m b
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap (IORef TCState -> TCEnv -> m (a -> b)
mf IORef TCState
r TCEnv
e) (IORef TCState -> TCEnv -> m a
m IORef TCState
r TCEnv
e)
{-# INLINE apTCMT #-}

instance MonadTrans TCMT where
    lift :: m a -> TCMT m a
lift m a
m = (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m a) -> TCMT m a)
-> (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall a b. (a -> b) -> a -> b
$ \IORef TCState
_ TCEnv
_ -> m a
m

-- We want a special monad implementation of fail.
instance MonadIO m => Monad (TCMT m) where
    return :: a -> TCMT m a
return = a -> TCMT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    >>= :: TCMT m a -> (a -> TCMT m b) -> TCMT m b
(>>=)  = TCMT m a -> (a -> TCMT m b) -> TCMT m b
forall (m :: * -> *) a b.
MonadIO m =>
TCMT m a -> (a -> TCMT m b) -> TCMT m b
bindTCMT
    >> :: TCMT m a -> TCMT m b -> TCMT m b
(>>)   = TCMT m a -> TCMT m b -> TCMT m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
#if __GLASGOW_HASKELL__ < 808
    fail   = Fail.fail
#endif

instance MonadIO m => Fail.MonadFail (TCMT m) where
  fail :: String -> TCMT m a
fail = String -> TCMT m a
forall (tcm :: * -> *) a. MonadTCM tcm => String -> tcm a
internalError

instance MonadIO m => MonadIO (TCMT m) where
  liftIO :: IO a -> TCMT m a
liftIO IO a
m = (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m a) -> TCMT m a)
-> (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall a b. (a -> b) -> a -> b
$ \ IORef TCState
s TCEnv
env -> do
    IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> m a) -> IO a -> m a
forall a b. (a -> b) -> a -> b
$ IORef TCState -> Range -> IO a -> IO a
forall a. IORef TCState -> Range -> IO a -> IO a
wrap IORef TCState
s (TCEnv -> Range
envRange TCEnv
env) (IO a -> IO a) -> IO a -> IO a
forall a b. (a -> b) -> a -> b
$ do
      a
x <- IO a
m
      a
x a -> IO a -> IO a
`seq` a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x
    where
      wrap :: IORef TCState -> Range -> IO a -> IO a
wrap IORef TCState
s Range
r IO a
m = IO a -> (IOException -> IO a) -> IO a
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
E.catch IO a
m ((IOException -> IO a) -> IO a) -> (IOException -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \ IOException
err -> do
        TCState
s <- IORef TCState -> IO TCState
forall a. IORef a -> IO a
readIORef IORef TCState
s
        TCErr -> IO a
forall e a. Exception e => e -> IO a
E.throwIO (TCErr -> IO a) -> TCErr -> IO a
forall a b. (a -> b) -> a -> b
$ TCState -> Range -> IOException -> TCErr
IOException TCState
s Range
r IOException
err

instance MonadIO m => MonadTCEnv (TCMT m) where
  askTC :: TCMT m TCEnv
askTC             = (IORef TCState -> TCEnv -> m TCEnv) -> TCMT m TCEnv
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m TCEnv) -> TCMT m TCEnv)
-> (IORef TCState -> TCEnv -> m TCEnv) -> TCMT m TCEnv
forall a b. (a -> b) -> a -> b
$ \ IORef TCState
_ TCEnv
e -> TCEnv -> m TCEnv
forall (m :: * -> *) a. Monad m => a -> m a
return TCEnv
e
  localTC :: (TCEnv -> TCEnv) -> TCMT m a -> TCMT m a
localTC TCEnv -> TCEnv
f (TCM IORef TCState -> TCEnv -> m a
m) = (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m a) -> TCMT m a)
-> (IORef TCState -> TCEnv -> m a) -> TCMT m a
forall a b. (a -> b) -> a -> b
$ \ IORef TCState
s TCEnv
e -> IORef TCState -> TCEnv -> m a
m IORef TCState
s (TCEnv -> TCEnv
f TCEnv
e)

instance MonadIO m => MonadTCState (TCMT m) where
  getTC :: TCMT m TCState
getTC   = (IORef TCState -> TCEnv -> m TCState) -> TCMT m TCState
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m TCState) -> TCMT m TCState)
-> (IORef TCState -> TCEnv -> m TCState) -> TCMT m TCState
forall a b. (a -> b) -> a -> b
$ \ IORef TCState
r TCEnv
_e -> IO TCState -> m TCState
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IORef TCState -> IO TCState
forall a. IORef a -> IO a
readIORef IORef TCState
r)
  putTC :: TCState -> TCMT m ()
putTC TCState
s = (IORef TCState -> TCEnv -> m ()) -> TCMT m ()
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> m ()) -> TCMT m ())
-> (IORef TCState -> TCEnv -> m ()) -> TCMT m ()
forall a b. (a -> b) -> a -> b
$ \ IORef TCState
r TCEnv
_e -> IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IORef TCState -> TCState -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef IORef TCState
r TCState
s)

instance MonadIO m => ReadTCState (TCMT m) where
  getTCState :: TCMT m TCState
getTCState = TCMT m TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  locallyTCState :: Lens' a TCState -> (a -> a) -> TCMT m b -> TCMT m b
locallyTCState Lens' a TCState
l a -> a
f = TCMT m a -> (a -> TCMT m ()) -> TCMT m b -> TCMT m b
forall (m :: * -> *) a b.
Monad m =>
m a -> (a -> m ()) -> m b -> m b
bracket_ (Lens' a TCState -> TCMT m a
forall (m :: * -> *) a. ReadTCState m => Lens' a TCState -> m a
useTC Lens' a TCState
l TCMT m a -> TCMT m () -> TCMT m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Lens' a TCState -> (a -> a) -> TCMT m ()
forall (m :: * -> *) a.
MonadTCState m =>
Lens' a TCState -> (a -> a) -> m ()
modifyTCLens Lens' a TCState
l a -> a
f) (Lens' a TCState -> a -> TCMT m ()
forall (m :: * -> *) a.
MonadTCState m =>
Lens' a TCState -> a -> m ()
setTCLens Lens' a TCState
l)

instance MonadError TCErr TCM where
  throwError :: TCErr -> TCM a
throwError = IO a -> TCM a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> TCM a) -> (TCErr -> IO a) -> TCErr -> TCM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCErr -> IO a
forall e a. Exception e => e -> IO a
E.throwIO
  catchError :: TCM a -> (TCErr -> TCM a) -> TCM a
catchError TCM a
m TCErr -> TCM a
h = (IORef TCState -> TCEnv -> IO a) -> TCM a
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> IO a) -> TCM a)
-> (IORef TCState -> TCEnv -> IO a) -> TCM a
forall a b. (a -> b) -> a -> b
$ \ IORef TCState
r TCEnv
e -> do  -- now we are in the IO monad
    TCState
oldState <- IORef TCState -> IO TCState
forall a. IORef a -> IO a
readIORef IORef TCState
r
    TCM a -> IORef TCState -> TCEnv -> IO a
forall (m :: * -> *) a. TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM TCM a
m IORef TCState
r TCEnv
e IO a -> (TCErr -> IO a) -> IO a
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`E.catch` \TCErr
err -> do
      -- Reset the state, but do not forget changes to the persistent
      -- component. Not for pattern violations.
      case TCErr
err of
        TCErr
PatternErr -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        TCErr
_          ->
          IO () -> IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
            TCState
newState <- IORef TCState -> IO TCState
forall a. IORef a -> IO a
readIORef IORef TCState
r
            IORef TCState -> TCState -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef IORef TCState
r (TCState -> IO ()) -> TCState -> IO ()
forall a b. (a -> b) -> a -> b
$ TCState
oldState { stPersistentState :: PersistentTCState
stPersistentState = TCState -> PersistentTCState
stPersistentState TCState
newState }
      TCM a -> IORef TCState -> TCEnv -> IO a
forall (m :: * -> *) a. TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM (TCErr -> TCM a
h TCErr
err) IORef TCState
r TCEnv
e

-- | Like 'catchError', but resets the state completely before running the handler.
--   This means it also loses changes to the 'stPersistentState'.
--
--   The intended use is to catch internal errors during debug printing.
--   In debug printing, we are not expecting state changes.
instance CatchImpossible TCM where
  catchImpossibleJust :: (Impossible -> Maybe b) -> TCM a -> (b -> TCM a) -> TCM a
catchImpossibleJust Impossible -> Maybe b
f TCM a
m b -> TCM a
h = (IORef TCState -> TCEnv -> IO a) -> TCM a
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> IO a) -> TCM a)
-> (IORef TCState -> TCEnv -> IO a) -> TCM a
forall a b. (a -> b) -> a -> b
$ \ IORef TCState
r TCEnv
e -> do
    -- save the state
    TCState
s <- IORef TCState -> IO TCState
forall a. IORef a -> IO a
readIORef IORef TCState
r
    (Impossible -> Maybe b) -> IO a -> (b -> IO a) -> IO a
forall (m :: * -> *) b a.
CatchImpossible m =>
(Impossible -> Maybe b) -> m a -> (b -> m a) -> m a
catchImpossibleJust Impossible -> Maybe b
f (TCM a -> IORef TCState -> TCEnv -> IO a
forall (m :: * -> *) a. TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM TCM a
m IORef TCState
r TCEnv
e) ((b -> IO a) -> IO a) -> (b -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \ b
err -> do
      IORef TCState -> TCState -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef IORef TCState
r TCState
s
      TCM a -> IORef TCState -> TCEnv -> IO a
forall (m :: * -> *) a. TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM (b -> TCM a
h b
err) IORef TCState
r TCEnv
e

instance MonadIO m => MonadReduce (TCMT m) where
  liftReduce :: ReduceM a -> TCMT m a
liftReduce = TCM a -> TCMT m a
forall (tcm :: * -> *) a. MonadTCM tcm => TCM a -> tcm a
liftTCM (TCM a -> TCMT m a)
-> (ReduceM a -> TCM a) -> ReduceM a -> TCMT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReduceM a -> TCM a
forall a. ReduceM a -> TCM a
runReduceM

instance (IsString a, MonadIO m) => IsString (TCMT m a) where
  fromString :: String -> TCMT m a
fromString String
s = a -> TCMT m a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> a
forall a. IsString a => String -> a
fromString String
s)

-- | Strict (non-shortcut) semigroup.
--
--   Note that there might be a lazy alternative, e.g.,
--   for TCM All we might want 'Agda.Utils.Monad.and2M' as concatenation,
--   to shortcut conjunction in case we already have 'False'.
--
instance {-# OVERLAPPABLE #-} (MonadIO m, Semigroup a) => Semigroup (TCMT m a) where
  <> :: TCMT m a -> TCMT m a -> TCMT m a
(<>) = (a -> a -> a) -> TCMT m a -> TCMT m a -> TCMT m a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Semigroup a => a -> a -> a
(<>)

-- | Strict (non-shortcut) monoid.
instance {-# OVERLAPPABLE #-} (MonadIO m, Semigroup a, Monoid a) => Monoid (TCMT m a) where
  mempty :: TCMT m a
mempty  = a -> TCMT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Monoid a => a
mempty
  mappend :: TCMT m a -> TCMT m a -> TCMT m a
mappend = TCMT m a -> TCMT m a -> TCMT m a
forall a. Semigroup a => a -> a -> a
(<>)
  mconcat :: [TCMT m a] -> TCMT m a
mconcat = [a] -> a
forall a. Monoid a => [a] -> a
mconcat ([a] -> a) -> ([TCMT m a] -> TCMT m [a]) -> [TCMT m a] -> TCMT m a
forall (m :: * -> *) b c a.
Functor m =>
(b -> c) -> (a -> m b) -> a -> m c
<.> [TCMT m a] -> TCMT m [a]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence

-- | Interaction monad.

type IM = TCMT (Haskeline.InputT IO)

runIM :: IM a -> TCM a
runIM :: IM a -> TCM a
runIM = (forall a. InputT IO a -> IO a) -> IM a -> TCM a
forall (m :: * -> *) (n :: * -> *) a.
(forall a. m a -> n a) -> TCMT m a -> TCMT n a
mapTCMT (Settings IO -> InputT IO a -> IO a
forall (m :: * -> *) a.
(MonadIO m, MonadMask m) =>
Settings m -> InputT m a -> m a
Haskeline.runInputT Settings IO
forall (m :: * -> *). MonadIO m => Settings m
Haskeline.defaultSettings)

instance MonadError TCErr IM where
  throwError :: TCErr -> IM a
throwError     = IO a -> IM a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> IM a) -> (TCErr -> IO a) -> TCErr -> IM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCErr -> IO a
forall e a. Exception e => e -> IO a
E.throwIO
  catchError :: IM a -> (TCErr -> IM a) -> IM a
catchError IM a
m TCErr -> IM a
h = TCM a -> IM a
forall (tcm :: * -> *) a. MonadTCM tcm => TCM a -> tcm a
liftTCM (TCM a -> IM a) -> TCM a -> IM a
forall a b. (a -> b) -> a -> b
$ IM a -> TCM a
forall a. IM a -> TCM a
runIM IM a
m TCM a -> (TCErr -> TCM a) -> TCM a
forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
`catchError` (IM a -> TCM a
forall a. IM a -> TCM a
runIM (IM a -> TCM a) -> (TCErr -> IM a) -> TCErr -> TCM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCErr -> IM a
h)

-- | Preserve the state of the failing computation.
catchError_ :: TCM a -> (TCErr -> TCM a) -> TCM a
catchError_ :: TCM a -> (TCErr -> TCM a) -> TCM a
catchError_ TCM a
m TCErr -> TCM a
h = (IORef TCState -> TCEnv -> IO a) -> TCM a
forall (m :: * -> *) a. (IORef TCState -> TCEnv -> m a) -> TCMT m a
TCM ((IORef TCState -> TCEnv -> IO a) -> TCM a)
-> (IORef TCState -> TCEnv -> IO a) -> TCM a
forall a b. (a -> b) -> a -> b
$ \IORef TCState
r TCEnv
e ->
  TCM a -> IORef TCState -> TCEnv -> IO a
forall (m :: * -> *) a. TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM TCM a
m IORef TCState
r TCEnv
e
  IO a -> (TCErr -> IO a) -> IO a
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`E.catch` \TCErr
err -> TCM a -> IORef TCState -> TCEnv -> IO a
forall (m :: * -> *) a. TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM (TCErr -> TCM a
h TCErr
err) IORef TCState
r TCEnv
e

-- | Execute a finalizer even when an exception is thrown.
--   Does not catch any errors.
--   In case both the regular computation and the finalizer
--   throw an exception, the one of the finalizer is propagated.
finally_ :: TCM a -> TCM b -> TCM a
finally_ :: TCM a -> TCM b -> TCM a
finally_ TCM a
m TCM b
f = do
    a
x <- TCM a
m TCM a -> (TCErr -> TCM a) -> TCM a
forall a. TCM a -> (TCErr -> TCM a) -> TCM a
`catchError_` \ TCErr
err -> TCM b
f TCM b -> TCM a -> TCM a
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TCErr -> TCM a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError TCErr
err
    b
_ <- TCM b
f
    a -> TCM a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x

-- | Embedding a TCM computation.

class ( Applicative tcm, MonadIO tcm
      , MonadTCEnv tcm
      , MonadTCState tcm
      , HasOptions tcm
      ) => MonadTCM tcm where
    liftTCM :: TCM a -> tcm a

    default liftTCM :: (MonadTCM m, MonadTrans t, tcm ~ t m) => TCM a -> tcm a
    liftTCM = m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> t m a) -> (TCM a -> m a) -> TCM a -> t m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCM a -> m a
forall (tcm :: * -> *) a. MonadTCM tcm => TCM a -> tcm a
liftTCM

{-# RULES "liftTCM/id" liftTCM = id #-}
instance MonadIO m => MonadTCM (TCMT m) where
    liftTCM :: TCM a -> TCMT m a
liftTCM = (forall a. IO a -> m a) -> TCM a -> TCMT m a
forall (m :: * -> *) (n :: * -> *) a.
(forall a. m a -> n a) -> TCMT m a -> TCMT n a
mapTCMT forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO

instance MonadTCM tcm => MonadTCM (ChangeT tcm)
instance MonadTCM tcm => MonadTCM (ExceptT err tcm)
instance MonadTCM tcm => MonadTCM (IdentityT tcm)
instance MonadTCM tcm => MonadTCM (ListT tcm)
instance MonadTCM tcm => MonadTCM (MaybeT tcm)
instance MonadTCM tcm => MonadTCM (ReaderT r tcm)
instance MonadTCM tcm => MonadTCM (StateT s tcm)
instance (Monoid w, MonadTCM tcm) => MonadTCM (WriterT w tcm)

-- | We store benchmark statistics in an IORef.
--   This enables benchmarking pure computation, see
--   "Agda.Benchmarking".
instance MonadBench Phase TCM where
  getBenchmark :: TCM Benchmark
getBenchmark = IO Benchmark -> TCM Benchmark
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Benchmark -> TCM Benchmark) -> IO Benchmark -> TCM Benchmark
forall a b. (a -> b) -> a -> b
$ IO Benchmark
forall a (m :: * -> *). MonadBench a m => m (Benchmark a)
getBenchmark
  putBenchmark :: Benchmark -> TCMT IO ()
putBenchmark = IO () -> TCMT IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> TCMT IO ())
-> (Benchmark -> IO ()) -> Benchmark -> TCMT IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Benchmark -> IO ()
forall a (m :: * -> *). MonadBench a m => Benchmark a -> m ()
putBenchmark
  finally :: TCM b -> TCM c -> TCM b
finally = TCM b -> TCM c -> TCM b
forall b c. TCM b -> TCM c -> TCM b
finally_

instance Null (TCM Doc) where
  empty :: TCM Doc
empty = Doc -> TCM Doc
forall (m :: * -> *) a. Monad m => a -> m a
return Doc
forall a. Null a => a
empty
  null :: TCM Doc -> Bool
null = TCM Doc -> Bool
forall a. HasCallStack => a
__IMPOSSIBLE__

patternViolation :: MonadError TCErr m => m a
patternViolation :: m a
patternViolation = TCErr -> m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError TCErr
PatternErr

internalError :: MonadTCM tcm => String -> tcm a
internalError :: String -> tcm a
internalError String
s = TCM a -> tcm a
forall (tcm :: * -> *) a. MonadTCM tcm => TCM a -> tcm a
liftTCM (TCM a -> tcm a) -> TCM a -> tcm a
forall a b. (a -> b) -> a -> b
$ TypeError -> TCM a
forall (m :: * -> *) a.
(MonadTCEnv m, ReadTCState m, MonadError TCErr m) =>
TypeError -> m a
typeError (TypeError -> TCM a) -> TypeError -> TCM a
forall a b. (a -> b) -> a -> b
$ String -> TypeError
InternalError String
s

genericError :: (MonadTCEnv m, ReadTCState m, MonadError TCErr m)
             => String -> m a
genericError :: String -> m a
genericError = TypeError -> m a
forall (m :: * -> *) a.
(MonadTCEnv m, ReadTCState m, MonadError TCErr m) =>
TypeError -> m a
typeError (TypeError -> m a) -> (String -> TypeError) -> String -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> TypeError
GenericError

{-# SPECIALIZE genericDocError :: Doc -> TCM a #-}
genericDocError :: (MonadTCEnv m, ReadTCState m, MonadError TCErr m)
                => Doc -> m a
genericDocError :: Doc -> m a
genericDocError = TypeError -> m a
forall (m :: * -> *) a.
(MonadTCEnv m, ReadTCState m, MonadError TCErr m) =>
TypeError -> m a
typeError (TypeError -> m a) -> (Doc -> TypeError) -> Doc -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> TypeError
GenericDocError

{-# SPECIALIZE typeError :: TypeError -> TCM a #-}
typeError :: (MonadTCEnv m, ReadTCState m, MonadError TCErr m)
          => TypeError -> m a
typeError :: TypeError -> m a
typeError TypeError
err = TCErr -> m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (TCErr -> m a) -> m TCErr -> m a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< TypeError -> m TCErr
forall (m :: * -> *).
(MonadTCEnv m, ReadTCState m) =>
TypeError -> m TCErr
typeError_ TypeError
err

{-# SPECIALIZE typeError_ :: TypeError -> TCM TCErr #-}
typeError_ :: (MonadTCEnv m, ReadTCState m) => TypeError -> m TCErr
typeError_ :: TypeError -> m TCErr
typeError_ TypeError
err = TCState -> Closure TypeError -> TCErr
TypeError (TCState -> Closure TypeError -> TCErr)
-> m TCState -> m (Closure TypeError -> TCErr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m TCState
forall (m :: * -> *). ReadTCState m => m TCState
getTCState m (Closure TypeError -> TCErr) -> m (Closure TypeError) -> m TCErr
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TypeError -> m (Closure TypeError)
forall (m :: * -> *) a.
(MonadTCEnv m, ReadTCState m) =>
a -> m (Closure a)
buildClosure TypeError
err

-- | Running the type checking monad (most general form).
{-# SPECIALIZE runTCM :: TCEnv -> TCState -> TCM a -> IO (a, TCState) #-}
runTCM :: MonadIO m => TCEnv -> TCState -> TCMT m a -> m (a, TCState)
runTCM :: TCEnv -> TCState -> TCMT m a -> m (a, TCState)
runTCM TCEnv
e TCState
s TCMT m a
m = do
  IORef TCState
r <- IO (IORef TCState) -> m (IORef TCState)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef TCState) -> m (IORef TCState))
-> IO (IORef TCState) -> m (IORef TCState)
forall a b. (a -> b) -> a -> b
$ TCState -> IO (IORef TCState)
forall a. a -> IO (IORef a)
newIORef TCState
s
  a
a <- TCMT m a -> IORef TCState -> TCEnv -> m a
forall (m :: * -> *) a. TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM TCMT m a
m IORef TCState
r TCEnv
e
  TCState
s <- IO TCState -> m TCState
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TCState -> m TCState) -> IO TCState -> m TCState
forall a b. (a -> b) -> a -> b
$ IORef TCState -> IO TCState
forall a. IORef a -> IO a
readIORef IORef TCState
r
  (a, TCState) -> m (a, TCState)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, TCState
s)

-- | Running the type checking monad on toplevel (with initial state).
runTCMTop :: TCM a -> IO (Either TCErr a)
runTCMTop :: TCM a -> IO (Either TCErr a)
runTCMTop TCM a
m = (a -> Either TCErr a
forall a b. b -> Either a b
Right (a -> Either TCErr a) -> IO a -> IO (Either TCErr a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TCM a -> IO a
forall (m :: * -> *) a. MonadIO m => TCMT m a -> m a
runTCMTop' TCM a
m) IO (Either TCErr a)
-> (TCErr -> IO (Either TCErr a)) -> IO (Either TCErr a)
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`E.catch` (Either TCErr a -> IO (Either TCErr a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Either TCErr a -> IO (Either TCErr a))
-> (TCErr -> Either TCErr a) -> TCErr -> IO (Either TCErr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TCErr -> Either TCErr a
forall a b. a -> Either a b
Left)

runTCMTop' :: MonadIO m => TCMT m a -> m a
runTCMTop' :: TCMT m a -> m a
runTCMTop' TCMT m a
m = do
  IORef TCState
r <- IO (IORef TCState) -> m (IORef TCState)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef TCState) -> m (IORef TCState))
-> IO (IORef TCState) -> m (IORef TCState)
forall a b. (a -> b) -> a -> b
$ TCState -> IO (IORef TCState)
forall a. a -> IO (IORef a)
newIORef TCState
initState
  TCMT m a -> IORef TCState -> TCEnv -> m a
forall (m :: * -> *) a. TCMT m a -> IORef TCState -> TCEnv -> m a
unTCM TCMT m a
m IORef TCState
r TCEnv
initEnv

-- | 'runSafeTCM' runs a safe 'TCM' action (a 'TCM' action which cannot fail)
--   in the initial environment.

runSafeTCM :: TCM a -> TCState -> IO (a, TCState)
runSafeTCM :: TCM a -> TCState -> IO (a, TCState)
runSafeTCM TCM a
m TCState
st = TCEnv -> TCState -> TCM a -> IO (a, TCState)
forall (m :: * -> *) a.
MonadIO m =>
TCEnv -> TCState -> TCMT m a -> m (a, TCState)
runTCM TCEnv
initEnv TCState
st TCM a
m IO (a, TCState) -> (TCErr -> IO (a, TCState)) -> IO (a, TCState)
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`E.catch` (\ (TCErr
e :: TCErr) -> IO (a, TCState)
forall a. HasCallStack => a
__IMPOSSIBLE__)
-- runSafeTCM m st = either__IMPOSSIBLE__ return <$> do
--     -- Errors must be impossible.
--     runTCM $ do
--         putTC st
--         a <- m
--         st <- getTC
--         return (a, st)

-- | Runs the given computation in a separate thread, with /a copy/ of
-- the current state and environment.
--
-- Note that Agda sometimes uses actual, mutable state. If the
-- computation given to @forkTCM@ tries to /modify/ this state, then
-- bad things can happen, because accesses are not mutually exclusive.
-- The @forkTCM@ function has been added mainly to allow the thread to
-- /read/ (a snapshot of) the current state in a convenient way.
--
-- Note also that exceptions which are raised in the thread are not
-- propagated to the parent, so the thread should not do anything
-- important.

forkTCM :: TCM a -> TCM ()
forkTCM :: TCM a -> TCMT IO ()
forkTCM TCM a
m = do
  TCState
s <- TCMT IO TCState
forall (m :: * -> *). MonadTCState m => m TCState
getTC
  TCEnv
e <- TCMT IO TCEnv
forall (m :: * -> *). MonadTCEnv m => m TCEnv
askTC
  IO () -> TCMT IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> TCMT IO ()) -> IO () -> TCMT IO ()
forall a b. (a -> b) -> a -> b
$ IO ThreadId -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO ThreadId -> IO ()) -> IO ThreadId -> IO ()
forall a b. (a -> b) -> a -> b
$ IO () -> IO ThreadId
C.forkIO (IO () -> IO ThreadId) -> IO () -> IO ThreadId
forall a b. (a -> b) -> a -> b
$ IO (a, TCState) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (a, TCState) -> IO ()) -> IO (a, TCState) -> IO ()
forall a b. (a -> b) -> a -> b
$ TCEnv -> TCState -> TCM a -> IO (a, TCState)
forall (m :: * -> *) a.
MonadIO m =>
TCEnv -> TCState -> TCMT m a -> m (a, TCState)
runTCM TCEnv
e TCState
s TCM a
m

---------------------------------------------------------------------------
-- * Names for generated definitions
---------------------------------------------------------------------------

-- | Base name for patterns in telescopes
patternInTeleName :: String
patternInTeleName :: String
patternInTeleName = String
".patternInTele"

-- | Base name for extended lambda patterns
extendedLambdaName :: String
extendedLambdaName :: String
extendedLambdaName = String
".extendedlambda"

-- | Check whether we have an definition from an extended lambda.
isExtendedLambdaName :: A.QName -> Bool
isExtendedLambdaName :: QName -> Bool
isExtendedLambdaName = (String
extendedLambdaName String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`List.isPrefixOf`) (String -> Bool) -> (QName -> String) -> QName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> String
forall a. Pretty a => a -> String
prettyShow (Name -> String) -> (QName -> Name) -> QName -> String
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

-- | Name of absurdLambda definitions.
absurdLambdaName :: String
absurdLambdaName :: String
absurdLambdaName = String
".absurdlambda"

-- | Check whether we have an definition from an absurd lambda.
isAbsurdLambdaName :: QName -> Bool
isAbsurdLambdaName :: QName -> Bool
isAbsurdLambdaName = (String
absurdLambdaName String -> String -> Bool
forall a. Eq a => a -> a -> Bool
==) (String -> Bool) -> (QName -> String) -> QName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> String
forall a. Pretty a => a -> String
prettyShow (Name -> String) -> (QName -> Name) -> QName -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QName -> Name
qnameName

-- | Base name for generalized variable projections
generalizedFieldName :: String
generalizedFieldName :: String
generalizedFieldName = String
".generalizedField-"

-- | Check whether we have a generalized variable field
getGeneralizedFieldName :: A.QName -> Maybe String
getGeneralizedFieldName :: QName -> Maybe String
getGeneralizedFieldName QName
q
  | String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
List.isPrefixOf String
generalizedFieldName String
strName = String -> Maybe String
forall a. a -> Maybe a
Just (Int -> ShowS
forall a. Int -> [a] -> [a]
drop (String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
generalizedFieldName) String
strName)
  | Bool
otherwise                                    = Maybe String
forall a. Maybe a
Nothing
  where strName :: String
strName = Name -> String
forall a. Pretty a => a -> String
prettyShow (Name -> String) -> Name -> String
forall a b. (a -> b) -> a -> b
$ Name -> Name
nameConcrete (Name -> Name) -> Name -> Name
forall a b. (a -> b) -> a -> b
$ QName -> Name
qnameName QName
q

---------------------------------------------------------------------------
-- * KillRange instances
---------------------------------------------------------------------------

instance KillRange Signature where
  killRange :: Signature -> Signature
killRange (Sig Sections
secs Definitions
defs RewriteRuleMap
rews) = (Sections -> Definitions -> RewriteRuleMap -> Signature)
-> Sections -> Definitions -> RewriteRuleMap -> Signature
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 Sections -> Definitions -> RewriteRuleMap -> Signature
Sig Sections
secs Definitions
defs RewriteRuleMap
rews

instance KillRange Sections where
  killRange :: KillRangeT Sections
killRange = (Section -> Section) -> KillRangeT Sections
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Section -> Section
forall a. KillRange a => KillRangeT a
killRange

instance KillRange Definitions where
  killRange :: KillRangeT Definitions
killRange = (Definition -> Definition) -> KillRangeT Definitions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Definition -> Definition
forall a. KillRange a => KillRangeT a
killRange

instance KillRange RewriteRuleMap where
  killRange :: KillRangeT RewriteRuleMap
killRange = ([RewriteRule] -> [RewriteRule]) -> KillRangeT RewriteRuleMap
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [RewriteRule] -> [RewriteRule]
forall a. KillRange a => KillRangeT a
killRange

instance KillRange Section where
  killRange :: Section -> Section
killRange (Section Telescope
tel) = (Telescope -> Section) -> Telescope -> Section
forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Telescope -> Section
Section Telescope
tel

instance KillRange Definition where
  killRange :: Definition -> Definition
killRange (Defn ArgInfo
ai QName
name Type
t [Polarity]
pols [Occurrence]
occs NumGeneralizableArgs
gens [Maybe Name]
gpars [LocalDisplayForm]
displ MutualId
mut CompiledRepresentation
compiled Maybe QName
inst Bool
copy Set QName
ma Bool
nc Bool
inj Bool
copat Blocked_
blk Defn
def) =
    (ArgInfo
 -> QName
 -> Type
 -> [Polarity]
 -> [Occurrence]
 -> NumGeneralizableArgs
 -> [Maybe Name]
 -> [LocalDisplayForm]
 -> MutualId
 -> CompiledRepresentation
 -> Maybe QName
 -> Bool
 -> Set QName
 -> Bool
 -> Bool
 -> Bool
 -> Blocked_
 -> Defn
 -> Definition)
-> ArgInfo
-> QName
-> Type
-> [Polarity]
-> [Occurrence]
-> NumGeneralizableArgs
-> [Maybe Name]
-> [LocalDisplayForm]
-> MutualId
-> CompiledRepresentation
-> Maybe QName
-> Bool
-> Set QName
-> Bool
-> Bool
-> Bool
-> Blocked_
-> Defn
-> Definition
forall a b c d e f g h i j k l m n o p q r s.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
 KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
 KillRange k, KillRange l, KillRange m, KillRange n, KillRange o,
 KillRange p, KillRange q, KillRange r) =>
(a
 -> b
 -> c
 -> d
 -> e
 -> f
 -> g
 -> h
 -> i
 -> j
 -> k
 -> l
 -> m
 -> n
 -> o
 -> p
 -> q
 -> r
 -> s)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
killRange18 ArgInfo
-> QName
-> Type
-> [Polarity]
-> [Occurrence]
-> NumGeneralizableArgs
-> [Maybe Name]
-> [LocalDisplayForm]
-> MutualId
-> CompiledRepresentation
-> Maybe QName
-> Bool
-> Set QName
-> Bool
-> Bool
-> Bool
-> Blocked_
-> Defn
-> Definition
Defn ArgInfo
ai QName
name Type
t [Polarity]
pols [Occurrence]
occs NumGeneralizableArgs
gens [Maybe Name]
gpars [LocalDisplayForm]
displ MutualId
mut CompiledRepresentation
compiled Maybe QName
inst Bool
copy Set QName
ma Bool
nc Bool
inj Bool
copat Blocked_
blk Defn
def
    -- TODO clarify: Keep the range in the defName field?

instance KillRange NumGeneralizableArgs where
  killRange :: NumGeneralizableArgs -> NumGeneralizableArgs
killRange = NumGeneralizableArgs -> NumGeneralizableArgs
forall a. a -> a
id

instance KillRange NLPat where
  killRange :: NLPat -> NLPat
killRange (PVar Int
x [Arg Int]
y) = (Int -> [Arg Int] -> NLPat) -> Int -> [Arg Int] -> NLPat
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 Int -> [Arg Int] -> NLPat
PVar Int
x [Arg Int]
y
  killRange (PDef QName
x PElims
y) = (QName -> PElims -> NLPat) -> QName -> PElims -> NLPat
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 QName -> PElims -> NLPat
PDef QName
x PElims
y
  killRange (PLam ArgInfo
x Abs NLPat
y) = (ArgInfo -> Abs NLPat -> NLPat) -> ArgInfo -> Abs NLPat -> NLPat
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 ArgInfo -> Abs NLPat -> NLPat
PLam ArgInfo
x Abs NLPat
y
  killRange (PPi Dom NLPType
x Abs NLPType
y)  = (Dom NLPType -> Abs NLPType -> NLPat)
-> Dom NLPType -> Abs NLPType -> NLPat
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 Dom NLPType -> Abs NLPType -> NLPat
PPi Dom NLPType
x Abs NLPType
y
  killRange (PSort NLPSort
x)  = (NLPSort -> NLPat) -> NLPSort -> NLPat
forall a b. KillRange a => (a -> b) -> a -> b
killRange1 NLPSort -> NLPat
PSort NLPSort
x
  killRange (PBoundVar Int
x PElims
y) = (Int -> PElims -> NLPat) -> Int -> PElims -> NLPat
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 Int -> PElims -> NLPat
PBoundVar Int
x PElims
y
  killRange (PTerm Term
x)  = (Term -> NLPat) -> Term -> NLPat
forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Term -> NLPat
PTerm Term
x

instance KillRange NLPType where
  killRange :: NLPType -> NLPType
killRange (NLPType NLPSort
s NLPat
a) = (NLPSort -> NLPat -> NLPType) -> NLPSort -> NLPat -> NLPType
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 NLPSort -> NLPat -> NLPType
NLPType NLPSort
s NLPat
a

instance KillRange NLPSort where
  killRange :: NLPSort -> NLPSort
killRange (PType NLPat
l) = (NLPat -> NLPSort) -> NLPat -> NLPSort
forall a b. KillRange a => (a -> b) -> a -> b
killRange1 NLPat -> NLPSort
PType NLPat
l
  killRange (PProp NLPat
l) = (NLPat -> NLPSort) -> NLPat -> NLPSort
forall a b. KillRange a => (a -> b) -> a -> b
killRange1 NLPat -> NLPSort
PProp NLPat
l
  killRange NLPSort
PInf      = NLPSort
PInf
  killRange NLPSort
PSizeUniv = NLPSort
PSizeUniv

instance KillRange RewriteRule where
  killRange :: RewriteRule -> RewriteRule
killRange (RewriteRule QName
q Telescope
gamma QName
f PElims
es Term
rhs Type
t) =
    (QName
 -> Telescope -> QName -> PElims -> Term -> Type -> RewriteRule)
-> QName
-> Telescope
-> QName
-> PElims
-> Term
-> Type
-> RewriteRule
forall a b c d e f g.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
 KillRange f) =>
(a -> b -> c -> d -> e -> f -> g)
-> a -> b -> c -> d -> e -> f -> g
killRange6 QName
-> Telescope -> QName -> PElims -> Term -> Type -> RewriteRule
RewriteRule QName
q Telescope
gamma QName
f PElims
es Term
rhs Type
t

instance KillRange CompiledRepresentation where
  killRange :: KillRangeT CompiledRepresentation
killRange = KillRangeT CompiledRepresentation
forall a. a -> a
id


instance KillRange EtaEquality where
  killRange :: EtaEquality -> EtaEquality
killRange = EtaEquality -> EtaEquality
forall a. a -> a
id

instance KillRange System where
  killRange :: System -> System
killRange (System Telescope
tel [(Face, Term)]
sys) = Telescope -> [(Face, Term)] -> System
System (KillRangeT Telescope
forall a. KillRange a => KillRangeT a
killRange Telescope
tel) (KillRangeT [(Face, Term)]
forall a. KillRange a => KillRangeT a
killRange [(Face, Term)]
sys)

instance KillRange ExtLamInfo where
  killRange :: ExtLamInfo -> ExtLamInfo
killRange (ExtLamInfo ModuleName
m Maybe System
sys) = (ModuleName -> Maybe System -> ExtLamInfo)
-> ModuleName -> Maybe System -> ExtLamInfo
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 ModuleName -> Maybe System -> ExtLamInfo
ExtLamInfo ModuleName
m Maybe System
sys

instance KillRange FunctionFlag where
  killRange :: FunctionFlag -> FunctionFlag
killRange = FunctionFlag -> FunctionFlag
forall a. a -> a
id

instance KillRange CompKit where
  killRange :: CompKit -> CompKit
killRange = CompKit -> CompKit
forall a. a -> a
id

instance KillRange Defn where
  killRange :: Defn -> Defn
killRange Defn
def =
    case Defn
def of
      Defn
Axiom -> Defn
Axiom
      DataOrRecSig Int
n -> Int -> Defn
DataOrRecSig Int
n
      Defn
GeneralizableVar -> Defn
GeneralizableVar
      AbstractDefn{} -> Defn
forall a. HasCallStack => a
__IMPOSSIBLE__ -- only returned by 'getConstInfo'!
      Function [Clause]
cls Maybe CompiledClauses
comp Maybe SplitTree
ct Maybe Compiled
tt [Clause]
covering FunctionInverse
inv Maybe [QName]
mut IsAbstract
isAbs Delayed
delayed Maybe Projection
proj Set FunctionFlag
flags Maybe Bool
term Maybe ExtLamInfo
extlam Maybe QName
with ->
        ([Clause]
 -> Maybe CompiledClauses
 -> Maybe SplitTree
 -> Maybe Compiled
 -> [Clause]
 -> FunctionInverse
 -> Maybe [QName]
 -> IsAbstract
 -> Delayed
 -> Maybe Projection
 -> Set FunctionFlag
 -> Maybe Bool
 -> Maybe ExtLamInfo
 -> Maybe QName
 -> Defn)
-> [Clause]
-> Maybe CompiledClauses
-> Maybe SplitTree
-> Maybe Compiled
-> [Clause]
-> FunctionInverse
-> Maybe [QName]
-> IsAbstract
-> Delayed
-> Maybe Projection
-> Set FunctionFlag
-> Maybe Bool
-> Maybe ExtLamInfo
-> Maybe QName
-> Defn
forall a b c d e f g h i j k l m n o.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
 KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
 KillRange k, KillRange l, KillRange m, KillRange n) =>
(a
 -> b
 -> c
 -> d
 -> e
 -> f
 -> g
 -> h
 -> i
 -> j
 -> k
 -> l
 -> m
 -> n
 -> o)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
killRange14 [Clause]
-> Maybe CompiledClauses
-> Maybe SplitTree
-> Maybe Compiled
-> [Clause]
-> FunctionInverse
-> Maybe [QName]
-> IsAbstract
-> Delayed
-> Maybe Projection
-> Set FunctionFlag
-> Maybe Bool
-> Maybe ExtLamInfo
-> Maybe QName
-> Defn
Function [Clause]
cls Maybe CompiledClauses
comp Maybe SplitTree
ct Maybe Compiled
tt [Clause]
covering FunctionInverse
inv Maybe [QName]
mut IsAbstract
isAbs Delayed
delayed Maybe Projection
proj Set FunctionFlag
flags Maybe Bool
term Maybe ExtLamInfo
extlam Maybe QName
with
      Datatype Int
a Int
b Maybe Clause
c [QName]
d Sort
e Maybe [QName]
f IsAbstract
g [QName]
h       -> (Int
 -> Int
 -> Maybe Clause
 -> [QName]
 -> Sort
 -> Maybe [QName]
 -> IsAbstract
 -> [QName]
 -> Defn)
-> Int
-> Int
-> Maybe Clause
-> [QName]
-> Sort
-> Maybe [QName]
-> IsAbstract
-> [QName]
-> Defn
forall a b c d e f g h.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
 KillRange f, KillRange g) =>
(a -> b -> c -> d -> e -> f -> g -> h)
-> a -> b -> c -> d -> e -> f -> g -> h
killRange7 Int
-> Int
-> Maybe Clause
-> [QName]
-> Sort
-> Maybe [QName]
-> IsAbstract
-> [QName]
-> Defn
Datatype Int
a Int
b Maybe Clause
c [QName]
d Sort
e Maybe [QName]
f IsAbstract
g [QName]
h
      Record Int
a Maybe Clause
b ConHead
c Bool
d [Dom QName]
e Telescope
f Maybe [QName]
g EtaEquality
h Maybe Induction
i IsAbstract
j CompKit
k   -> (Int
 -> Maybe Clause
 -> ConHead
 -> Bool
 -> [Dom QName]
 -> Telescope
 -> Maybe [QName]
 -> EtaEquality
 -> Maybe Induction
 -> IsAbstract
 -> CompKit
 -> Defn)
-> Int
-> Maybe Clause
-> ConHead
-> Bool
-> [Dom QName]
-> Telescope
-> Maybe [QName]
-> EtaEquality
-> Maybe Induction
-> IsAbstract
-> CompKit
-> Defn
forall a b c d e f g h i j k l.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
 KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
 KillRange k) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
killRange11 Int
-> Maybe Clause
-> ConHead
-> Bool
-> [Dom QName]
-> Telescope
-> Maybe [QName]
-> EtaEquality
-> Maybe Induction
-> IsAbstract
-> CompKit
-> Defn
Record Int
a Maybe Clause
b ConHead
c Bool
d [Dom QName]
e Telescope
f Maybe [QName]
g EtaEquality
h Maybe Induction
i IsAbstract
j CompKit
k
      Constructor Int
a Int
b ConHead
c QName
d IsAbstract
e Induction
f CompKit
g Maybe [QName]
h [IsForced]
i Maybe [Bool]
j-> (Int
 -> Int
 -> ConHead
 -> QName
 -> IsAbstract
 -> Induction
 -> CompKit
 -> Maybe [QName]
 -> [IsForced]
 -> Maybe [Bool]
 -> Defn)
-> Int
-> Int
-> ConHead
-> QName
-> IsAbstract
-> Induction
-> CompKit
-> Maybe [QName]
-> [IsForced]
-> Maybe [Bool]
-> Defn
forall a b c d e f g h i j k.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
 KillRange f, KillRange g, KillRange h, KillRange i, KillRange j) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
killRange10 Int
-> Int
-> ConHead
-> QName
-> IsAbstract
-> Induction
-> CompKit
-> Maybe [QName]
-> [IsForced]
-> Maybe [Bool]
-> Defn
Constructor Int
a Int
b ConHead
c QName
d IsAbstract
e Induction
f CompKit
g Maybe [QName]
h [IsForced]
i Maybe [Bool]
j
      Primitive IsAbstract
a String
b [Clause]
c FunctionInverse
d Maybe CompiledClauses
e            -> (IsAbstract
 -> String
 -> [Clause]
 -> FunctionInverse
 -> Maybe CompiledClauses
 -> Defn)
-> IsAbstract
-> String
-> [Clause]
-> FunctionInverse
-> Maybe CompiledClauses
-> Defn
forall a b c d e f.
(KillRange a, KillRange b, KillRange c, KillRange d,
 KillRange e) =>
(a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
killRange5 IsAbstract
-> String
-> [Clause]
-> FunctionInverse
-> Maybe CompiledClauses
-> Defn
Primitive IsAbstract
a String
b [Clause]
c FunctionInverse
d Maybe CompiledClauses
e

instance KillRange MutualId where
  killRange :: MutualId -> MutualId
killRange = MutualId -> MutualId
forall a. a -> a
id

instance KillRange c => KillRange (FunctionInverse' c) where
  killRange :: KillRangeT (FunctionInverse' c)
killRange FunctionInverse' c
NotInjective = FunctionInverse' c
forall c. FunctionInverse' c
NotInjective
  killRange (Inverse InversionMap c
m)  = InversionMap c -> FunctionInverse' c
forall c. InversionMap c -> FunctionInverse' c
Inverse (InversionMap c -> FunctionInverse' c)
-> InversionMap c -> FunctionInverse' c
forall a b. (a -> b) -> a -> b
$ KillRangeT (InversionMap c)
forall k v. (KillRange k, KillRange v) => KillRangeT (Map k v)
killRangeMap InversionMap c
m

instance KillRange TermHead where
  killRange :: TermHead -> TermHead
killRange TermHead
SortHead     = TermHead
SortHead
  killRange TermHead
PiHead       = TermHead
PiHead
  killRange (ConsHead QName
q) = QName -> TermHead
ConsHead (QName -> TermHead) -> QName -> TermHead
forall a b. (a -> b) -> a -> b
$ KillRangeT QName
forall a. KillRange a => KillRangeT a
killRange QName
q
  killRange h :: TermHead
h@VarHead{}  = TermHead
h
  killRange TermHead
UnknownHead  = TermHead
UnknownHead

instance KillRange Projection where
  killRange :: Projection -> Projection
killRange (Projection Maybe QName
a QName
b Arg QName
c Int
d ProjLams
e) = (Maybe QName
 -> QName -> Arg QName -> Int -> ProjLams -> Projection)
-> Maybe QName
-> QName
-> Arg QName
-> Int
-> ProjLams
-> Projection
forall a b c d e f.
(KillRange a, KillRange b, KillRange c, KillRange d,
 KillRange e) =>
(a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
killRange5 Maybe QName -> QName -> Arg QName -> Int -> ProjLams -> Projection
Projection Maybe QName
a QName
b Arg QName
c Int
d ProjLams
e

instance KillRange ProjLams where
  killRange :: ProjLams -> ProjLams
killRange = ProjLams -> ProjLams
forall a. a -> a
id

instance KillRange a => KillRange (Open a) where
  killRange :: KillRangeT (Open a)
killRange = (a -> a) -> KillRangeT (Open a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. KillRange a => KillRangeT a
killRange

instance KillRange DisplayForm where
  killRange :: DisplayForm -> DisplayForm
killRange (Display Int
n [Elim]
es DisplayTerm
dt) = (Int -> [Elim] -> DisplayTerm -> DisplayForm)
-> Int -> [Elim] -> DisplayTerm -> DisplayForm
forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 Int -> [Elim] -> DisplayTerm -> DisplayForm
Display Int
n [Elim]
es DisplayTerm
dt

instance KillRange Polarity where
  killRange :: Polarity -> Polarity
killRange = Polarity -> Polarity
forall a. a -> a
id

instance KillRange IsForced where
  killRange :: IsForced -> IsForced
killRange = IsForced -> IsForced
forall a. a -> a
id

instance KillRange DoGeneralize where
  killRange :: DoGeneralize -> DoGeneralize
killRange = DoGeneralize -> DoGeneralize
forall a. a -> a
id

instance KillRange DisplayTerm where
  killRange :: DisplayTerm -> DisplayTerm
killRange DisplayTerm
dt =
    case DisplayTerm
dt of
      DWithApp DisplayTerm
dt [DisplayTerm]
dts [Elim]
es -> (DisplayTerm -> [DisplayTerm] -> [Elim] -> DisplayTerm)
-> DisplayTerm -> [DisplayTerm] -> [Elim] -> DisplayTerm
forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 DisplayTerm -> [DisplayTerm] -> [Elim] -> DisplayTerm
DWithApp DisplayTerm
dt [DisplayTerm]
dts [Elim]
es
      DCon ConHead
q ConInfo
ci [Arg DisplayTerm]
dts     -> (ConHead -> ConInfo -> [Arg DisplayTerm] -> DisplayTerm)
-> ConHead -> ConInfo -> [Arg DisplayTerm] -> DisplayTerm
forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 ConHead -> ConInfo -> [Arg DisplayTerm] -> DisplayTerm
DCon ConHead
q ConInfo
ci [Arg DisplayTerm]
dts
      DDef QName
q [Elim' DisplayTerm]
dts        -> (QName -> [Elim' DisplayTerm] -> DisplayTerm)
-> QName -> [Elim' DisplayTerm] -> DisplayTerm
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 QName -> [Elim' DisplayTerm] -> DisplayTerm
DDef QName
q [Elim' DisplayTerm]
dts
      DDot Term
v            -> (Term -> DisplayTerm) -> Term -> DisplayTerm
forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Term -> DisplayTerm
DDot Term
v
      DTerm Term
v           -> (Term -> DisplayTerm) -> Term -> DisplayTerm
forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Term -> DisplayTerm
DTerm Term
v

instance KillRange a => KillRange (Closure a) where
  killRange :: KillRangeT (Closure a)
killRange = KillRangeT (Closure a)
forall a. a -> a
id