agda2train
Safe HaskellSafe-Inferred
LanguageHaskell2010

Output

Description

Defines the structure of the training data, as well as how to translate internal Agda definition to this format.

Synopsis

Types

type Name = String Source #

Name identifiers.

type DB = Int Source #

DeBruijn indices.

type Head = Either Name DB Source #

A head of a λ-application can either be a defined name in the global scope, or a DeBruijn index into the local context.

Generic constructions

pattern (:>) :: String -> a -> Pretty a infixr 4 Source #

data Pretty a Source #

Bundle a thing with its "pretty" version.

NB: In JSON format, we follow a shallow encoding with "pretty" being an additional field and "thing" just inlined in the top-level record.

Constructors

Pretty 

Fields

Instances

Instances details
Telescope ~> Telescope Source # 
Instance details

Defined in Output

Methods

convert :: Telescope0 -> TCM Telescope Source #

go :: Telescope0 -> TCM Telescope Source #

FromJSON a => FromJSON (Pretty a) Source # 
Instance details

Defined in Output

Methods

parseJSON :: Value -> Parser (Pretty a)

parseJSONList :: Value -> Parser [Pretty a]

ToJSON a => ToJSON (Pretty a) Source # 
Instance details

Defined in Output

Methods

toJSON :: Pretty a -> Value

toEncoding :: Pretty a -> Encoding

toJSONList :: [Pretty a] -> Value

toEncodingList :: [Pretty a] -> Encoding

Generic (Pretty a) Source # 
Instance details

Defined in Output

Associated Types

type Rep (Pretty a) :: Type -> Type #

Methods

from :: Pretty a -> Rep (Pretty a) x #

to :: Rep (Pretty a) x -> Pretty a #

Show a => Show (Pretty a) Source # 
Instance details

Defined in Output

Methods

showsPrec :: Int -> Pretty a -> ShowS #

show :: Pretty a -> String #

showList :: [Pretty a] -> ShowS #

type Rep (Pretty a) Source # 
Instance details

Defined in Output

data Reduced a Source #

Bundle a term with (several of) its normalised forms.

We do not repeat identical elements in subsequent evaluations (in the order simprednorm) and some fields may not be populated due to the evaluation taking to long and leading to a timeout (currently 2 seconds).

NB: Like Named, encoded in a shallow JSON.

Constructors

Reduced 

Fields

Instances

Instances details
Foldable Reduced Source # 
Instance details

Defined in Output

Methods

fold :: Monoid m => Reduced m -> m #

foldMap :: Monoid m => (a -> m) -> Reduced a -> m #

foldMap' :: Monoid m => (a -> m) -> Reduced a -> m #

foldr :: (a -> b -> b) -> b -> Reduced a -> b #

foldr' :: (a -> b -> b) -> b -> Reduced a -> b #

foldl :: (b -> a -> b) -> b -> Reduced a -> b #

foldl' :: (b -> a -> b) -> b -> Reduced a -> b #

foldr1 :: (a -> a -> a) -> Reduced a -> a #

foldl1 :: (a -> a -> a) -> Reduced a -> a #

toList :: Reduced a -> [a] #

null :: Reduced a -> Bool #

length :: Reduced a -> Int #

elem :: Eq a => a -> Reduced a -> Bool #

maximum :: Ord a => Reduced a -> a #

minimum :: Ord a => Reduced a -> a #

sum :: Num a => Reduced a -> a #

product :: Num a => Reduced a -> a #

Traversable Reduced Source # 
Instance details

Defined in Output

Methods

traverse :: Applicative f => (a -> f b) -> Reduced a -> f (Reduced b) #

sequenceA :: Applicative f => Reduced (f a) -> f (Reduced a) #

mapM :: Monad m => (a -> m b) -> Reduced a -> m (Reduced b) #

sequence :: Monad m => Reduced (m a) -> m (Reduced a) #

Functor Reduced Source # 
Instance details

Defined in Output

Methods

fmap :: (a -> b) -> Reduced a -> Reduced b #

(<$) :: a -> Reduced b -> Reduced a #

FromJSON a => FromJSON (Reduced a) Source # 
Instance details

Defined in Output

Methods

parseJSON :: Value -> Parser (Reduced a)

parseJSONList :: Value -> Parser [Reduced a]

ToJSON a => ToJSON (Reduced a) Source # 
Instance details

Defined in Output

Methods

toJSON :: Reduced a -> Value

toEncoding :: Reduced a -> Encoding

toJSONList :: [Reduced a] -> Value

toEncodingList :: [Reduced a] -> Encoding

Generic (Reduced a) Source # 
Instance details

Defined in Output

Associated Types

type Rep (Reduced a) :: Type -> Type #

Methods

from :: Reduced a -> Rep (Reduced a) x #

to :: Rep (Reduced a) x -> Reduced a #

Show a => Show (Reduced a) Source # 
Instance details

Defined in Output

Methods

showsPrec :: Int -> Reduced a -> ShowS #

show :: Reduced a -> String #

showList :: [Reduced a] -> ShowS #

type Rep (Reduced a) Source # 
Instance details

Defined in Output

pattern (:~) :: Name -> a -> Named a infixr 4 Source #

data Named a Source #

Bundle a thing with its name.

NB: Like Named and Reduced, encoded in a shallow JSON.

Constructors

Named 

Fields

Instances

Instances details
Telescope ~> Telescope Source # 
Instance details

Defined in Output

Methods

convert :: Telescope0 -> TCM Telescope Source #

go :: Telescope0 -> TCM Telescope Source #

FromJSON a => FromJSON (Named a) Source # 
Instance details

Defined in Output

Methods

parseJSON :: Value -> Parser (Named a)

parseJSONList :: Value -> Parser [Named a]

ToJSON a => ToJSON (Named a) Source # 
Instance details

Defined in Output

Methods

toJSON :: Named a -> Value

toEncoding :: Named a -> Encoding

toJSONList :: [Named a] -> Value

toEncodingList :: [Named a] -> Encoding

Generic (Named a) Source # 
Instance details

Defined in Output

Associated Types

type Rep (Named a) :: Type -> Type #

Methods

from :: Named a -> Rep (Named a) x #

to :: Rep (Named a) x -> Named a #

Show a => Show (Named a) Source # 
Instance details

Defined in Output

Methods

showsPrec :: Int -> Named a -> ShowS #

show :: Named a -> String #

showList :: [Named a] -> ShowS #

type Rep (Named a) Source # 
Instance details

Defined in Output

Concrete types (~ JSON schema)

type FileData = Named TrainData Source #

Data for a file include the filename and its training data.

data TrainData Source #

The training data for a module, divided into three parts.

Constructors

TrainData 

Fields

  • scopeGlobal :: [ScopeEntry]

    The global scope, giving the types and definitions of all import statements.

    NB: does not contain any holes for subterms.

  • scopeLocal :: [ScopeEntry]

    The local scope, containing the types, definitions, and training data for each of this module's definitions.

  • scopePrivate :: Maybe [ScopeEntry]

    The private scope, containing private definitions not exported to the public, as well as system-generated definitions stemming from where or with.

Instances

Instances details
FromJSON TrainData Source # 
Instance details

Defined in Output

Methods

parseJSON :: Value -> Parser TrainData

parseJSONList :: Value -> Parser [TrainData]

ToJSON TrainData Source # 
Instance details

Defined in Output

Methods

toJSON :: TrainData -> Value

toEncoding :: TrainData -> Encoding

toJSONList :: [TrainData] -> Value

toEncodingList :: [TrainData] -> Encoding

Generic TrainData Source # 
Instance details

Defined in Output

Associated Types

type Rep TrainData :: Type -> Type #

type Rep TrainData Source # 
Instance details

Defined in Output

data ScopeEntry' Source #

An entry in the scope: type, definitions, and holes.

Constructors

ScopeEntry 

Fields

Instances

Instances details
FromJSON ScopeEntry' Source # 
Instance details

Defined in Output

Methods

parseJSON :: Value -> Parser ScopeEntry'

parseJSONList :: Value -> Parser [ScopeEntry']

ToJSON ScopeEntry' Source # 
Instance details

Defined in Output

Methods

toJSON :: ScopeEntry' -> Value

toEncoding :: ScopeEntry' -> Encoding

toJSONList :: [ScopeEntry'] -> Value

toEncodingList :: [ScopeEntry'] -> Encoding

Generic ScopeEntry' Source # 
Instance details

Defined in Output

Associated Types

type Rep ScopeEntry' :: Type -> Type #

Show ScopeEntry' Source # 
Instance details

Defined in Output

type Rep ScopeEntry' Source # 
Instance details

Defined in Output

data Sample Source #

The training sample for each sub-hole.

Constructors

Sample 

Fields

Instances

Instances details
FromJSON Sample Source # 
Instance details

Defined in Output

Methods

parseJSON :: Value -> Parser Sample

parseJSONList :: Value -> Parser [Sample]

ToJSON Sample Source # 
Instance details

Defined in Output

Methods

toJSON :: Sample -> Value

toEncoding :: Sample -> Encoding

toJSONList :: [Sample] -> Value

toEncodingList :: [Sample] -> Encoding

Generic Sample Source # 
Instance details

Defined in Output

Associated Types

type Rep Sample :: Type -> Type #

Methods

from :: Sample -> Rep Sample x #

to :: Rep Sample x -> Sample #

Show Sample Source # 
Instance details

Defined in Output

type Rep Sample Source # 
Instance details

Defined in Output

data Definition Source #

Agda definitions: datatypes, records, functions, postulates and primitives.

Constructors

ADT

e.g. data ℕ : Set where zero : ℕ suc : ℕ → ℕ

Fields

Constructor

e.g. `(ℕ, 0) ~ zero` or `(ℕ, 1) ~ suc`

Fields

Record

e.g. record X : Set where field x : ℕ y : ℕ

Fields

Function

e.g. f [] = [] f (x ∷ xs) = x ∷ x ∷ xs

Fields

Postulate

e.g. `postulate pred : ℕ → ℕ`

Primitive

e.g. `primitive primShowNat : ℕ → String`

Instances

Instances details
FromJSON Definition Source # 
Instance details

Defined in Output

Methods

parseJSON :: Value -> Parser Definition

parseJSONList :: Value -> Parser [Definition]

ToJSON Definition Source # 
Instance details

Defined in Output

Methods

toJSON :: Definition -> Value

toEncoding :: Definition -> Encoding

toJSONList :: [Definition] -> Value

toEncodingList :: [Definition] -> Encoding

Generic Definition Source # 
Instance details

Defined in Output

Associated Types

type Rep Definition :: Type -> Type #

Show Definition Source # 
Instance details

Defined in Output

Definition ~> Definition Source # 
Instance details

Defined in Output

Methods

convert :: Definition0 -> TCM Definition Source #

go :: Definition0 -> TCM Definition Source #

Defn ~> Definition Source # 
Instance details

Defined in Output

Methods

convert :: Defn -> TCM Definition Source #

go :: Defn -> TCM Definition Source #

type Rep Definition Source # 
Instance details

Defined in Output

data Clause Source #

Function clauses.

Constructors

Clause 

Fields

Instances

Instances details
FromJSON Clause Source # 
Instance details

Defined in Output

Methods

parseJSON :: Value -> Parser Clause

parseJSONList :: Value -> Parser [Clause]

ToJSON Clause Source # 
Instance details

Defined in Output

Methods

toJSON :: Clause -> Value

toEncoding :: Clause -> Encoding

toJSONList :: [Clause] -> Value

toEncodingList :: [Clause] -> Encoding

Generic Clause Source # 
Instance details

Defined in Output

Associated Types

type Rep Clause :: Type -> Type #

Methods

from :: Clause -> Rep Clause x #

to :: Rep Clause x -> Clause #

Show Clause Source # 
Instance details

Defined in Output

Clause ~> Clause Source # 
Instance details

Defined in Output

Methods

convert :: Clause0 -> TCM Clause Source #

go :: Clause0 -> TCM Clause Source #

type Rep Clause Source # 
Instance details

Defined in Output

type Telescope = [Named (Pretty Type)] Source #

A telescope is a sequence of (named) types, a.k.a. bindings.

type Pattern = Term Source #

We under-approximate patterns as terms, e.g. losing information about forced patterns.

type Type = Term Source #

Types are the same as terms.

data Term Source #

The AST of Agda terms.

Constructors

Pi Bool (Named Term) Term

e.g. ∀ {A : Set}. A → A

Lam (Named Term)

e.g. λ x. x

App Head [Term]

e.g. f x (x + x) or @0 (λ x. x)

Lit String

e.g. 42 or "something"

Sort String

e.g. Set

Level String

e.g. 0ℓ

UnsolvedMeta

i.e. {!!}

Instances

Instances details
FromJSON Term Source # 
Instance details

Defined in Output

Methods

parseJSON :: Value -> Parser Term

parseJSONList :: Value -> Parser [Term]

ToJSON Term Source # 
Instance details

Defined in Output

Methods

toJSON :: Term -> Value

toEncoding :: Term -> Encoding

toJSONList :: [Term] -> Value

toEncodingList :: [Term] -> Encoding

Generic Term Source # 
Instance details

Defined in Output

Associated Types

type Rep Term :: Type -> Type #

Methods

from :: Term -> Rep Term x #

to :: Rep Term x -> Term #

Show Term Source # 
Instance details

Defined in Output

Methods

showsPrec :: Int -> Term -> ShowS #

show :: Term -> String #

showList :: [Term] -> ShowS #

DeBruijnPattern ~> Pattern Source # 
Instance details

Defined in Output

Methods

convert :: DeBruijnPattern -> TCM Pattern Source #

go :: DeBruijnPattern -> TCM Pattern Source #

Elim ~> Term Source # 
Instance details

Defined in Output

Methods

convert :: Elim -> TCM Term Source #

go :: Elim -> TCM Term Source #

Telescope ~> Telescope Source # 
Instance details

Defined in Output

Methods

convert :: Telescope0 -> TCM Telescope Source #

go :: Telescope0 -> TCM Telescope Source #

Term ~> Term Source # 
Instance details

Defined in Output

Methods

convert :: Term0 -> TCM Term Source #

go :: Term0 -> TCM Term Source #

Type ~> Type Source # 
Instance details

Defined in Output

Methods

convert :: Type0 -> TCM Type Source #

go :: Type0 -> TCM Type Source #

type Rep Term Source # 
Instance details

Defined in Output

Conversion from Agda's internal syntax

class a ~> b | a -> b where Source #

Converting between two types a and b under Agda's typechecking monad.

NB: go is only used internally to de-clutter the recursive calls.

Minimal complete definition

go

Methods

convert :: a -> TCM b Source #

go :: a -> TCM b Source #

Instances

Instances details
Clause ~> Clause Source # 
Instance details

Defined in Output

Methods

convert :: Clause0 -> TCM Clause Source #

go :: Clause0 -> TCM Clause Source #

DeBruijnPattern ~> Pattern Source # 
Instance details

Defined in Output

Methods

convert :: DeBruijnPattern -> TCM Pattern Source #

go :: DeBruijnPattern -> TCM Pattern Source #

Elim ~> Term Source # 
Instance details

Defined in Output

Methods

convert :: Elim -> TCM Term Source #

go :: Elim -> TCM Term Source #

Telescope ~> Telescope Source # 
Instance details

Defined in Output

Methods

convert :: Telescope0 -> TCM Telescope Source #

go :: Telescope0 -> TCM Telescope Source #

Term ~> Term Source # 
Instance details

Defined in Output

Methods

convert :: Term0 -> TCM Term Source #

go :: Term0 -> TCM Term Source #

Type ~> Type Source # 
Instance details

Defined in Output

Methods

convert :: Type0 -> TCM Type Source #

go :: Type0 -> TCM Type Source #

Definition ~> Definition Source # 
Instance details

Defined in Output

Methods

convert :: Definition0 -> TCM Definition Source #

go :: Definition0 -> TCM Definition Source #

Defn ~> Definition Source # 
Instance details

Defined in Output

Methods

convert :: Defn -> TCM Definition Source #

go :: Defn -> TCM Definition Source #

Utilities

pp :: Pretty a => a -> String Source #

ppm :: (MonadPretty m, PrettyTCM a) => a -> m Doc Source #

pinterleave :: (Applicative m, Semigroup (m Doc)) => m Doc -> [m Doc] -> m Doc Source #

pbindings :: (MonadPretty m, PrettyTCM a) => [(String, a)] -> [m Doc] Source #

report :: MonadTCM m => VerboseLevel -> TCM Doc -> m () Source #

panic :: (Pretty a, Show a) => String -> a -> b Source #

ppName :: QName -> String Source #

unqualify :: QName -> String Source #

(\/) :: (a -> Bool) -> (a -> Bool) -> a -> Bool Source #

isNotCubical :: Clause -> Bool Source #

jsonOpts :: Options Source #

Configure JSON to omit empty (optional) fields and switch from camelCase to kebab-case.

Orphan instances

PrettyTCM Definition Source # 
Instance details

Methods

prettyTCM :: MonadPretty m => Definition -> m Doc