{-# OPTIONS_GHC -fno-cse #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Agda.Interaction.Base where
import Control.Concurrent.STM.TChan
import Control.Concurrent.STM.TVar
import Control.Monad ( mplus, liftM2, liftM4 )
import Control.Monad.Except
import Control.Monad.Identity
import Control.Monad.State
import qualified Data.List as List
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe (listToMaybe)
import {-# SOURCE #-} Agda.TypeChecking.Monad.Base
(HighlightingLevel, HighlightingMethod, TCM, Comparison, Polarity, TCErr)
import Agda.Syntax.Abstract (QName)
import Agda.Syntax.Common (InteractionId (..), Modality)
import Agda.Syntax.Internal (ProblemId, Blocker)
import Agda.Syntax.Position
import Agda.Syntax.Scope.Base (ScopeInfo)
import Agda.Syntax.TopLevelModuleName
import Agda.Interaction.Options (CommandLineOptions,
defaultOptions)
import Agda.Utils.FileName (AbsolutePath, mkAbsolute)
import Agda.Utils.Pretty (Pretty(..), prettyShow, text)
import Agda.Utils.Time (ClockTime)
data CommandState = CommandState
{ CommandState -> [InteractionId]
theInteractionPoints :: [InteractionId]
, CommandState -> Maybe CurrentFile
theCurrentFile :: Maybe CurrentFile
, CommandState -> CommandLineOptions
optionsOnReload :: CommandLineOptions
, CommandState -> OldInteractionScopes
oldInteractionScopes :: !OldInteractionScopes
, CommandState -> CommandQueue
commandQueue :: !CommandQueue
}
type OldInteractionScopes = Map InteractionId ScopeInfo
initCommandState :: CommandQueue -> CommandState
initCommandState :: CommandQueue -> CommandState
initCommandState CommandQueue
commandQueue =
CommandState
{ theInteractionPoints :: [InteractionId]
theInteractionPoints = []
, theCurrentFile :: Maybe CurrentFile
theCurrentFile = forall a. Maybe a
Nothing
, optionsOnReload :: CommandLineOptions
optionsOnReload = CommandLineOptions
defaultOptions
, oldInteractionScopes :: OldInteractionScopes
oldInteractionScopes = forall k a. Map k a
Map.empty
, commandQueue :: CommandQueue
commandQueue = CommandQueue
commandQueue
}
type CommandM = StateT CommandState TCM
data CurrentFile = CurrentFile
{ CurrentFile -> AbsolutePath
currentFilePath :: AbsolutePath
, CurrentFile -> TopLevelModuleName
currentFileModule :: TopLevelModuleName
, CurrentFile -> [String]
currentFileArgs :: [String]
, CurrentFile -> ClockTime
currentFileStamp :: ClockTime
} deriving (Int -> CurrentFile -> ShowS
[CurrentFile] -> ShowS
CurrentFile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CurrentFile] -> ShowS
$cshowList :: [CurrentFile] -> ShowS
show :: CurrentFile -> String
$cshow :: CurrentFile -> String
showsPrec :: Int -> CurrentFile -> ShowS
$cshowsPrec :: Int -> CurrentFile -> ShowS
Show)
data Command' a
= Command !a
| Done
| Error String
deriving Int -> Command' a -> ShowS
forall a. Show a => Int -> Command' a -> ShowS
forall a. Show a => [Command' a] -> ShowS
forall a. Show a => Command' a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Command' a] -> ShowS
$cshowList :: forall a. Show a => [Command' a] -> ShowS
show :: Command' a -> String
$cshow :: forall a. Show a => Command' a -> String
showsPrec :: Int -> Command' a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Command' a -> ShowS
Show
type Command = Command' IOTCM
type IOTCM = Maybe TopLevelModuleName -> IOTCM' Range
data CommandQueue = CommandQueue
{ CommandQueue -> TChan (Integer, Command)
commands :: !(TChan (Integer, Command))
, CommandQueue -> TVar (Maybe Integer)
abort :: !(TVar (Maybe Integer))
}
type Interaction = Interaction' Range
data Interaction' range
= Cmd_load FilePath [String]
| Cmd_compile CompilerBackend FilePath [String]
| Cmd_constraints
| Cmd_metas Rewrite
| Cmd_no_metas
| Cmd_show_module_contents_toplevel
Rewrite
String
| Cmd_search_about_toplevel Rewrite String
| Cmd_solveAll Rewrite
| Cmd_solveOne Rewrite InteractionId range String
| Cmd_autoOne InteractionId range String
| Cmd_autoAll
| Cmd_infer_toplevel Rewrite
String
| Cmd_compute_toplevel ComputeMode
String
| Cmd_load_highlighting_info FilePath
| Cmd_tokenHighlighting FilePath Remove
| Cmd_highlight InteractionId range String
| ShowImplicitArgs Bool
| ToggleImplicitArgs
| ShowIrrelevantArgs Bool
| ToggleIrrelevantArgs
| Cmd_give UseForce InteractionId range String
| Cmd_refine InteractionId range String
| Cmd_intro Bool InteractionId range String
| Cmd_refine_or_intro Bool InteractionId range String
| Cmd_context Rewrite InteractionId range String
| Cmd_helper_function Rewrite InteractionId range String
| Cmd_infer Rewrite InteractionId range String
| Cmd_goal_type Rewrite InteractionId range String
| Cmd_elaborate_give
Rewrite InteractionId range String
| Cmd_goal_type_context Rewrite InteractionId range String
| Cmd_goal_type_context_infer
Rewrite InteractionId range String
| Cmd_goal_type_context_check
Rewrite InteractionId range String
| Cmd_show_module_contents
Rewrite InteractionId range String
| Cmd_make_case InteractionId range String
| Cmd_compute ComputeMode
InteractionId range String
| Cmd_why_in_scope InteractionId range String
| Cmd_why_in_scope_toplevel String
| Cmd_show_version
| Cmd_abort
| Cmd_exit
deriving (Int -> Interaction' range -> ShowS
forall range. Show range => Int -> Interaction' range -> ShowS
forall range. Show range => [Interaction' range] -> ShowS
forall range. Show range => Interaction' range -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Interaction' range] -> ShowS
$cshowList :: forall range. Show range => [Interaction' range] -> ShowS
show :: Interaction' range -> String
$cshow :: forall range. Show range => Interaction' range -> String
showsPrec :: Int -> Interaction' range -> ShowS
$cshowsPrec :: forall range. Show range => Int -> Interaction' range -> ShowS
Show, ReadPrec [Interaction' range]
ReadPrec (Interaction' range)
ReadS [Interaction' range]
forall range. Read range => ReadPrec [Interaction' range]
forall range. Read range => ReadPrec (Interaction' range)
forall range. Read range => Int -> ReadS (Interaction' range)
forall range. Read range => ReadS [Interaction' range]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Interaction' range]
$creadListPrec :: forall range. Read range => ReadPrec [Interaction' range]
readPrec :: ReadPrec (Interaction' range)
$creadPrec :: forall range. Read range => ReadPrec (Interaction' range)
readList :: ReadS [Interaction' range]
$creadList :: forall range. Read range => ReadS [Interaction' range]
readsPrec :: Int -> ReadS (Interaction' range)
$creadsPrec :: forall range. Read range => Int -> ReadS (Interaction' range)
Read, forall a b. a -> Interaction' b -> Interaction' a
forall a b. (a -> b) -> Interaction' a -> Interaction' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Interaction' b -> Interaction' a
$c<$ :: forall a b. a -> Interaction' b -> Interaction' a
fmap :: forall a b. (a -> b) -> Interaction' a -> Interaction' b
$cfmap :: forall a b. (a -> b) -> Interaction' a -> Interaction' b
Functor, forall a. Eq a => a -> Interaction' a -> Bool
forall a. Num a => Interaction' a -> a
forall a. Ord a => Interaction' a -> a
forall m. Monoid m => Interaction' m -> m
forall a. Interaction' a -> Bool
forall a. Interaction' a -> Int
forall a. Interaction' a -> [a]
forall a. (a -> a -> a) -> Interaction' a -> a
forall m a. Monoid m => (a -> m) -> Interaction' a -> m
forall b a. (b -> a -> b) -> b -> Interaction' a -> b
forall a b. (a -> b -> b) -> b -> Interaction' 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 :: forall a. Num a => Interaction' a -> a
$cproduct :: forall a. Num a => Interaction' a -> a
sum :: forall a. Num a => Interaction' a -> a
$csum :: forall a. Num a => Interaction' a -> a
minimum :: forall a. Ord a => Interaction' a -> a
$cminimum :: forall a. Ord a => Interaction' a -> a
maximum :: forall a. Ord a => Interaction' a -> a
$cmaximum :: forall a. Ord a => Interaction' a -> a
elem :: forall a. Eq a => a -> Interaction' a -> Bool
$celem :: forall a. Eq a => a -> Interaction' a -> Bool
length :: forall a. Interaction' a -> Int
$clength :: forall a. Interaction' a -> Int
null :: forall a. Interaction' a -> Bool
$cnull :: forall a. Interaction' a -> Bool
toList :: forall a. Interaction' a -> [a]
$ctoList :: forall a. Interaction' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> Interaction' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Interaction' a -> a
foldr1 :: forall a. (a -> a -> a) -> Interaction' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Interaction' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> Interaction' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Interaction' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Interaction' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Interaction' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Interaction' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Interaction' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Interaction' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Interaction' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> Interaction' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Interaction' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Interaction' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Interaction' a -> m
fold :: forall m. Monoid m => Interaction' m -> m
$cfold :: forall m. Monoid m => Interaction' m -> m
Foldable, Functor Interaction'
Foldable Interaction'
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 =>
Interaction' (m a) -> m (Interaction' a)
forall (f :: * -> *) a.
Applicative f =>
Interaction' (f a) -> f (Interaction' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Interaction' a -> m (Interaction' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Interaction' a -> f (Interaction' b)
sequence :: forall (m :: * -> *) a.
Monad m =>
Interaction' (m a) -> m (Interaction' a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
Interaction' (m a) -> m (Interaction' a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Interaction' a -> m (Interaction' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Interaction' a -> m (Interaction' b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Interaction' (f a) -> f (Interaction' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Interaction' (f a) -> f (Interaction' a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Interaction' a -> f (Interaction' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Interaction' a -> f (Interaction' b)
Traversable)
data IOTCM' range
= IOTCM
FilePath
HighlightingLevel
HighlightingMethod
(Interaction' range)
deriving (Int -> IOTCM' range -> ShowS
forall range. Show range => Int -> IOTCM' range -> ShowS
forall range. Show range => [IOTCM' range] -> ShowS
forall range. Show range => IOTCM' range -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IOTCM' range] -> ShowS
$cshowList :: forall range. Show range => [IOTCM' range] -> ShowS
show :: IOTCM' range -> String
$cshow :: forall range. Show range => IOTCM' range -> String
showsPrec :: Int -> IOTCM' range -> ShowS
$cshowsPrec :: forall range. Show range => Int -> IOTCM' range -> ShowS
Show, ReadPrec [IOTCM' range]
ReadPrec (IOTCM' range)
ReadS [IOTCM' range]
forall range. Read range => ReadPrec [IOTCM' range]
forall range. Read range => ReadPrec (IOTCM' range)
forall range. Read range => Int -> ReadS (IOTCM' range)
forall range. Read range => ReadS [IOTCM' range]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IOTCM' range]
$creadListPrec :: forall range. Read range => ReadPrec [IOTCM' range]
readPrec :: ReadPrec (IOTCM' range)
$creadPrec :: forall range. Read range => ReadPrec (IOTCM' range)
readList :: ReadS [IOTCM' range]
$creadList :: forall range. Read range => ReadS [IOTCM' range]
readsPrec :: Int -> ReadS (IOTCM' range)
$creadsPrec :: forall range. Read range => Int -> ReadS (IOTCM' range)
Read, forall a b. a -> IOTCM' b -> IOTCM' a
forall a b. (a -> b) -> IOTCM' a -> IOTCM' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> IOTCM' b -> IOTCM' a
$c<$ :: forall a b. a -> IOTCM' b -> IOTCM' a
fmap :: forall a b. (a -> b) -> IOTCM' a -> IOTCM' b
$cfmap :: forall a b. (a -> b) -> IOTCM' a -> IOTCM' b
Functor, forall a. Eq a => a -> IOTCM' a -> Bool
forall a. Num a => IOTCM' a -> a
forall a. Ord a => IOTCM' a -> a
forall m. Monoid m => IOTCM' m -> m
forall a. IOTCM' a -> Bool
forall a. IOTCM' a -> Int
forall a. IOTCM' a -> [a]
forall a. (a -> a -> a) -> IOTCM' a -> a
forall m a. Monoid m => (a -> m) -> IOTCM' a -> m
forall b a. (b -> a -> b) -> b -> IOTCM' a -> b
forall a b. (a -> b -> b) -> b -> IOTCM' 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 :: forall a. Num a => IOTCM' a -> a
$cproduct :: forall a. Num a => IOTCM' a -> a
sum :: forall a. Num a => IOTCM' a -> a
$csum :: forall a. Num a => IOTCM' a -> a
minimum :: forall a. Ord a => IOTCM' a -> a
$cminimum :: forall a. Ord a => IOTCM' a -> a
maximum :: forall a. Ord a => IOTCM' a -> a
$cmaximum :: forall a. Ord a => IOTCM' a -> a
elem :: forall a. Eq a => a -> IOTCM' a -> Bool
$celem :: forall a. Eq a => a -> IOTCM' a -> Bool
length :: forall a. IOTCM' a -> Int
$clength :: forall a. IOTCM' a -> Int
null :: forall a. IOTCM' a -> Bool
$cnull :: forall a. IOTCM' a -> Bool
toList :: forall a. IOTCM' a -> [a]
$ctoList :: forall a. IOTCM' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> IOTCM' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> IOTCM' a -> a
foldr1 :: forall a. (a -> a -> a) -> IOTCM' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> IOTCM' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> IOTCM' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> IOTCM' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> IOTCM' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> IOTCM' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> IOTCM' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> IOTCM' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> IOTCM' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> IOTCM' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> IOTCM' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> IOTCM' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> IOTCM' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> IOTCM' a -> m
fold :: forall m. Monoid m => IOTCM' m -> m
$cfold :: forall m. Monoid m => IOTCM' m -> m
Foldable, Functor IOTCM'
Foldable IOTCM'
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 => IOTCM' (m a) -> m (IOTCM' a)
forall (f :: * -> *) a.
Applicative f =>
IOTCM' (f a) -> f (IOTCM' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IOTCM' a -> m (IOTCM' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IOTCM' a -> f (IOTCM' b)
sequence :: forall (m :: * -> *) a. Monad m => IOTCM' (m a) -> m (IOTCM' a)
$csequence :: forall (m :: * -> *) a. Monad m => IOTCM' (m a) -> m (IOTCM' a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IOTCM' a -> m (IOTCM' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> IOTCM' a -> m (IOTCM' b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
IOTCM' (f a) -> f (IOTCM' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
IOTCM' (f a) -> f (IOTCM' a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IOTCM' a -> f (IOTCM' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IOTCM' a -> f (IOTCM' b)
Traversable)
data Remove
= Remove
| Keep
deriving (Int -> Remove -> ShowS
[Remove] -> ShowS
Remove -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Remove] -> ShowS
$cshowList :: [Remove] -> ShowS
show :: Remove -> String
$cshow :: Remove -> String
showsPrec :: Int -> Remove -> ShowS
$cshowsPrec :: Int -> Remove -> ShowS
Show, ReadPrec [Remove]
ReadPrec Remove
Int -> ReadS Remove
ReadS [Remove]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Remove]
$creadListPrec :: ReadPrec [Remove]
readPrec :: ReadPrec Remove
$creadPrec :: ReadPrec Remove
readList :: ReadS [Remove]
$creadList :: ReadS [Remove]
readsPrec :: Int -> ReadS Remove
$creadsPrec :: Int -> ReadS Remove
Read)
parseIOTCM ::
String -> Either String IOTCM
parseIOTCM :: String -> Either String IOTCM
parseIOTCM String
s = case forall a. [a] -> Maybe a
listToMaybe forall a b. (a -> b) -> a -> b
$ forall a. Read a => ReadS a
reads String
s of
Just (IOTCM' (Range' (Maybe RangeFile))
x, String
"") -> forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ \Maybe TopLevelModuleName
top -> case IOTCM' (Range' (Maybe RangeFile))
x of
IOTCM String
f HighlightingLevel
l HighlightingMethod
m Interaction' (Range' (Maybe RangeFile))
i -> forall range.
String
-> HighlightingLevel
-> HighlightingMethod
-> Interaction' range
-> IOTCM' range
IOTCM String
f HighlightingLevel
l HighlightingMethod
m forall a b. (a -> b) -> a -> b
$
(forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap) (\RangeFile
rf -> AbsolutePath -> Maybe TopLevelModuleName -> RangeFile
mkRangeFile (RangeFile -> AbsolutePath
rangeFilePath RangeFile
rf) Maybe TopLevelModuleName
top) Interaction' (Range' (Maybe RangeFile))
i
Just (IOTCM' (Range' (Maybe RangeFile))
_, String
rem) -> forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ String
"not consumed: " forall a. [a] -> [a] -> [a]
++ String
rem
Maybe (IOTCM' (Range' (Maybe RangeFile)), String)
_ -> forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ String
"cannot read: " forall a. [a] -> [a] -> [a]
++ String
s
type Parse a = ExceptT String (StateT String Identity) a
readsToParse :: String -> (String -> Maybe (a, String)) -> Parse a
readsToParse :: forall a. String -> (String -> Maybe (a, String)) -> Parse a
readsToParse String
s String -> Maybe (a, String)
f = do
String
st <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall s (m :: * -> *). MonadState s m => m s
get
case String -> Maybe (a, String)
f String
st of
Maybe (a, String)
Nothing -> forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError String
s
Just (a
a, String
st) -> do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *). MonadState s m => s -> m ()
put String
st
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
parseToReadsPrec :: Parse a -> Int -> String -> [(a, String)]
parseToReadsPrec :: forall a. Parse a -> Int -> String -> [(a, String)]
parseToReadsPrec Parse a
p Int
i String
s = case forall a. Identity a -> a
runIdentity forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> b -> a -> c
flip forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT String
s forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT forall a b. (a -> b) -> a -> b
$ forall a. Parse a -> Parse a
parens' Parse a
p of
(Right a
a, String
s) -> [(a
a,String
s)]
(Either String a, String)
_ -> []
exact :: String -> Parse ()
exact :: String -> ExceptT String (StateT String Identity) ()
exact String
s = forall a. String -> (String -> Maybe (a, String)) -> Parse a
readsToParse (forall a. Show a => a -> String
show String
s) forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((),) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a] -> Maybe [a]
List.stripPrefix String
s forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
dropWhile (forall a. Eq a => a -> a -> Bool
==Char
' ')
readParse :: Read a => Parse a
readParse :: forall a. Read a => Parse a
readParse = forall a. String -> (String -> Maybe (a, String)) -> Parse a
readsToParse String
"read failed" forall a b. (a -> b) -> a -> b
$ forall a. [a] -> Maybe a
listToMaybe forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Read a => ReadS a
reads
parens' :: Parse a -> Parse a
parens' :: forall a. Parse a -> Parse a
parens' Parse a
p = do
String -> ExceptT String (StateT String Identity) ()
exact String
"("
a
x <- Parse a
p
String -> ExceptT String (StateT String Identity) ()
exact String
")"
forall (m :: * -> *) a. Monad m => a -> m a
return a
x
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus`
Parse a
p
instance Read InteractionId where
readsPrec :: Int -> ReadS InteractionId
readsPrec = forall a. Parse a -> Int -> String -> [(a, String)]
parseToReadsPrec forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> InteractionId
InteractionId forall a. Read a => Parse a
readParse
instance Read a => Read (Range' a) where
readsPrec :: Int -> ReadS (Range' a)
readsPrec = forall a. Parse a -> Int -> String -> [(a, String)]
parseToReadsPrec forall a b. (a -> b) -> a -> b
$
(String -> ExceptT String (StateT String Identity) ()
exact String
"intervalsToRange" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 forall a. a -> [IntervalWithoutFile] -> Range' a
intervalsToRange forall a. Read a => Parse a
readParse forall a. Read a => Parse a
readParse)
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus`
(String -> ExceptT String (StateT String Identity) ()
exact String
"noRange" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Range' a
noRange)
instance Read a => Read (Interval' a) where
readsPrec :: Int -> ReadS (Interval' a)
readsPrec = forall a. Parse a -> Int -> String -> [(a, String)]
parseToReadsPrec forall a b. (a -> b) -> a -> b
$ do
String -> ExceptT String (StateT String Identity) ()
exact String
"Interval"
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 forall a. Position' a -> Position' a -> Interval' a
Interval forall a. Read a => Parse a
readParse forall a. Read a => Parse a
readParse
instance Read AbsolutePath where
readsPrec :: Int -> ReadS AbsolutePath
readsPrec = forall a. Parse a -> Int -> String -> [(a, String)]
parseToReadsPrec forall a b. (a -> b) -> a -> b
$ do
String -> ExceptT String (StateT String Identity) ()
exact String
"mkAbsolute"
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> AbsolutePath
mkAbsolute forall a. Read a => Parse a
readParse
instance Read RangeFile where
readsPrec :: Int -> ReadS RangeFile
readsPrec = forall a. Parse a -> Int -> String -> [(a, String)]
parseToReadsPrec forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b c. (a -> b -> c) -> b -> a -> c
flip AbsolutePath -> Maybe TopLevelModuleName -> RangeFile
mkRangeFile forall a. Maybe a
Nothing) forall a. Read a => Parse a
readParse
instance Read a => Read (Position' a) where
readsPrec :: Int -> ReadS (Position' a)
readsPrec = forall a. Parse a -> Int -> String -> [(a, String)]
parseToReadsPrec forall a b. (a -> b) -> a -> b
$ do
String -> ExceptT String (StateT String Identity) ()
exact String
"Pn"
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 forall a. a -> Int32 -> Int32 -> Int32 -> Position' a
Pn forall a. Read a => Parse a
readParse forall a. Read a => Parse a
readParse forall a. Read a => Parse a
readParse forall a. Read a => Parse a
readParse
data CompilerBackend = LaTeX | QuickLaTeX | OtherBackend String
deriving (CompilerBackend -> CompilerBackend -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompilerBackend -> CompilerBackend -> Bool
$c/= :: CompilerBackend -> CompilerBackend -> Bool
== :: CompilerBackend -> CompilerBackend -> Bool
$c== :: CompilerBackend -> CompilerBackend -> Bool
Eq)
instance Show CompilerBackend where
show :: CompilerBackend -> String
show = forall a. Pretty a => a -> String
prettyShow
instance Pretty CompilerBackend where
pretty :: CompilerBackend -> Doc
pretty = \case
CompilerBackend
LaTeX -> Doc
"LaTeX"
CompilerBackend
QuickLaTeX -> Doc
"QuickLaTeX"
OtherBackend String
s -> String -> Doc
text String
s
instance Read CompilerBackend where
readsPrec :: Int -> ReadS CompilerBackend
readsPrec Int
_ String
s = do
(String
t, String
s) <- ReadS String
lex String
s
let b :: CompilerBackend
b = case String
t of
String
"LaTeX" -> CompilerBackend
LaTeX
String
"QuickLaTeX" -> CompilerBackend
QuickLaTeX
String
_ -> String -> CompilerBackend
OtherBackend String
t
forall (m :: * -> *) a. Monad m => a -> m a
return (CompilerBackend
b, String
s)
data Rewrite = AsIs | Instantiated | HeadNormal | Simplified | Normalised
deriving (Int -> Rewrite -> ShowS
[Rewrite] -> ShowS
Rewrite -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rewrite] -> ShowS
$cshowList :: [Rewrite] -> ShowS
show :: Rewrite -> String
$cshow :: Rewrite -> String
showsPrec :: Int -> Rewrite -> ShowS
$cshowsPrec :: Int -> Rewrite -> ShowS
Show, ReadPrec [Rewrite]
ReadPrec Rewrite
Int -> ReadS Rewrite
ReadS [Rewrite]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Rewrite]
$creadListPrec :: ReadPrec [Rewrite]
readPrec :: ReadPrec Rewrite
$creadPrec :: ReadPrec Rewrite
readList :: ReadS [Rewrite]
$creadList :: ReadS [Rewrite]
readsPrec :: Int -> ReadS Rewrite
$creadsPrec :: Int -> ReadS Rewrite
Read, Rewrite -> Rewrite -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rewrite -> Rewrite -> Bool
$c/= :: Rewrite -> Rewrite -> Bool
== :: Rewrite -> Rewrite -> Bool
$c== :: Rewrite -> Rewrite -> Bool
Eq, Eq Rewrite
Rewrite -> Rewrite -> Bool
Rewrite -> Rewrite -> Ordering
Rewrite -> Rewrite -> Rewrite
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 :: Rewrite -> Rewrite -> Rewrite
$cmin :: Rewrite -> Rewrite -> Rewrite
max :: Rewrite -> Rewrite -> Rewrite
$cmax :: Rewrite -> Rewrite -> Rewrite
>= :: Rewrite -> Rewrite -> Bool
$c>= :: Rewrite -> Rewrite -> Bool
> :: Rewrite -> Rewrite -> Bool
$c> :: Rewrite -> Rewrite -> Bool
<= :: Rewrite -> Rewrite -> Bool
$c<= :: Rewrite -> Rewrite -> Bool
< :: Rewrite -> Rewrite -> Bool
$c< :: Rewrite -> Rewrite -> Bool
compare :: Rewrite -> Rewrite -> Ordering
$ccompare :: Rewrite -> Rewrite -> Ordering
Ord)
data ComputeMode = DefaultCompute | HeadCompute | IgnoreAbstract | UseShowInstance
deriving (Int -> ComputeMode -> ShowS
[ComputeMode] -> ShowS
ComputeMode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComputeMode] -> ShowS
$cshowList :: [ComputeMode] -> ShowS
show :: ComputeMode -> String
$cshow :: ComputeMode -> String
showsPrec :: Int -> ComputeMode -> ShowS
$cshowsPrec :: Int -> ComputeMode -> ShowS
Show, ReadPrec [ComputeMode]
ReadPrec ComputeMode
Int -> ReadS ComputeMode
ReadS [ComputeMode]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComputeMode]
$creadListPrec :: ReadPrec [ComputeMode]
readPrec :: ReadPrec ComputeMode
$creadPrec :: ReadPrec ComputeMode
readList :: ReadS [ComputeMode]
$creadList :: ReadS [ComputeMode]
readsPrec :: Int -> ReadS ComputeMode
$creadsPrec :: Int -> ReadS ComputeMode
Read, ComputeMode -> ComputeMode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComputeMode -> ComputeMode -> Bool
$c/= :: ComputeMode -> ComputeMode -> Bool
== :: ComputeMode -> ComputeMode -> Bool
$c== :: ComputeMode -> ComputeMode -> Bool
Eq)
data UseForce
= WithForce
| WithoutForce
deriving (UseForce -> UseForce -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UseForce -> UseForce -> Bool
$c/= :: UseForce -> UseForce -> Bool
== :: UseForce -> UseForce -> Bool
$c== :: UseForce -> UseForce -> Bool
Eq, ReadPrec [UseForce]
ReadPrec UseForce
Int -> ReadS UseForce
ReadS [UseForce]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UseForce]
$creadListPrec :: ReadPrec [UseForce]
readPrec :: ReadPrec UseForce
$creadPrec :: ReadPrec UseForce
readList :: ReadS [UseForce]
$creadList :: ReadS [UseForce]
readsPrec :: Int -> ReadS UseForce
$creadsPrec :: Int -> ReadS UseForce
Read, Int -> UseForce -> ShowS
[UseForce] -> ShowS
UseForce -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UseForce] -> ShowS
$cshowList :: [UseForce] -> ShowS
show :: UseForce -> String
$cshow :: UseForce -> String
showsPrec :: Int -> UseForce -> ShowS
$cshowsPrec :: Int -> UseForce -> ShowS
Show)
data OutputForm a b = OutputForm Range [ProblemId] Blocker (OutputConstraint a b)
deriving (forall a b. a -> OutputForm a b -> OutputForm a a
forall a b. (a -> b) -> OutputForm a a -> OutputForm a b
forall a a b. a -> OutputForm a b -> OutputForm a a
forall a a b. (a -> b) -> OutputForm a a -> OutputForm a b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> OutputForm a b -> OutputForm a a
$c<$ :: forall a a b. a -> OutputForm a b -> OutputForm a a
fmap :: forall a b. (a -> b) -> OutputForm a a -> OutputForm a b
$cfmap :: forall a a b. (a -> b) -> OutputForm a a -> OutputForm a b
Functor)
data OutputConstraint a b
= OfType b a | CmpInType Comparison a b b
| CmpElim [Polarity] a [b] [b]
| JustType b | CmpTypes Comparison b b
| CmpLevels Comparison b b
| CmpTeles Comparison b b
| JustSort b | CmpSorts Comparison b b
| Assign b a | TypedAssign b a a | PostponedCheckArgs b [a] a a
| IsEmptyType a
| SizeLtSat a
| FindInstanceOF b a [(a,a,a)]
| PTSInstance b b
| PostponedCheckFunDef QName a TCErr
| CheckLock b b
| DataSort QName b
| UsableAtMod Modality b
deriving (forall a b. a -> OutputConstraint a b -> OutputConstraint a a
forall a b.
(a -> b) -> OutputConstraint a a -> OutputConstraint a b
forall a a b. a -> OutputConstraint a b -> OutputConstraint a a
forall a a b.
(a -> b) -> OutputConstraint a a -> OutputConstraint a b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> OutputConstraint a b -> OutputConstraint a a
$c<$ :: forall a a b. a -> OutputConstraint a b -> OutputConstraint a a
fmap :: forall a b.
(a -> b) -> OutputConstraint a a -> OutputConstraint a b
$cfmap :: forall a a b.
(a -> b) -> OutputConstraint a a -> OutputConstraint a b
Functor)
data OutputConstraint' a b = OfType'
{ forall a b. OutputConstraint' a b -> b
ofName :: b
, forall a b. OutputConstraint' a b -> a
ofExpr :: a
}
data OutputContextEntry name ty val
= ContextVar name ty
| ContextLet name ty val