{-# LANGUAGE OverloadedStrings #-}

{- |
Module      : Control.Lens.Grammar.TypeScript
Description : TypeScript declaration files, as a grammar
Copyright   : (C) 2026 - Eitan Chatav
License     : BSD-style (see the file LICENSE)
Maintainer  : Eitan Chatav <eitan.chatav@gmail.com>
Stability   : provisional
Portability : non-portable

TypeScript's declaration files, @.d.ts@, like the TypeScript compiler,
in two layers: `tsTokensGrammar` of their tokens, by their
`TsTokenCategory`s, & `tsGrammar` of their declarations, of those tokens,
by the compiler's names of their nodes, so that they parse & print
together.

Both layers parse by `parsecG` & print by `unparsecG`, locating failures,
since `tsTokensGrammar` scans tokens without their trivia, as the compiler
does. `tsGrammar` isn't @LL(1)@: it backtracks, by `try`, where TypeScript's
syntax needs more lookahead. Here, a declaration prints as tokens,
& as characters, & parses back.

>>> :set -XOverloadedStrings
>>> let point = ObjectType [PropertySignature [] (PropertyIdentifier "x") False (Just (KeywordType NumberKeyword))]
>>> let printed = unparsecG tsGrammar [TypeAliasDeclaration [ExportKeyword] "Point" [] point] ([] :: [TsToken])
>>> let source = parsecStream (unparsecG tsTokensGrammar (parsecStream printed) ("" :: String))
>>> putStr source
export type Point = { x: number };
>>> parsecResult (parsecG tsGrammar (concat (parsecResult (parsecG tsTokensGrammar source)))) == Just [TypeAliasDeclaration [ExportKeyword] "Point" [] point]
True
-}

module Control.Lens.Grammar.TypeScript
  ( -- * Grammar
    tsGrammar
  , tsTokenGrammar
  , tsTokensGrammar
    -- * Declarations
  , TsDeclaration (..)
  , TsModuleName (..)
  , TsImportClause (..)
  , TsNamedBindings (..)
  , TsImportSpecifier (..)
  , TsModuleReference (..)
  , TsExportClause (..)
  , TsVariableDeclaration (..)
  , TsEnumMember (..)
  , TsHeritage (..)
  , TsEntityName
    -- * Types
  , TsType (..)
  , TsProperty (..)
  , TsPropertyName (..)
  , TsLiteral (..)
  , TsTypeParameter (..)
  , TsSignature (..)
  , TsParameter (..)
  , TsBindingName (..)
  , TsBindingElement (..)
    -- * Tokens
  , TsToken (..)
  , TsTokenCategory (..)
  ) where

import Control.Lens
import Control.Lens.Grammar
import Data.Char (chr, ord)
import Data.Maybe (fromMaybe, listToMaybe)
import Data.Profunctor.Monadic.Do qualified as P
import Data.Text (Text)
import Data.Text qualified as Text
import Numeric (readHex, showHex)

-- $setup
-- >>> import Control.Lens.Grammar

-- Declarations --

{- | A declaration of a declaration file, by the TypeScript compiler's
name of its node, most with its modifiers, like @export@ & @declare@.
-}
data TsDeclaration
  = TypeAliasDeclaration [TsTokenCategory] Text [TsTypeParameter] TsType
  -- ^ @type T\<U> = V;@
  | InterfaceDeclaration
      [TsTokenCategory] Text [TsTypeParameter] [TsHeritage] [TsProperty]
  -- ^ @interface I\<T> extends J { … }@
  | ClassDeclaration
      [TsTokenCategory] Text [TsTypeParameter]
      (Maybe TsHeritage) [TsHeritage] [TsProperty]
  -- ^ @class C\<T> extends D implements I { … }@
  | FunctionDeclaration [TsTokenCategory] Text TsSignature
  -- ^ @function f\<T>(x: T): U;@
  | VariableStatement
      [TsTokenCategory] TsTokenCategory [TsVariableDeclaration]
  -- ^ @const x: T;@, by @var@, @let@ or @const@
  | EnumDeclaration [TsTokenCategory] Text [TsEnumMember]
  -- ^ @enum E { A, B = 1 }@
  | ModuleDeclaration [TsTokenCategory] TsModuleName (Maybe [TsDeclaration])
  -- ^ @namespace N { … }@, @module "m" { … }@ or @global { … }@
  | ImportDeclaration Bool (Maybe TsImportClause) Text
  -- ^ @import type { A } from "m";@, of types only or not
  | ImportEqualsDeclaration [TsTokenCategory] Bool Text TsModuleReference
  -- ^ @import x = require("m");@, of types only or not
  | ExportDeclaration Bool TsExportClause (Maybe Text)
  -- ^ @export type { A } from "m";@, of types only or not
  | ExportAssignment Bool TsEntityName
  -- ^ @export = x;@, or else @export default x;@
  | NamespaceExportDeclaration Text
  -- ^ @export as namespace N;@
  deriving stock (TsDeclaration -> TsDeclaration -> Bool
(TsDeclaration -> TsDeclaration -> Bool)
-> (TsDeclaration -> TsDeclaration -> Bool) -> Eq TsDeclaration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsDeclaration -> TsDeclaration -> Bool
== :: TsDeclaration -> TsDeclaration -> Bool
$c/= :: TsDeclaration -> TsDeclaration -> Bool
/= :: TsDeclaration -> TsDeclaration -> Bool
Eq, Eq TsDeclaration
Eq TsDeclaration =>
(TsDeclaration -> TsDeclaration -> Ordering)
-> (TsDeclaration -> TsDeclaration -> Bool)
-> (TsDeclaration -> TsDeclaration -> Bool)
-> (TsDeclaration -> TsDeclaration -> Bool)
-> (TsDeclaration -> TsDeclaration -> Bool)
-> (TsDeclaration -> TsDeclaration -> TsDeclaration)
-> (TsDeclaration -> TsDeclaration -> TsDeclaration)
-> Ord TsDeclaration
TsDeclaration -> TsDeclaration -> Bool
TsDeclaration -> TsDeclaration -> Ordering
TsDeclaration -> TsDeclaration -> TsDeclaration
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
$ccompare :: TsDeclaration -> TsDeclaration -> Ordering
compare :: TsDeclaration -> TsDeclaration -> Ordering
$c< :: TsDeclaration -> TsDeclaration -> Bool
< :: TsDeclaration -> TsDeclaration -> Bool
$c<= :: TsDeclaration -> TsDeclaration -> Bool
<= :: TsDeclaration -> TsDeclaration -> Bool
$c> :: TsDeclaration -> TsDeclaration -> Bool
> :: TsDeclaration -> TsDeclaration -> Bool
$c>= :: TsDeclaration -> TsDeclaration -> Bool
>= :: TsDeclaration -> TsDeclaration -> Bool
$cmax :: TsDeclaration -> TsDeclaration -> TsDeclaration
max :: TsDeclaration -> TsDeclaration -> TsDeclaration
$cmin :: TsDeclaration -> TsDeclaration -> TsDeclaration
min :: TsDeclaration -> TsDeclaration -> TsDeclaration
Ord, Int -> TsDeclaration -> ShowS
[TsDeclaration] -> ShowS
TsDeclaration -> String
(Int -> TsDeclaration -> ShowS)
-> (TsDeclaration -> String)
-> ([TsDeclaration] -> ShowS)
-> Show TsDeclaration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsDeclaration -> ShowS
showsPrec :: Int -> TsDeclaration -> ShowS
$cshow :: TsDeclaration -> String
show :: TsDeclaration -> String
$cshowList :: [TsDeclaration] -> ShowS
showList :: [TsDeclaration] -> ShowS
Show, ReadPrec [TsDeclaration]
ReadPrec TsDeclaration
Int -> ReadS TsDeclaration
ReadS [TsDeclaration]
(Int -> ReadS TsDeclaration)
-> ReadS [TsDeclaration]
-> ReadPrec TsDeclaration
-> ReadPrec [TsDeclaration]
-> Read TsDeclaration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsDeclaration
readsPrec :: Int -> ReadS TsDeclaration
$creadList :: ReadS [TsDeclaration]
readList :: ReadS [TsDeclaration]
$creadPrec :: ReadPrec TsDeclaration
readPrec :: ReadPrec TsDeclaration
$creadListPrec :: ReadPrec [TsDeclaration]
readListPrec :: ReadPrec [TsDeclaration]
Read)

-- | The name of a `ModuleDeclaration`.
data TsModuleName
  = NamespaceName TsEntityName -- ^ @namespace N.M@
  | ModuleName TsEntityName -- ^ @module N.M@
  | ExternalModuleName Text -- ^ @module "m"@
  | GlobalAugmentation -- ^ @global@
  deriving stock (TsModuleName -> TsModuleName -> Bool
(TsModuleName -> TsModuleName -> Bool)
-> (TsModuleName -> TsModuleName -> Bool) -> Eq TsModuleName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsModuleName -> TsModuleName -> Bool
== :: TsModuleName -> TsModuleName -> Bool
$c/= :: TsModuleName -> TsModuleName -> Bool
/= :: TsModuleName -> TsModuleName -> Bool
Eq, Eq TsModuleName
Eq TsModuleName =>
(TsModuleName -> TsModuleName -> Ordering)
-> (TsModuleName -> TsModuleName -> Bool)
-> (TsModuleName -> TsModuleName -> Bool)
-> (TsModuleName -> TsModuleName -> Bool)
-> (TsModuleName -> TsModuleName -> Bool)
-> (TsModuleName -> TsModuleName -> TsModuleName)
-> (TsModuleName -> TsModuleName -> TsModuleName)
-> Ord TsModuleName
TsModuleName -> TsModuleName -> Bool
TsModuleName -> TsModuleName -> Ordering
TsModuleName -> TsModuleName -> TsModuleName
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
$ccompare :: TsModuleName -> TsModuleName -> Ordering
compare :: TsModuleName -> TsModuleName -> Ordering
$c< :: TsModuleName -> TsModuleName -> Bool
< :: TsModuleName -> TsModuleName -> Bool
$c<= :: TsModuleName -> TsModuleName -> Bool
<= :: TsModuleName -> TsModuleName -> Bool
$c> :: TsModuleName -> TsModuleName -> Bool
> :: TsModuleName -> TsModuleName -> Bool
$c>= :: TsModuleName -> TsModuleName -> Bool
>= :: TsModuleName -> TsModuleName -> Bool
$cmax :: TsModuleName -> TsModuleName -> TsModuleName
max :: TsModuleName -> TsModuleName -> TsModuleName
$cmin :: TsModuleName -> TsModuleName -> TsModuleName
min :: TsModuleName -> TsModuleName -> TsModuleName
Ord, Int -> TsModuleName -> ShowS
[TsModuleName] -> ShowS
TsModuleName -> String
(Int -> TsModuleName -> ShowS)
-> (TsModuleName -> String)
-> ([TsModuleName] -> ShowS)
-> Show TsModuleName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsModuleName -> ShowS
showsPrec :: Int -> TsModuleName -> ShowS
$cshow :: TsModuleName -> String
show :: TsModuleName -> String
$cshowList :: [TsModuleName] -> ShowS
showList :: [TsModuleName] -> ShowS
Show, ReadPrec [TsModuleName]
ReadPrec TsModuleName
Int -> ReadS TsModuleName
ReadS [TsModuleName]
(Int -> ReadS TsModuleName)
-> ReadS [TsModuleName]
-> ReadPrec TsModuleName
-> ReadPrec [TsModuleName]
-> Read TsModuleName
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsModuleName
readsPrec :: Int -> ReadS TsModuleName
$creadList :: ReadS [TsModuleName]
readList :: ReadS [TsModuleName]
$creadPrec :: ReadPrec TsModuleName
readPrec :: ReadPrec TsModuleName
$creadListPrec :: ReadPrec [TsModuleName]
readListPrec :: ReadPrec [TsModuleName]
Read)

-- | The imports of an `ImportDeclaration`, by default & by name.
data TsImportClause = TsImportClause (Maybe Text) (Maybe TsNamedBindings)
  deriving stock (TsImportClause -> TsImportClause -> Bool
(TsImportClause -> TsImportClause -> Bool)
-> (TsImportClause -> TsImportClause -> Bool) -> Eq TsImportClause
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsImportClause -> TsImportClause -> Bool
== :: TsImportClause -> TsImportClause -> Bool
$c/= :: TsImportClause -> TsImportClause -> Bool
/= :: TsImportClause -> TsImportClause -> Bool
Eq, Eq TsImportClause
Eq TsImportClause =>
(TsImportClause -> TsImportClause -> Ordering)
-> (TsImportClause -> TsImportClause -> Bool)
-> (TsImportClause -> TsImportClause -> Bool)
-> (TsImportClause -> TsImportClause -> Bool)
-> (TsImportClause -> TsImportClause -> Bool)
-> (TsImportClause -> TsImportClause -> TsImportClause)
-> (TsImportClause -> TsImportClause -> TsImportClause)
-> Ord TsImportClause
TsImportClause -> TsImportClause -> Bool
TsImportClause -> TsImportClause -> Ordering
TsImportClause -> TsImportClause -> TsImportClause
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
$ccompare :: TsImportClause -> TsImportClause -> Ordering
compare :: TsImportClause -> TsImportClause -> Ordering
$c< :: TsImportClause -> TsImportClause -> Bool
< :: TsImportClause -> TsImportClause -> Bool
$c<= :: TsImportClause -> TsImportClause -> Bool
<= :: TsImportClause -> TsImportClause -> Bool
$c> :: TsImportClause -> TsImportClause -> Bool
> :: TsImportClause -> TsImportClause -> Bool
$c>= :: TsImportClause -> TsImportClause -> Bool
>= :: TsImportClause -> TsImportClause -> Bool
$cmax :: TsImportClause -> TsImportClause -> TsImportClause
max :: TsImportClause -> TsImportClause -> TsImportClause
$cmin :: TsImportClause -> TsImportClause -> TsImportClause
min :: TsImportClause -> TsImportClause -> TsImportClause
Ord, Int -> TsImportClause -> ShowS
[TsImportClause] -> ShowS
TsImportClause -> String
(Int -> TsImportClause -> ShowS)
-> (TsImportClause -> String)
-> ([TsImportClause] -> ShowS)
-> Show TsImportClause
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsImportClause -> ShowS
showsPrec :: Int -> TsImportClause -> ShowS
$cshow :: TsImportClause -> String
show :: TsImportClause -> String
$cshowList :: [TsImportClause] -> ShowS
showList :: [TsImportClause] -> ShowS
Show, ReadPrec [TsImportClause]
ReadPrec TsImportClause
Int -> ReadS TsImportClause
ReadS [TsImportClause]
(Int -> ReadS TsImportClause)
-> ReadS [TsImportClause]
-> ReadPrec TsImportClause
-> ReadPrec [TsImportClause]
-> Read TsImportClause
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsImportClause
readsPrec :: Int -> ReadS TsImportClause
$creadList :: ReadS [TsImportClause]
readList :: ReadS [TsImportClause]
$creadPrec :: ReadPrec TsImportClause
readPrec :: ReadPrec TsImportClause
$creadListPrec :: ReadPrec [TsImportClause]
readListPrec :: ReadPrec [TsImportClause]
Read)

-- | Imports by name.
data TsNamedBindings
  = NamespaceImport Text -- ^ @* as n@
  | NamedImports [TsImportSpecifier] -- ^ @{ a, b as c }@
  deriving stock (TsNamedBindings -> TsNamedBindings -> Bool
(TsNamedBindings -> TsNamedBindings -> Bool)
-> (TsNamedBindings -> TsNamedBindings -> Bool)
-> Eq TsNamedBindings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsNamedBindings -> TsNamedBindings -> Bool
== :: TsNamedBindings -> TsNamedBindings -> Bool
$c/= :: TsNamedBindings -> TsNamedBindings -> Bool
/= :: TsNamedBindings -> TsNamedBindings -> Bool
Eq, Eq TsNamedBindings
Eq TsNamedBindings =>
(TsNamedBindings -> TsNamedBindings -> Ordering)
-> (TsNamedBindings -> TsNamedBindings -> Bool)
-> (TsNamedBindings -> TsNamedBindings -> Bool)
-> (TsNamedBindings -> TsNamedBindings -> Bool)
-> (TsNamedBindings -> TsNamedBindings -> Bool)
-> (TsNamedBindings -> TsNamedBindings -> TsNamedBindings)
-> (TsNamedBindings -> TsNamedBindings -> TsNamedBindings)
-> Ord TsNamedBindings
TsNamedBindings -> TsNamedBindings -> Bool
TsNamedBindings -> TsNamedBindings -> Ordering
TsNamedBindings -> TsNamedBindings -> TsNamedBindings
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
$ccompare :: TsNamedBindings -> TsNamedBindings -> Ordering
compare :: TsNamedBindings -> TsNamedBindings -> Ordering
$c< :: TsNamedBindings -> TsNamedBindings -> Bool
< :: TsNamedBindings -> TsNamedBindings -> Bool
$c<= :: TsNamedBindings -> TsNamedBindings -> Bool
<= :: TsNamedBindings -> TsNamedBindings -> Bool
$c> :: TsNamedBindings -> TsNamedBindings -> Bool
> :: TsNamedBindings -> TsNamedBindings -> Bool
$c>= :: TsNamedBindings -> TsNamedBindings -> Bool
>= :: TsNamedBindings -> TsNamedBindings -> Bool
$cmax :: TsNamedBindings -> TsNamedBindings -> TsNamedBindings
max :: TsNamedBindings -> TsNamedBindings -> TsNamedBindings
$cmin :: TsNamedBindings -> TsNamedBindings -> TsNamedBindings
min :: TsNamedBindings -> TsNamedBindings -> TsNamedBindings
Ord, Int -> TsNamedBindings -> ShowS
[TsNamedBindings] -> ShowS
TsNamedBindings -> String
(Int -> TsNamedBindings -> ShowS)
-> (TsNamedBindings -> String)
-> ([TsNamedBindings] -> ShowS)
-> Show TsNamedBindings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsNamedBindings -> ShowS
showsPrec :: Int -> TsNamedBindings -> ShowS
$cshow :: TsNamedBindings -> String
show :: TsNamedBindings -> String
$cshowList :: [TsNamedBindings] -> ShowS
showList :: [TsNamedBindings] -> ShowS
Show, ReadPrec [TsNamedBindings]
ReadPrec TsNamedBindings
Int -> ReadS TsNamedBindings
ReadS [TsNamedBindings]
(Int -> ReadS TsNamedBindings)
-> ReadS [TsNamedBindings]
-> ReadPrec TsNamedBindings
-> ReadPrec [TsNamedBindings]
-> Read TsNamedBindings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsNamedBindings
readsPrec :: Int -> ReadS TsNamedBindings
$creadList :: ReadS [TsNamedBindings]
readList :: ReadS [TsNamedBindings]
$creadPrec :: ReadPrec TsNamedBindings
readPrec :: ReadPrec TsNamedBindings
$creadListPrec :: ReadPrec [TsNamedBindings]
readListPrec :: ReadPrec [TsNamedBindings]
Read)

-- | @type a as b@, an import or export, of a type or not, renamed or not.
data TsImportSpecifier = TsImportSpecifier Bool (Maybe Text) Text
  deriving stock (TsImportSpecifier -> TsImportSpecifier -> Bool
(TsImportSpecifier -> TsImportSpecifier -> Bool)
-> (TsImportSpecifier -> TsImportSpecifier -> Bool)
-> Eq TsImportSpecifier
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsImportSpecifier -> TsImportSpecifier -> Bool
== :: TsImportSpecifier -> TsImportSpecifier -> Bool
$c/= :: TsImportSpecifier -> TsImportSpecifier -> Bool
/= :: TsImportSpecifier -> TsImportSpecifier -> Bool
Eq, Eq TsImportSpecifier
Eq TsImportSpecifier =>
(TsImportSpecifier -> TsImportSpecifier -> Ordering)
-> (TsImportSpecifier -> TsImportSpecifier -> Bool)
-> (TsImportSpecifier -> TsImportSpecifier -> Bool)
-> (TsImportSpecifier -> TsImportSpecifier -> Bool)
-> (TsImportSpecifier -> TsImportSpecifier -> Bool)
-> (TsImportSpecifier -> TsImportSpecifier -> TsImportSpecifier)
-> (TsImportSpecifier -> TsImportSpecifier -> TsImportSpecifier)
-> Ord TsImportSpecifier
TsImportSpecifier -> TsImportSpecifier -> Bool
TsImportSpecifier -> TsImportSpecifier -> Ordering
TsImportSpecifier -> TsImportSpecifier -> TsImportSpecifier
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
$ccompare :: TsImportSpecifier -> TsImportSpecifier -> Ordering
compare :: TsImportSpecifier -> TsImportSpecifier -> Ordering
$c< :: TsImportSpecifier -> TsImportSpecifier -> Bool
< :: TsImportSpecifier -> TsImportSpecifier -> Bool
$c<= :: TsImportSpecifier -> TsImportSpecifier -> Bool
<= :: TsImportSpecifier -> TsImportSpecifier -> Bool
$c> :: TsImportSpecifier -> TsImportSpecifier -> Bool
> :: TsImportSpecifier -> TsImportSpecifier -> Bool
$c>= :: TsImportSpecifier -> TsImportSpecifier -> Bool
>= :: TsImportSpecifier -> TsImportSpecifier -> Bool
$cmax :: TsImportSpecifier -> TsImportSpecifier -> TsImportSpecifier
max :: TsImportSpecifier -> TsImportSpecifier -> TsImportSpecifier
$cmin :: TsImportSpecifier -> TsImportSpecifier -> TsImportSpecifier
min :: TsImportSpecifier -> TsImportSpecifier -> TsImportSpecifier
Ord, Int -> TsImportSpecifier -> ShowS
[TsImportSpecifier] -> ShowS
TsImportSpecifier -> String
(Int -> TsImportSpecifier -> ShowS)
-> (TsImportSpecifier -> String)
-> ([TsImportSpecifier] -> ShowS)
-> Show TsImportSpecifier
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsImportSpecifier -> ShowS
showsPrec :: Int -> TsImportSpecifier -> ShowS
$cshow :: TsImportSpecifier -> String
show :: TsImportSpecifier -> String
$cshowList :: [TsImportSpecifier] -> ShowS
showList :: [TsImportSpecifier] -> ShowS
Show, ReadPrec [TsImportSpecifier]
ReadPrec TsImportSpecifier
Int -> ReadS TsImportSpecifier
ReadS [TsImportSpecifier]
(Int -> ReadS TsImportSpecifier)
-> ReadS [TsImportSpecifier]
-> ReadPrec TsImportSpecifier
-> ReadPrec [TsImportSpecifier]
-> Read TsImportSpecifier
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsImportSpecifier
readsPrec :: Int -> ReadS TsImportSpecifier
$creadList :: ReadS [TsImportSpecifier]
readList :: ReadS [TsImportSpecifier]
$creadPrec :: ReadPrec TsImportSpecifier
readPrec :: ReadPrec TsImportSpecifier
$creadListPrec :: ReadPrec [TsImportSpecifier]
readListPrec :: ReadPrec [TsImportSpecifier]
Read)

-- | What an `ImportEqualsDeclaration` imports.
data TsModuleReference
  = ExternalModuleReference Text -- ^ @require("m")@
  | EntityModuleReference TsEntityName -- ^ @N.M@
  deriving stock (TsModuleReference -> TsModuleReference -> Bool
(TsModuleReference -> TsModuleReference -> Bool)
-> (TsModuleReference -> TsModuleReference -> Bool)
-> Eq TsModuleReference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsModuleReference -> TsModuleReference -> Bool
== :: TsModuleReference -> TsModuleReference -> Bool
$c/= :: TsModuleReference -> TsModuleReference -> Bool
/= :: TsModuleReference -> TsModuleReference -> Bool
Eq, Eq TsModuleReference
Eq TsModuleReference =>
(TsModuleReference -> TsModuleReference -> Ordering)
-> (TsModuleReference -> TsModuleReference -> Bool)
-> (TsModuleReference -> TsModuleReference -> Bool)
-> (TsModuleReference -> TsModuleReference -> Bool)
-> (TsModuleReference -> TsModuleReference -> Bool)
-> (TsModuleReference -> TsModuleReference -> TsModuleReference)
-> (TsModuleReference -> TsModuleReference -> TsModuleReference)
-> Ord TsModuleReference
TsModuleReference -> TsModuleReference -> Bool
TsModuleReference -> TsModuleReference -> Ordering
TsModuleReference -> TsModuleReference -> TsModuleReference
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
$ccompare :: TsModuleReference -> TsModuleReference -> Ordering
compare :: TsModuleReference -> TsModuleReference -> Ordering
$c< :: TsModuleReference -> TsModuleReference -> Bool
< :: TsModuleReference -> TsModuleReference -> Bool
$c<= :: TsModuleReference -> TsModuleReference -> Bool
<= :: TsModuleReference -> TsModuleReference -> Bool
$c> :: TsModuleReference -> TsModuleReference -> Bool
> :: TsModuleReference -> TsModuleReference -> Bool
$c>= :: TsModuleReference -> TsModuleReference -> Bool
>= :: TsModuleReference -> TsModuleReference -> Bool
$cmax :: TsModuleReference -> TsModuleReference -> TsModuleReference
max :: TsModuleReference -> TsModuleReference -> TsModuleReference
$cmin :: TsModuleReference -> TsModuleReference -> TsModuleReference
min :: TsModuleReference -> TsModuleReference -> TsModuleReference
Ord, Int -> TsModuleReference -> ShowS
[TsModuleReference] -> ShowS
TsModuleReference -> String
(Int -> TsModuleReference -> ShowS)
-> (TsModuleReference -> String)
-> ([TsModuleReference] -> ShowS)
-> Show TsModuleReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsModuleReference -> ShowS
showsPrec :: Int -> TsModuleReference -> ShowS
$cshow :: TsModuleReference -> String
show :: TsModuleReference -> String
$cshowList :: [TsModuleReference] -> ShowS
showList :: [TsModuleReference] -> ShowS
Show, ReadPrec [TsModuleReference]
ReadPrec TsModuleReference
Int -> ReadS TsModuleReference
ReadS [TsModuleReference]
(Int -> ReadS TsModuleReference)
-> ReadS [TsModuleReference]
-> ReadPrec TsModuleReference
-> ReadPrec [TsModuleReference]
-> Read TsModuleReference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsModuleReference
readsPrec :: Int -> ReadS TsModuleReference
$creadList :: ReadS [TsModuleReference]
readList :: ReadS [TsModuleReference]
$creadPrec :: ReadPrec TsModuleReference
readPrec :: ReadPrec TsModuleReference
$creadListPrec :: ReadPrec [TsModuleReference]
readListPrec :: ReadPrec [TsModuleReference]
Read)

-- | What an `ExportDeclaration` exports.
data TsExportClause
  = NamespaceExport (Maybe Text) -- ^ @*@, or @* as n@
  | NamedExports [TsImportSpecifier] -- ^ @{ a, b as c }@
  deriving stock (TsExportClause -> TsExportClause -> Bool
(TsExportClause -> TsExportClause -> Bool)
-> (TsExportClause -> TsExportClause -> Bool) -> Eq TsExportClause
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsExportClause -> TsExportClause -> Bool
== :: TsExportClause -> TsExportClause -> Bool
$c/= :: TsExportClause -> TsExportClause -> Bool
/= :: TsExportClause -> TsExportClause -> Bool
Eq, Eq TsExportClause
Eq TsExportClause =>
(TsExportClause -> TsExportClause -> Ordering)
-> (TsExportClause -> TsExportClause -> Bool)
-> (TsExportClause -> TsExportClause -> Bool)
-> (TsExportClause -> TsExportClause -> Bool)
-> (TsExportClause -> TsExportClause -> Bool)
-> (TsExportClause -> TsExportClause -> TsExportClause)
-> (TsExportClause -> TsExportClause -> TsExportClause)
-> Ord TsExportClause
TsExportClause -> TsExportClause -> Bool
TsExportClause -> TsExportClause -> Ordering
TsExportClause -> TsExportClause -> TsExportClause
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
$ccompare :: TsExportClause -> TsExportClause -> Ordering
compare :: TsExportClause -> TsExportClause -> Ordering
$c< :: TsExportClause -> TsExportClause -> Bool
< :: TsExportClause -> TsExportClause -> Bool
$c<= :: TsExportClause -> TsExportClause -> Bool
<= :: TsExportClause -> TsExportClause -> Bool
$c> :: TsExportClause -> TsExportClause -> Bool
> :: TsExportClause -> TsExportClause -> Bool
$c>= :: TsExportClause -> TsExportClause -> Bool
>= :: TsExportClause -> TsExportClause -> Bool
$cmax :: TsExportClause -> TsExportClause -> TsExportClause
max :: TsExportClause -> TsExportClause -> TsExportClause
$cmin :: TsExportClause -> TsExportClause -> TsExportClause
min :: TsExportClause -> TsExportClause -> TsExportClause
Ord, Int -> TsExportClause -> ShowS
[TsExportClause] -> ShowS
TsExportClause -> String
(Int -> TsExportClause -> ShowS)
-> (TsExportClause -> String)
-> ([TsExportClause] -> ShowS)
-> Show TsExportClause
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsExportClause -> ShowS
showsPrec :: Int -> TsExportClause -> ShowS
$cshow :: TsExportClause -> String
show :: TsExportClause -> String
$cshowList :: [TsExportClause] -> ShowS
showList :: [TsExportClause] -> ShowS
Show, ReadPrec [TsExportClause]
ReadPrec TsExportClause
Int -> ReadS TsExportClause
ReadS [TsExportClause]
(Int -> ReadS TsExportClause)
-> ReadS [TsExportClause]
-> ReadPrec TsExportClause
-> ReadPrec [TsExportClause]
-> Read TsExportClause
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsExportClause
readsPrec :: Int -> ReadS TsExportClause
$creadList :: ReadS [TsExportClause]
readList :: ReadS [TsExportClause]
$creadPrec :: ReadPrec TsExportClause
readPrec :: ReadPrec TsExportClause
$creadListPrec :: ReadPrec [TsExportClause]
readListPrec :: ReadPrec [TsExportClause]
Read)

-- | @x: T = 1@, a variable, of a type or not, & a literal value or not.
data TsVariableDeclaration =
  TsVariableDeclaration Text (Maybe TsType) (Maybe TsLiteral)
  deriving stock (TsVariableDeclaration -> TsVariableDeclaration -> Bool
(TsVariableDeclaration -> TsVariableDeclaration -> Bool)
-> (TsVariableDeclaration -> TsVariableDeclaration -> Bool)
-> Eq TsVariableDeclaration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
== :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
$c/= :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
/= :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
Eq, Eq TsVariableDeclaration
Eq TsVariableDeclaration =>
(TsVariableDeclaration -> TsVariableDeclaration -> Ordering)
-> (TsVariableDeclaration -> TsVariableDeclaration -> Bool)
-> (TsVariableDeclaration -> TsVariableDeclaration -> Bool)
-> (TsVariableDeclaration -> TsVariableDeclaration -> Bool)
-> (TsVariableDeclaration -> TsVariableDeclaration -> Bool)
-> (TsVariableDeclaration
    -> TsVariableDeclaration -> TsVariableDeclaration)
-> (TsVariableDeclaration
    -> TsVariableDeclaration -> TsVariableDeclaration)
-> Ord TsVariableDeclaration
TsVariableDeclaration -> TsVariableDeclaration -> Bool
TsVariableDeclaration -> TsVariableDeclaration -> Ordering
TsVariableDeclaration
-> TsVariableDeclaration -> TsVariableDeclaration
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
$ccompare :: TsVariableDeclaration -> TsVariableDeclaration -> Ordering
compare :: TsVariableDeclaration -> TsVariableDeclaration -> Ordering
$c< :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
< :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
$c<= :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
<= :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
$c> :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
> :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
$c>= :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
>= :: TsVariableDeclaration -> TsVariableDeclaration -> Bool
$cmax :: TsVariableDeclaration
-> TsVariableDeclaration -> TsVariableDeclaration
max :: TsVariableDeclaration
-> TsVariableDeclaration -> TsVariableDeclaration
$cmin :: TsVariableDeclaration
-> TsVariableDeclaration -> TsVariableDeclaration
min :: TsVariableDeclaration
-> TsVariableDeclaration -> TsVariableDeclaration
Ord, Int -> TsVariableDeclaration -> ShowS
[TsVariableDeclaration] -> ShowS
TsVariableDeclaration -> String
(Int -> TsVariableDeclaration -> ShowS)
-> (TsVariableDeclaration -> String)
-> ([TsVariableDeclaration] -> ShowS)
-> Show TsVariableDeclaration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsVariableDeclaration -> ShowS
showsPrec :: Int -> TsVariableDeclaration -> ShowS
$cshow :: TsVariableDeclaration -> String
show :: TsVariableDeclaration -> String
$cshowList :: [TsVariableDeclaration] -> ShowS
showList :: [TsVariableDeclaration] -> ShowS
Show, ReadPrec [TsVariableDeclaration]
ReadPrec TsVariableDeclaration
Int -> ReadS TsVariableDeclaration
ReadS [TsVariableDeclaration]
(Int -> ReadS TsVariableDeclaration)
-> ReadS [TsVariableDeclaration]
-> ReadPrec TsVariableDeclaration
-> ReadPrec [TsVariableDeclaration]
-> Read TsVariableDeclaration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsVariableDeclaration
readsPrec :: Int -> ReadS TsVariableDeclaration
$creadList :: ReadS [TsVariableDeclaration]
readList :: ReadS [TsVariableDeclaration]
$creadPrec :: ReadPrec TsVariableDeclaration
readPrec :: ReadPrec TsVariableDeclaration
$creadListPrec :: ReadPrec [TsVariableDeclaration]
readListPrec :: ReadPrec [TsVariableDeclaration]
Read)

-- | @A = 1@, a member of an `EnumDeclaration`, of a literal value or not.
data TsEnumMember = TsEnumMember TsPropertyName (Maybe TsLiteral)
  deriving stock (TsEnumMember -> TsEnumMember -> Bool
(TsEnumMember -> TsEnumMember -> Bool)
-> (TsEnumMember -> TsEnumMember -> Bool) -> Eq TsEnumMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsEnumMember -> TsEnumMember -> Bool
== :: TsEnumMember -> TsEnumMember -> Bool
$c/= :: TsEnumMember -> TsEnumMember -> Bool
/= :: TsEnumMember -> TsEnumMember -> Bool
Eq, Eq TsEnumMember
Eq TsEnumMember =>
(TsEnumMember -> TsEnumMember -> Ordering)
-> (TsEnumMember -> TsEnumMember -> Bool)
-> (TsEnumMember -> TsEnumMember -> Bool)
-> (TsEnumMember -> TsEnumMember -> Bool)
-> (TsEnumMember -> TsEnumMember -> Bool)
-> (TsEnumMember -> TsEnumMember -> TsEnumMember)
-> (TsEnumMember -> TsEnumMember -> TsEnumMember)
-> Ord TsEnumMember
TsEnumMember -> TsEnumMember -> Bool
TsEnumMember -> TsEnumMember -> Ordering
TsEnumMember -> TsEnumMember -> TsEnumMember
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
$ccompare :: TsEnumMember -> TsEnumMember -> Ordering
compare :: TsEnumMember -> TsEnumMember -> Ordering
$c< :: TsEnumMember -> TsEnumMember -> Bool
< :: TsEnumMember -> TsEnumMember -> Bool
$c<= :: TsEnumMember -> TsEnumMember -> Bool
<= :: TsEnumMember -> TsEnumMember -> Bool
$c> :: TsEnumMember -> TsEnumMember -> Bool
> :: TsEnumMember -> TsEnumMember -> Bool
$c>= :: TsEnumMember -> TsEnumMember -> Bool
>= :: TsEnumMember -> TsEnumMember -> Bool
$cmax :: TsEnumMember -> TsEnumMember -> TsEnumMember
max :: TsEnumMember -> TsEnumMember -> TsEnumMember
$cmin :: TsEnumMember -> TsEnumMember -> TsEnumMember
min :: TsEnumMember -> TsEnumMember -> TsEnumMember
Ord, Int -> TsEnumMember -> ShowS
[TsEnumMember] -> ShowS
TsEnumMember -> String
(Int -> TsEnumMember -> ShowS)
-> (TsEnumMember -> String)
-> ([TsEnumMember] -> ShowS)
-> Show TsEnumMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsEnumMember -> ShowS
showsPrec :: Int -> TsEnumMember -> ShowS
$cshow :: TsEnumMember -> String
show :: TsEnumMember -> String
$cshowList :: [TsEnumMember] -> ShowS
showList :: [TsEnumMember] -> ShowS
Show, ReadPrec [TsEnumMember]
ReadPrec TsEnumMember
Int -> ReadS TsEnumMember
ReadS [TsEnumMember]
(Int -> ReadS TsEnumMember)
-> ReadS [TsEnumMember]
-> ReadPrec TsEnumMember
-> ReadPrec [TsEnumMember]
-> Read TsEnumMember
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsEnumMember
readsPrec :: Int -> ReadS TsEnumMember
$creadList :: ReadS [TsEnumMember]
readList :: ReadS [TsEnumMember]
$creadPrec :: ReadPrec TsEnumMember
readPrec :: ReadPrec TsEnumMember
$creadListPrec :: ReadPrec [TsEnumMember]
readListPrec :: ReadPrec [TsEnumMember]
Read)

-- | @N.M\<T>@, a class or interface which a declaration extends.
data TsHeritage = TsHeritage TsEntityName [TsType]
  deriving stock (TsHeritage -> TsHeritage -> Bool
(TsHeritage -> TsHeritage -> Bool)
-> (TsHeritage -> TsHeritage -> Bool) -> Eq TsHeritage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsHeritage -> TsHeritage -> Bool
== :: TsHeritage -> TsHeritage -> Bool
$c/= :: TsHeritage -> TsHeritage -> Bool
/= :: TsHeritage -> TsHeritage -> Bool
Eq, Eq TsHeritage
Eq TsHeritage =>
(TsHeritage -> TsHeritage -> Ordering)
-> (TsHeritage -> TsHeritage -> Bool)
-> (TsHeritage -> TsHeritage -> Bool)
-> (TsHeritage -> TsHeritage -> Bool)
-> (TsHeritage -> TsHeritage -> Bool)
-> (TsHeritage -> TsHeritage -> TsHeritage)
-> (TsHeritage -> TsHeritage -> TsHeritage)
-> Ord TsHeritage
TsHeritage -> TsHeritage -> Bool
TsHeritage -> TsHeritage -> Ordering
TsHeritage -> TsHeritage -> TsHeritage
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
$ccompare :: TsHeritage -> TsHeritage -> Ordering
compare :: TsHeritage -> TsHeritage -> Ordering
$c< :: TsHeritage -> TsHeritage -> Bool
< :: TsHeritage -> TsHeritage -> Bool
$c<= :: TsHeritage -> TsHeritage -> Bool
<= :: TsHeritage -> TsHeritage -> Bool
$c> :: TsHeritage -> TsHeritage -> Bool
> :: TsHeritage -> TsHeritage -> Bool
$c>= :: TsHeritage -> TsHeritage -> Bool
>= :: TsHeritage -> TsHeritage -> Bool
$cmax :: TsHeritage -> TsHeritage -> TsHeritage
max :: TsHeritage -> TsHeritage -> TsHeritage
$cmin :: TsHeritage -> TsHeritage -> TsHeritage
min :: TsHeritage -> TsHeritage -> TsHeritage
Ord, Int -> TsHeritage -> ShowS
[TsHeritage] -> ShowS
TsHeritage -> String
(Int -> TsHeritage -> ShowS)
-> (TsHeritage -> String)
-> ([TsHeritage] -> ShowS)
-> Show TsHeritage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsHeritage -> ShowS
showsPrec :: Int -> TsHeritage -> ShowS
$cshow :: TsHeritage -> String
show :: TsHeritage -> String
$cshowList :: [TsHeritage] -> ShowS
showList :: [TsHeritage] -> ShowS
Show, ReadPrec [TsHeritage]
ReadPrec TsHeritage
Int -> ReadS TsHeritage
ReadS [TsHeritage]
(Int -> ReadS TsHeritage)
-> ReadS [TsHeritage]
-> ReadPrec TsHeritage
-> ReadPrec [TsHeritage]
-> Read TsHeritage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsHeritage
readsPrec :: Int -> ReadS TsHeritage
$creadList :: ReadS [TsHeritage]
readList :: ReadS [TsHeritage]
$creadPrec :: ReadPrec TsHeritage
readPrec :: ReadPrec TsHeritage
$creadListPrec :: ReadPrec [TsHeritage]
readListPrec :: ReadPrec [TsHeritage]
Read)

-- | A qualified name, @N.M.x@, by its identifiers.
type TsEntityName = [Text]

-- Types --

-- | A type, by the TypeScript compiler's name of its node.
data TsType
  = KeywordType TsTokenCategory -- ^ @number@, @string@, @never@, …
  | ThisType -- ^ @this@
  | LiteralType TsLiteral -- ^ @null@, @true@, @1@ or @"abc"@
  | ReferenceType TsEntityName [TsType] -- ^ @T@ or @N.T\<U, V>@
  | ArrayType TsType -- ^ @T[]@
  | TupleType [TsType] -- ^ @[T, U]@
  | OptionalType TsType -- ^ @T?@, an element of a tuple
  | RestType TsType -- ^ @...T@, an element of a tuple
  | NamedTupleMember Bool Text Bool TsType
  -- ^ @...x?: T@, an element of a tuple, rest or not, optional or not
  | UnionType [TsType] -- ^ @T | U@
  | IntersectionType [TsType] -- ^ @T & U@
  | ParenthesizedType TsType -- ^ @(T)@
  | FunctionType TsSignature -- ^ @\<T>(x: T) => U@
  | ConstructorType Bool TsSignature
  -- ^ @abstract new \<T>(x: T) => U@, abstract or not
  | TypeOperator TsTokenCategory TsType
  -- ^ @keyof T@, @readonly T@ or @unique T@
  | IndexedAccessType TsType TsType -- ^ @T[K]@
  | TypeQuery TsEntityName [TsType] -- ^ @typeof x\<T>@
  | ImportType Bool Text TsEntityName [TsType]
  -- ^ @typeof import("m").N.T\<U>@, a @typeof@ or not
  | InferType Text (Maybe TsType) -- ^ @infer T extends U@
  | TypePredicate Bool Text (Maybe TsType)
  -- ^ @asserts x is T@ or @this is T@, a return type, asserting or not
  | ObjectType [TsProperty] -- ^ @{ x: T; y?: U }@
  | MappedType
      (Maybe TsTokenCategory) Text TsType (Maybe TsType)
      (Maybe TsTokenCategory) TsType
  {- ^ @{ -readonly [K in T as U]+?: V }@, by its @readonly@ modifier,
  @readonly@, @+@ or @-@, its type parameter & its constraint & name type,
  & its @?@ modifier, @?@, @+@ or @-@ -}
  | ConditionalType TsType TsType TsType TsType
  -- ^ @T extends U ? V : W@
  | TemplateLiteralType Text [(TsType, Text)]
  -- ^ @\`a${T}b\`@, by its head & its spans' types & literals
  deriving stock (TsType -> TsType -> Bool
(TsType -> TsType -> Bool)
-> (TsType -> TsType -> Bool) -> Eq TsType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsType -> TsType -> Bool
== :: TsType -> TsType -> Bool
$c/= :: TsType -> TsType -> Bool
/= :: TsType -> TsType -> Bool
Eq, Eq TsType
Eq TsType =>
(TsType -> TsType -> Ordering)
-> (TsType -> TsType -> Bool)
-> (TsType -> TsType -> Bool)
-> (TsType -> TsType -> Bool)
-> (TsType -> TsType -> Bool)
-> (TsType -> TsType -> TsType)
-> (TsType -> TsType -> TsType)
-> Ord TsType
TsType -> TsType -> Bool
TsType -> TsType -> Ordering
TsType -> TsType -> TsType
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
$ccompare :: TsType -> TsType -> Ordering
compare :: TsType -> TsType -> Ordering
$c< :: TsType -> TsType -> Bool
< :: TsType -> TsType -> Bool
$c<= :: TsType -> TsType -> Bool
<= :: TsType -> TsType -> Bool
$c> :: TsType -> TsType -> Bool
> :: TsType -> TsType -> Bool
$c>= :: TsType -> TsType -> Bool
>= :: TsType -> TsType -> Bool
$cmax :: TsType -> TsType -> TsType
max :: TsType -> TsType -> TsType
$cmin :: TsType -> TsType -> TsType
min :: TsType -> TsType -> TsType
Ord, Int -> TsType -> ShowS
[TsType] -> ShowS
TsType -> String
(Int -> TsType -> ShowS)
-> (TsType -> String) -> ([TsType] -> ShowS) -> Show TsType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsType -> ShowS
showsPrec :: Int -> TsType -> ShowS
$cshow :: TsType -> String
show :: TsType -> String
$cshowList :: [TsType] -> ShowS
showList :: [TsType] -> ShowS
Show, ReadPrec [TsType]
ReadPrec TsType
Int -> ReadS TsType
ReadS [TsType]
(Int -> ReadS TsType)
-> ReadS [TsType]
-> ReadPrec TsType
-> ReadPrec [TsType]
-> Read TsType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsType
readsPrec :: Int -> ReadS TsType
$creadList :: ReadS [TsType]
readList :: ReadS [TsType]
$creadPrec :: ReadPrec TsType
readPrec :: ReadPrec TsType
$creadListPrec :: ReadPrec [TsType]
readListPrec :: ReadPrec [TsType]
Read)

{- | A member of an `ObjectType`, `InterfaceDeclaration` or
`ClassDeclaration`, by the TypeScript compiler's name of its node,
with its modifiers, like @readonly@ & @static@.
-}
data TsProperty
  = PropertySignature [TsTokenCategory] TsPropertyName Bool (Maybe TsType)
  -- ^ @x?: T@, optional or not, of a type or not
  | MethodSignature [TsTokenCategory] TsPropertyName Bool TsSignature
  -- ^ @f?\<T>(x: T): U@, optional or not
  | CallSignature TsSignature -- ^ @\<T>(x: T): U@
  | ConstructSignature TsSignature -- ^ @new \<T>(x: T): U@
  | IndexSignature [TsTokenCategory] Text TsType TsType -- ^ @[k: K]: T@
  | GetAccessor [TsTokenCategory] TsPropertyName (Maybe TsType)
  -- ^ @get x(): T@
  | SetAccessor [TsTokenCategory] TsPropertyName TsParameter
  -- ^ @set x(v: T)@
  | Constructor [TsTokenCategory] [TsParameter]
  -- ^ @constructor(x: T)@, of a class
  deriving stock (TsProperty -> TsProperty -> Bool
(TsProperty -> TsProperty -> Bool)
-> (TsProperty -> TsProperty -> Bool) -> Eq TsProperty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsProperty -> TsProperty -> Bool
== :: TsProperty -> TsProperty -> Bool
$c/= :: TsProperty -> TsProperty -> Bool
/= :: TsProperty -> TsProperty -> Bool
Eq, Eq TsProperty
Eq TsProperty =>
(TsProperty -> TsProperty -> Ordering)
-> (TsProperty -> TsProperty -> Bool)
-> (TsProperty -> TsProperty -> Bool)
-> (TsProperty -> TsProperty -> Bool)
-> (TsProperty -> TsProperty -> Bool)
-> (TsProperty -> TsProperty -> TsProperty)
-> (TsProperty -> TsProperty -> TsProperty)
-> Ord TsProperty
TsProperty -> TsProperty -> Bool
TsProperty -> TsProperty -> Ordering
TsProperty -> TsProperty -> TsProperty
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
$ccompare :: TsProperty -> TsProperty -> Ordering
compare :: TsProperty -> TsProperty -> Ordering
$c< :: TsProperty -> TsProperty -> Bool
< :: TsProperty -> TsProperty -> Bool
$c<= :: TsProperty -> TsProperty -> Bool
<= :: TsProperty -> TsProperty -> Bool
$c> :: TsProperty -> TsProperty -> Bool
> :: TsProperty -> TsProperty -> Bool
$c>= :: TsProperty -> TsProperty -> Bool
>= :: TsProperty -> TsProperty -> Bool
$cmax :: TsProperty -> TsProperty -> TsProperty
max :: TsProperty -> TsProperty -> TsProperty
$cmin :: TsProperty -> TsProperty -> TsProperty
min :: TsProperty -> TsProperty -> TsProperty
Ord, Int -> TsProperty -> ShowS
[TsProperty] -> ShowS
TsProperty -> String
(Int -> TsProperty -> ShowS)
-> (TsProperty -> String)
-> ([TsProperty] -> ShowS)
-> Show TsProperty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsProperty -> ShowS
showsPrec :: Int -> TsProperty -> ShowS
$cshow :: TsProperty -> String
show :: TsProperty -> String
$cshowList :: [TsProperty] -> ShowS
showList :: [TsProperty] -> ShowS
Show, ReadPrec [TsProperty]
ReadPrec TsProperty
Int -> ReadS TsProperty
ReadS [TsProperty]
(Int -> ReadS TsProperty)
-> ReadS [TsProperty]
-> ReadPrec TsProperty
-> ReadPrec [TsProperty]
-> Read TsProperty
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsProperty
readsPrec :: Int -> ReadS TsProperty
$creadList :: ReadS [TsProperty]
readList :: ReadS [TsProperty]
$creadPrec :: ReadPrec TsProperty
readPrec :: ReadPrec TsProperty
$creadListPrec :: ReadPrec [TsProperty]
readListPrec :: ReadPrec [TsProperty]
Read)

-- | The name of a member.
data TsPropertyName
  = PropertyIdentifier Text -- ^ @x@
  | PropertyString Text -- ^ @"x y"@
  | PropertyNumeric Text -- ^ @1@
  | PropertyPrivate Text -- ^ @#x@
  | ComputedPropertyName TsEntityName -- ^ @[Symbol.iterator]@
  deriving stock (TsPropertyName -> TsPropertyName -> Bool
(TsPropertyName -> TsPropertyName -> Bool)
-> (TsPropertyName -> TsPropertyName -> Bool) -> Eq TsPropertyName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsPropertyName -> TsPropertyName -> Bool
== :: TsPropertyName -> TsPropertyName -> Bool
$c/= :: TsPropertyName -> TsPropertyName -> Bool
/= :: TsPropertyName -> TsPropertyName -> Bool
Eq, Eq TsPropertyName
Eq TsPropertyName =>
(TsPropertyName -> TsPropertyName -> Ordering)
-> (TsPropertyName -> TsPropertyName -> Bool)
-> (TsPropertyName -> TsPropertyName -> Bool)
-> (TsPropertyName -> TsPropertyName -> Bool)
-> (TsPropertyName -> TsPropertyName -> Bool)
-> (TsPropertyName -> TsPropertyName -> TsPropertyName)
-> (TsPropertyName -> TsPropertyName -> TsPropertyName)
-> Ord TsPropertyName
TsPropertyName -> TsPropertyName -> Bool
TsPropertyName -> TsPropertyName -> Ordering
TsPropertyName -> TsPropertyName -> TsPropertyName
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
$ccompare :: TsPropertyName -> TsPropertyName -> Ordering
compare :: TsPropertyName -> TsPropertyName -> Ordering
$c< :: TsPropertyName -> TsPropertyName -> Bool
< :: TsPropertyName -> TsPropertyName -> Bool
$c<= :: TsPropertyName -> TsPropertyName -> Bool
<= :: TsPropertyName -> TsPropertyName -> Bool
$c> :: TsPropertyName -> TsPropertyName -> Bool
> :: TsPropertyName -> TsPropertyName -> Bool
$c>= :: TsPropertyName -> TsPropertyName -> Bool
>= :: TsPropertyName -> TsPropertyName -> Bool
$cmax :: TsPropertyName -> TsPropertyName -> TsPropertyName
max :: TsPropertyName -> TsPropertyName -> TsPropertyName
$cmin :: TsPropertyName -> TsPropertyName -> TsPropertyName
min :: TsPropertyName -> TsPropertyName -> TsPropertyName
Ord, Int -> TsPropertyName -> ShowS
[TsPropertyName] -> ShowS
TsPropertyName -> String
(Int -> TsPropertyName -> ShowS)
-> (TsPropertyName -> String)
-> ([TsPropertyName] -> ShowS)
-> Show TsPropertyName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsPropertyName -> ShowS
showsPrec :: Int -> TsPropertyName -> ShowS
$cshow :: TsPropertyName -> String
show :: TsPropertyName -> String
$cshowList :: [TsPropertyName] -> ShowS
showList :: [TsPropertyName] -> ShowS
Show, ReadPrec [TsPropertyName]
ReadPrec TsPropertyName
Int -> ReadS TsPropertyName
ReadS [TsPropertyName]
(Int -> ReadS TsPropertyName)
-> ReadS [TsPropertyName]
-> ReadPrec TsPropertyName
-> ReadPrec [TsPropertyName]
-> Read TsPropertyName
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsPropertyName
readsPrec :: Int -> ReadS TsPropertyName
$creadList :: ReadS [TsPropertyName]
readList :: ReadS [TsPropertyName]
$creadPrec :: ReadPrec TsPropertyName
readPrec :: ReadPrec TsPropertyName
$creadListPrec :: ReadPrec [TsPropertyName]
readListPrec :: ReadPrec [TsPropertyName]
Read)

-- | A literal, of a `LiteralType` or a value.
data TsLiteral
  = NullLiteral -- ^ @null@
  | TrueLiteral -- ^ @true@
  | FalseLiteral -- ^ @false@
  | TextLiteral Text -- ^ @"abc"@
  | NumberLiteral Text -- ^ @1@ or @-1.5@, as it's written
  | BigIntegerLiteral Text -- ^ @1n@ or @-1n@, as it's written
  deriving stock (TsLiteral -> TsLiteral -> Bool
(TsLiteral -> TsLiteral -> Bool)
-> (TsLiteral -> TsLiteral -> Bool) -> Eq TsLiteral
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsLiteral -> TsLiteral -> Bool
== :: TsLiteral -> TsLiteral -> Bool
$c/= :: TsLiteral -> TsLiteral -> Bool
/= :: TsLiteral -> TsLiteral -> Bool
Eq, Eq TsLiteral
Eq TsLiteral =>
(TsLiteral -> TsLiteral -> Ordering)
-> (TsLiteral -> TsLiteral -> Bool)
-> (TsLiteral -> TsLiteral -> Bool)
-> (TsLiteral -> TsLiteral -> Bool)
-> (TsLiteral -> TsLiteral -> Bool)
-> (TsLiteral -> TsLiteral -> TsLiteral)
-> (TsLiteral -> TsLiteral -> TsLiteral)
-> Ord TsLiteral
TsLiteral -> TsLiteral -> Bool
TsLiteral -> TsLiteral -> Ordering
TsLiteral -> TsLiteral -> TsLiteral
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
$ccompare :: TsLiteral -> TsLiteral -> Ordering
compare :: TsLiteral -> TsLiteral -> Ordering
$c< :: TsLiteral -> TsLiteral -> Bool
< :: TsLiteral -> TsLiteral -> Bool
$c<= :: TsLiteral -> TsLiteral -> Bool
<= :: TsLiteral -> TsLiteral -> Bool
$c> :: TsLiteral -> TsLiteral -> Bool
> :: TsLiteral -> TsLiteral -> Bool
$c>= :: TsLiteral -> TsLiteral -> Bool
>= :: TsLiteral -> TsLiteral -> Bool
$cmax :: TsLiteral -> TsLiteral -> TsLiteral
max :: TsLiteral -> TsLiteral -> TsLiteral
$cmin :: TsLiteral -> TsLiteral -> TsLiteral
min :: TsLiteral -> TsLiteral -> TsLiteral
Ord, Int -> TsLiteral -> ShowS
[TsLiteral] -> ShowS
TsLiteral -> String
(Int -> TsLiteral -> ShowS)
-> (TsLiteral -> String)
-> ([TsLiteral] -> ShowS)
-> Show TsLiteral
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsLiteral -> ShowS
showsPrec :: Int -> TsLiteral -> ShowS
$cshow :: TsLiteral -> String
show :: TsLiteral -> String
$cshowList :: [TsLiteral] -> ShowS
showList :: [TsLiteral] -> ShowS
Show, ReadPrec [TsLiteral]
ReadPrec TsLiteral
Int -> ReadS TsLiteral
ReadS [TsLiteral]
(Int -> ReadS TsLiteral)
-> ReadS [TsLiteral]
-> ReadPrec TsLiteral
-> ReadPrec [TsLiteral]
-> Read TsLiteral
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsLiteral
readsPrec :: Int -> ReadS TsLiteral
$creadList :: ReadS [TsLiteral]
readList :: ReadS [TsLiteral]
$creadPrec :: ReadPrec TsLiteral
readPrec :: ReadPrec TsLiteral
$creadListPrec :: ReadPrec [TsLiteral]
readListPrec :: ReadPrec [TsLiteral]
Read)

-- | @const T extends U = V@, a type parameter, with its modifiers.
data TsTypeParameter =
  TsTypeParameter [TsTokenCategory] Text (Maybe TsType) (Maybe TsType)
  deriving stock (TsTypeParameter -> TsTypeParameter -> Bool
(TsTypeParameter -> TsTypeParameter -> Bool)
-> (TsTypeParameter -> TsTypeParameter -> Bool)
-> Eq TsTypeParameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsTypeParameter -> TsTypeParameter -> Bool
== :: TsTypeParameter -> TsTypeParameter -> Bool
$c/= :: TsTypeParameter -> TsTypeParameter -> Bool
/= :: TsTypeParameter -> TsTypeParameter -> Bool
Eq, Eq TsTypeParameter
Eq TsTypeParameter =>
(TsTypeParameter -> TsTypeParameter -> Ordering)
-> (TsTypeParameter -> TsTypeParameter -> Bool)
-> (TsTypeParameter -> TsTypeParameter -> Bool)
-> (TsTypeParameter -> TsTypeParameter -> Bool)
-> (TsTypeParameter -> TsTypeParameter -> Bool)
-> (TsTypeParameter -> TsTypeParameter -> TsTypeParameter)
-> (TsTypeParameter -> TsTypeParameter -> TsTypeParameter)
-> Ord TsTypeParameter
TsTypeParameter -> TsTypeParameter -> Bool
TsTypeParameter -> TsTypeParameter -> Ordering
TsTypeParameter -> TsTypeParameter -> TsTypeParameter
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
$ccompare :: TsTypeParameter -> TsTypeParameter -> Ordering
compare :: TsTypeParameter -> TsTypeParameter -> Ordering
$c< :: TsTypeParameter -> TsTypeParameter -> Bool
< :: TsTypeParameter -> TsTypeParameter -> Bool
$c<= :: TsTypeParameter -> TsTypeParameter -> Bool
<= :: TsTypeParameter -> TsTypeParameter -> Bool
$c> :: TsTypeParameter -> TsTypeParameter -> Bool
> :: TsTypeParameter -> TsTypeParameter -> Bool
$c>= :: TsTypeParameter -> TsTypeParameter -> Bool
>= :: TsTypeParameter -> TsTypeParameter -> Bool
$cmax :: TsTypeParameter -> TsTypeParameter -> TsTypeParameter
max :: TsTypeParameter -> TsTypeParameter -> TsTypeParameter
$cmin :: TsTypeParameter -> TsTypeParameter -> TsTypeParameter
min :: TsTypeParameter -> TsTypeParameter -> TsTypeParameter
Ord, Int -> TsTypeParameter -> ShowS
[TsTypeParameter] -> ShowS
TsTypeParameter -> String
(Int -> TsTypeParameter -> ShowS)
-> (TsTypeParameter -> String)
-> ([TsTypeParameter] -> ShowS)
-> Show TsTypeParameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsTypeParameter -> ShowS
showsPrec :: Int -> TsTypeParameter -> ShowS
$cshow :: TsTypeParameter -> String
show :: TsTypeParameter -> String
$cshowList :: [TsTypeParameter] -> ShowS
showList :: [TsTypeParameter] -> ShowS
Show, ReadPrec [TsTypeParameter]
ReadPrec TsTypeParameter
Int -> ReadS TsTypeParameter
ReadS [TsTypeParameter]
(Int -> ReadS TsTypeParameter)
-> ReadS [TsTypeParameter]
-> ReadPrec TsTypeParameter
-> ReadPrec [TsTypeParameter]
-> Read TsTypeParameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsTypeParameter
readsPrec :: Int -> ReadS TsTypeParameter
$creadList :: ReadS [TsTypeParameter]
readList :: ReadS [TsTypeParameter]
$creadPrec :: ReadPrec TsTypeParameter
readPrec :: ReadPrec TsTypeParameter
$creadListPrec :: ReadPrec [TsTypeParameter]
readListPrec :: ReadPrec [TsTypeParameter]
Read)

-- | @\<T>(x: T): U@, type parameters, parameters & a return type or not.
data TsSignature =
  TsSignature [TsTypeParameter] [TsParameter] (Maybe TsType)
  deriving stock (TsSignature -> TsSignature -> Bool
(TsSignature -> TsSignature -> Bool)
-> (TsSignature -> TsSignature -> Bool) -> Eq TsSignature
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsSignature -> TsSignature -> Bool
== :: TsSignature -> TsSignature -> Bool
$c/= :: TsSignature -> TsSignature -> Bool
/= :: TsSignature -> TsSignature -> Bool
Eq, Eq TsSignature
Eq TsSignature =>
(TsSignature -> TsSignature -> Ordering)
-> (TsSignature -> TsSignature -> Bool)
-> (TsSignature -> TsSignature -> Bool)
-> (TsSignature -> TsSignature -> Bool)
-> (TsSignature -> TsSignature -> Bool)
-> (TsSignature -> TsSignature -> TsSignature)
-> (TsSignature -> TsSignature -> TsSignature)
-> Ord TsSignature
TsSignature -> TsSignature -> Bool
TsSignature -> TsSignature -> Ordering
TsSignature -> TsSignature -> TsSignature
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
$ccompare :: TsSignature -> TsSignature -> Ordering
compare :: TsSignature -> TsSignature -> Ordering
$c< :: TsSignature -> TsSignature -> Bool
< :: TsSignature -> TsSignature -> Bool
$c<= :: TsSignature -> TsSignature -> Bool
<= :: TsSignature -> TsSignature -> Bool
$c> :: TsSignature -> TsSignature -> Bool
> :: TsSignature -> TsSignature -> Bool
$c>= :: TsSignature -> TsSignature -> Bool
>= :: TsSignature -> TsSignature -> Bool
$cmax :: TsSignature -> TsSignature -> TsSignature
max :: TsSignature -> TsSignature -> TsSignature
$cmin :: TsSignature -> TsSignature -> TsSignature
min :: TsSignature -> TsSignature -> TsSignature
Ord, Int -> TsSignature -> ShowS
[TsSignature] -> ShowS
TsSignature -> String
(Int -> TsSignature -> ShowS)
-> (TsSignature -> String)
-> ([TsSignature] -> ShowS)
-> Show TsSignature
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsSignature -> ShowS
showsPrec :: Int -> TsSignature -> ShowS
$cshow :: TsSignature -> String
show :: TsSignature -> String
$cshowList :: [TsSignature] -> ShowS
showList :: [TsSignature] -> ShowS
Show, ReadPrec [TsSignature]
ReadPrec TsSignature
Int -> ReadS TsSignature
ReadS [TsSignature]
(Int -> ReadS TsSignature)
-> ReadS [TsSignature]
-> ReadPrec TsSignature
-> ReadPrec [TsSignature]
-> Read TsSignature
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsSignature
readsPrec :: Int -> ReadS TsSignature
$creadList :: ReadS [TsSignature]
readList :: ReadS [TsSignature]
$creadPrec :: ReadPrec TsSignature
readPrec :: ReadPrec TsSignature
$creadListPrec :: ReadPrec [TsSignature]
readListPrec :: ReadPrec [TsSignature]
Read)

-- | @...x?: T@, a parameter, rest or not, optional or not.
data TsParameter = TsParameter Bool TsBindingName Bool (Maybe TsType)
  deriving stock (TsParameter -> TsParameter -> Bool
(TsParameter -> TsParameter -> Bool)
-> (TsParameter -> TsParameter -> Bool) -> Eq TsParameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsParameter -> TsParameter -> Bool
== :: TsParameter -> TsParameter -> Bool
$c/= :: TsParameter -> TsParameter -> Bool
/= :: TsParameter -> TsParameter -> Bool
Eq, Eq TsParameter
Eq TsParameter =>
(TsParameter -> TsParameter -> Ordering)
-> (TsParameter -> TsParameter -> Bool)
-> (TsParameter -> TsParameter -> Bool)
-> (TsParameter -> TsParameter -> Bool)
-> (TsParameter -> TsParameter -> Bool)
-> (TsParameter -> TsParameter -> TsParameter)
-> (TsParameter -> TsParameter -> TsParameter)
-> Ord TsParameter
TsParameter -> TsParameter -> Bool
TsParameter -> TsParameter -> Ordering
TsParameter -> TsParameter -> TsParameter
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
$ccompare :: TsParameter -> TsParameter -> Ordering
compare :: TsParameter -> TsParameter -> Ordering
$c< :: TsParameter -> TsParameter -> Bool
< :: TsParameter -> TsParameter -> Bool
$c<= :: TsParameter -> TsParameter -> Bool
<= :: TsParameter -> TsParameter -> Bool
$c> :: TsParameter -> TsParameter -> Bool
> :: TsParameter -> TsParameter -> Bool
$c>= :: TsParameter -> TsParameter -> Bool
>= :: TsParameter -> TsParameter -> Bool
$cmax :: TsParameter -> TsParameter -> TsParameter
max :: TsParameter -> TsParameter -> TsParameter
$cmin :: TsParameter -> TsParameter -> TsParameter
min :: TsParameter -> TsParameter -> TsParameter
Ord, Int -> TsParameter -> ShowS
[TsParameter] -> ShowS
TsParameter -> String
(Int -> TsParameter -> ShowS)
-> (TsParameter -> String)
-> ([TsParameter] -> ShowS)
-> Show TsParameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsParameter -> ShowS
showsPrec :: Int -> TsParameter -> ShowS
$cshow :: TsParameter -> String
show :: TsParameter -> String
$cshowList :: [TsParameter] -> ShowS
showList :: [TsParameter] -> ShowS
Show, ReadPrec [TsParameter]
ReadPrec TsParameter
Int -> ReadS TsParameter
ReadS [TsParameter]
(Int -> ReadS TsParameter)
-> ReadS [TsParameter]
-> ReadPrec TsParameter
-> ReadPrec [TsParameter]
-> Read TsParameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsParameter
readsPrec :: Int -> ReadS TsParameter
$creadList :: ReadS [TsParameter]
readList :: ReadS [TsParameter]
$creadPrec :: ReadPrec TsParameter
readPrec :: ReadPrec TsParameter
$creadListPrec :: ReadPrec [TsParameter]
readListPrec :: ReadPrec [TsParameter]
Read)

-- | The name of a parameter, or a pattern of names.
data TsBindingName
  = BindingIdentifier Text -- ^ @x@, or @this@
  | ObjectBindingPattern [TsBindingElement] -- ^ @{ a, b: c }@
  | ArrayBindingPattern [TsBindingElement] -- ^ @[a, ...b]@
  deriving stock (TsBindingName -> TsBindingName -> Bool
(TsBindingName -> TsBindingName -> Bool)
-> (TsBindingName -> TsBindingName -> Bool) -> Eq TsBindingName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsBindingName -> TsBindingName -> Bool
== :: TsBindingName -> TsBindingName -> Bool
$c/= :: TsBindingName -> TsBindingName -> Bool
/= :: TsBindingName -> TsBindingName -> Bool
Eq, Eq TsBindingName
Eq TsBindingName =>
(TsBindingName -> TsBindingName -> Ordering)
-> (TsBindingName -> TsBindingName -> Bool)
-> (TsBindingName -> TsBindingName -> Bool)
-> (TsBindingName -> TsBindingName -> Bool)
-> (TsBindingName -> TsBindingName -> Bool)
-> (TsBindingName -> TsBindingName -> TsBindingName)
-> (TsBindingName -> TsBindingName -> TsBindingName)
-> Ord TsBindingName
TsBindingName -> TsBindingName -> Bool
TsBindingName -> TsBindingName -> Ordering
TsBindingName -> TsBindingName -> TsBindingName
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
$ccompare :: TsBindingName -> TsBindingName -> Ordering
compare :: TsBindingName -> TsBindingName -> Ordering
$c< :: TsBindingName -> TsBindingName -> Bool
< :: TsBindingName -> TsBindingName -> Bool
$c<= :: TsBindingName -> TsBindingName -> Bool
<= :: TsBindingName -> TsBindingName -> Bool
$c> :: TsBindingName -> TsBindingName -> Bool
> :: TsBindingName -> TsBindingName -> Bool
$c>= :: TsBindingName -> TsBindingName -> Bool
>= :: TsBindingName -> TsBindingName -> Bool
$cmax :: TsBindingName -> TsBindingName -> TsBindingName
max :: TsBindingName -> TsBindingName -> TsBindingName
$cmin :: TsBindingName -> TsBindingName -> TsBindingName
min :: TsBindingName -> TsBindingName -> TsBindingName
Ord, Int -> TsBindingName -> ShowS
[TsBindingName] -> ShowS
TsBindingName -> String
(Int -> TsBindingName -> ShowS)
-> (TsBindingName -> String)
-> ([TsBindingName] -> ShowS)
-> Show TsBindingName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsBindingName -> ShowS
showsPrec :: Int -> TsBindingName -> ShowS
$cshow :: TsBindingName -> String
show :: TsBindingName -> String
$cshowList :: [TsBindingName] -> ShowS
showList :: [TsBindingName] -> ShowS
Show, ReadPrec [TsBindingName]
ReadPrec TsBindingName
Int -> ReadS TsBindingName
ReadS [TsBindingName]
(Int -> ReadS TsBindingName)
-> ReadS [TsBindingName]
-> ReadPrec TsBindingName
-> ReadPrec [TsBindingName]
-> Read TsBindingName
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsBindingName
readsPrec :: Int -> ReadS TsBindingName
$creadList :: ReadS [TsBindingName]
readList :: ReadS [TsBindingName]
$creadPrec :: ReadPrec TsBindingName
readPrec :: ReadPrec TsBindingName
$creadListPrec :: ReadPrec [TsBindingName]
readListPrec :: ReadPrec [TsBindingName]
Read)

-- | @...a: b@, an element of a binding pattern, rest or not.
data TsBindingElement =
  TsBindingElement Bool (Maybe TsPropertyName) TsBindingName
  deriving stock (TsBindingElement -> TsBindingElement -> Bool
(TsBindingElement -> TsBindingElement -> Bool)
-> (TsBindingElement -> TsBindingElement -> Bool)
-> Eq TsBindingElement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsBindingElement -> TsBindingElement -> Bool
== :: TsBindingElement -> TsBindingElement -> Bool
$c/= :: TsBindingElement -> TsBindingElement -> Bool
/= :: TsBindingElement -> TsBindingElement -> Bool
Eq, Eq TsBindingElement
Eq TsBindingElement =>
(TsBindingElement -> TsBindingElement -> Ordering)
-> (TsBindingElement -> TsBindingElement -> Bool)
-> (TsBindingElement -> TsBindingElement -> Bool)
-> (TsBindingElement -> TsBindingElement -> Bool)
-> (TsBindingElement -> TsBindingElement -> Bool)
-> (TsBindingElement -> TsBindingElement -> TsBindingElement)
-> (TsBindingElement -> TsBindingElement -> TsBindingElement)
-> Ord TsBindingElement
TsBindingElement -> TsBindingElement -> Bool
TsBindingElement -> TsBindingElement -> Ordering
TsBindingElement -> TsBindingElement -> TsBindingElement
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
$ccompare :: TsBindingElement -> TsBindingElement -> Ordering
compare :: TsBindingElement -> TsBindingElement -> Ordering
$c< :: TsBindingElement -> TsBindingElement -> Bool
< :: TsBindingElement -> TsBindingElement -> Bool
$c<= :: TsBindingElement -> TsBindingElement -> Bool
<= :: TsBindingElement -> TsBindingElement -> Bool
$c> :: TsBindingElement -> TsBindingElement -> Bool
> :: TsBindingElement -> TsBindingElement -> Bool
$c>= :: TsBindingElement -> TsBindingElement -> Bool
>= :: TsBindingElement -> TsBindingElement -> Bool
$cmax :: TsBindingElement -> TsBindingElement -> TsBindingElement
max :: TsBindingElement -> TsBindingElement -> TsBindingElement
$cmin :: TsBindingElement -> TsBindingElement -> TsBindingElement
min :: TsBindingElement -> TsBindingElement -> TsBindingElement
Ord, Int -> TsBindingElement -> ShowS
[TsBindingElement] -> ShowS
TsBindingElement -> String
(Int -> TsBindingElement -> ShowS)
-> (TsBindingElement -> String)
-> ([TsBindingElement] -> ShowS)
-> Show TsBindingElement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsBindingElement -> ShowS
showsPrec :: Int -> TsBindingElement -> ShowS
$cshow :: TsBindingElement -> String
show :: TsBindingElement -> String
$cshowList :: [TsBindingElement] -> ShowS
showList :: [TsBindingElement] -> ShowS
Show, ReadPrec [TsBindingElement]
ReadPrec TsBindingElement
Int -> ReadS TsBindingElement
ReadS [TsBindingElement]
(Int -> ReadS TsBindingElement)
-> ReadS [TsBindingElement]
-> ReadPrec TsBindingElement
-> ReadPrec [TsBindingElement]
-> Read TsBindingElement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsBindingElement
readsPrec :: Int -> ReadS TsBindingElement
$creadList :: ReadS [TsBindingElement]
readList :: ReadS [TsBindingElement]
$creadPrec :: ReadPrec TsBindingElement
readPrec :: ReadPrec TsBindingElement
$creadListPrec :: ReadPrec [TsBindingElement]
readListPrec :: ReadPrec [TsBindingElement]
Read)

-- Tokens --

{- | A token, of a `TsTokenCategory` & its text, as the scanner of
the TypeScript compiler scans it, with its trivia: its text is
an identifier's name, a string's value, a number's spelling,
a template's literal, or a comment.
-}
data TsToken = TsToken
  { TsToken -> TsTokenCategory
tokenCategory :: TsTokenCategory
  , TsToken -> Text
tokenText :: Text
  } deriving stock (TsToken -> TsToken -> Bool
(TsToken -> TsToken -> Bool)
-> (TsToken -> TsToken -> Bool) -> Eq TsToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsToken -> TsToken -> Bool
== :: TsToken -> TsToken -> Bool
$c/= :: TsToken -> TsToken -> Bool
/= :: TsToken -> TsToken -> Bool
Eq, Eq TsToken
Eq TsToken =>
(TsToken -> TsToken -> Ordering)
-> (TsToken -> TsToken -> Bool)
-> (TsToken -> TsToken -> Bool)
-> (TsToken -> TsToken -> Bool)
-> (TsToken -> TsToken -> Bool)
-> (TsToken -> TsToken -> TsToken)
-> (TsToken -> TsToken -> TsToken)
-> Ord TsToken
TsToken -> TsToken -> Bool
TsToken -> TsToken -> Ordering
TsToken -> TsToken -> TsToken
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
$ccompare :: TsToken -> TsToken -> Ordering
compare :: TsToken -> TsToken -> Ordering
$c< :: TsToken -> TsToken -> Bool
< :: TsToken -> TsToken -> Bool
$c<= :: TsToken -> TsToken -> Bool
<= :: TsToken -> TsToken -> Bool
$c> :: TsToken -> TsToken -> Bool
> :: TsToken -> TsToken -> Bool
$c>= :: TsToken -> TsToken -> Bool
>= :: TsToken -> TsToken -> Bool
$cmax :: TsToken -> TsToken -> TsToken
max :: TsToken -> TsToken -> TsToken
$cmin :: TsToken -> TsToken -> TsToken
min :: TsToken -> TsToken -> TsToken
Ord, Int -> TsToken -> ShowS
[TsToken] -> ShowS
TsToken -> String
(Int -> TsToken -> ShowS)
-> (TsToken -> String) -> ([TsToken] -> ShowS) -> Show TsToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsToken -> ShowS
showsPrec :: Int -> TsToken -> ShowS
$cshow :: TsToken -> String
show :: TsToken -> String
$cshowList :: [TsToken] -> ShowS
showList :: [TsToken] -> ShowS
Show, ReadPrec [TsToken]
ReadPrec TsToken
Int -> ReadS TsToken
ReadS [TsToken]
(Int -> ReadS TsToken)
-> ReadS [TsToken]
-> ReadPrec TsToken
-> ReadPrec [TsToken]
-> Read TsToken
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsToken
readsPrec :: Int -> ReadS TsToken
$creadList :: ReadS [TsToken]
readList :: ReadS [TsToken]
$creadPrec :: ReadPrec TsToken
readPrec :: ReadPrec TsToken
$creadListPrec :: ReadPrec [TsToken]
readListPrec :: ReadPrec [TsToken]
Read)

instance Categorized TsToken where
  type Categorize TsToken = TsTokenCategory
  categorize :: TsToken -> Categorize TsToken
categorize = TsToken -> Categorize TsToken
TsToken -> TsTokenCategory
tokenCategory

-- | The categories of t'TsToken's, by the TypeScript compiler's names.
data TsTokenCategory
  = WhitespaceTrivia
  | NewLineTrivia
  | SingleLineCommentTrivia
  | MultiLineCommentTrivia
  | Identifier
  | PrivateIdentifier
  | StringLiteral
  | NumericLiteral
  | BigIntLiteral
  | NoSubstitutionTemplateLiteral
  | TemplateHead
  | TemplateMiddle
  | TemplateTail
  | OpenBraceToken
  | CloseBraceToken
  | OpenParenToken
  | CloseParenToken
  | OpenBracketToken
  | CloseBracketToken
  | DotToken
  | DotDotDotToken
  | SemicolonToken
  | CommaToken
  | LessThanToken
  | GreaterThanToken
  | QuestionToken
  | ColonToken
  | EqualsToken
  | EqualsGreaterThanToken
  | BarToken
  | AmpersandToken
  | MinusToken
  | PlusToken
  | AsteriskToken
  | ExclamationToken
  | ClassKeyword
  | ConstKeyword
  | DefaultKeyword
  | EnumKeyword
  | ExportKeyword
  | ExtendsKeyword
  | FalseKeyword
  | FunctionKeyword
  | ImportKeyword
  | InKeyword
  | NewKeyword
  | NullKeyword
  | ThisKeyword
  | TrueKeyword
  | TypeOfKeyword
  | VarKeyword
  | VoidKeyword
  | AbstractKeyword
  | AccessorKeyword
  | AnyKeyword
  | AsKeyword
  | AssertsKeyword
  | BigIntKeyword
  | BooleanKeyword
  | ConstructorKeyword
  | DeclareKeyword
  | FromKeyword
  | GetKeyword
  | GlobalKeyword
  | ImplementsKeyword
  | InferKeyword
  | InterfaceKeyword
  | IntrinsicKeyword
  | IsKeyword
  | KeyOfKeyword
  | LetKeyword
  | ModuleKeyword
  | NamespaceKeyword
  | NeverKeyword
  | NumberKeyword
  | ObjectKeyword
  | OutKeyword
  | OverrideKeyword
  | PrivateKeyword
  | ProtectedKeyword
  | PublicKeyword
  | ReadonlyKeyword
  | RequireKeyword
  | SetKeyword
  | StaticKeyword
  | StringKeyword
  | SymbolKeyword
  | TypeKeyword
  | UndefinedKeyword
  | UniqueKeyword
  | UnknownKeyword
  deriving stock (TsTokenCategory -> TsTokenCategory -> Bool
(TsTokenCategory -> TsTokenCategory -> Bool)
-> (TsTokenCategory -> TsTokenCategory -> Bool)
-> Eq TsTokenCategory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TsTokenCategory -> TsTokenCategory -> Bool
== :: TsTokenCategory -> TsTokenCategory -> Bool
$c/= :: TsTokenCategory -> TsTokenCategory -> Bool
/= :: TsTokenCategory -> TsTokenCategory -> Bool
Eq, Eq TsTokenCategory
Eq TsTokenCategory =>
(TsTokenCategory -> TsTokenCategory -> Ordering)
-> (TsTokenCategory -> TsTokenCategory -> Bool)
-> (TsTokenCategory -> TsTokenCategory -> Bool)
-> (TsTokenCategory -> TsTokenCategory -> Bool)
-> (TsTokenCategory -> TsTokenCategory -> Bool)
-> (TsTokenCategory -> TsTokenCategory -> TsTokenCategory)
-> (TsTokenCategory -> TsTokenCategory -> TsTokenCategory)
-> Ord TsTokenCategory
TsTokenCategory -> TsTokenCategory -> Bool
TsTokenCategory -> TsTokenCategory -> Ordering
TsTokenCategory -> TsTokenCategory -> TsTokenCategory
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
$ccompare :: TsTokenCategory -> TsTokenCategory -> Ordering
compare :: TsTokenCategory -> TsTokenCategory -> Ordering
$c< :: TsTokenCategory -> TsTokenCategory -> Bool
< :: TsTokenCategory -> TsTokenCategory -> Bool
$c<= :: TsTokenCategory -> TsTokenCategory -> Bool
<= :: TsTokenCategory -> TsTokenCategory -> Bool
$c> :: TsTokenCategory -> TsTokenCategory -> Bool
> :: TsTokenCategory -> TsTokenCategory -> Bool
$c>= :: TsTokenCategory -> TsTokenCategory -> Bool
>= :: TsTokenCategory -> TsTokenCategory -> Bool
$cmax :: TsTokenCategory -> TsTokenCategory -> TsTokenCategory
max :: TsTokenCategory -> TsTokenCategory -> TsTokenCategory
$cmin :: TsTokenCategory -> TsTokenCategory -> TsTokenCategory
min :: TsTokenCategory -> TsTokenCategory -> TsTokenCategory
Ord, Int -> TsTokenCategory -> ShowS
[TsTokenCategory] -> ShowS
TsTokenCategory -> String
(Int -> TsTokenCategory -> ShowS)
-> (TsTokenCategory -> String)
-> ([TsTokenCategory] -> ShowS)
-> Show TsTokenCategory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TsTokenCategory -> ShowS
showsPrec :: Int -> TsTokenCategory -> ShowS
$cshow :: TsTokenCategory -> String
show :: TsTokenCategory -> String
$cshowList :: [TsTokenCategory] -> ShowS
showList :: [TsTokenCategory] -> ShowS
Show, ReadPrec [TsTokenCategory]
ReadPrec TsTokenCategory
Int -> ReadS TsTokenCategory
ReadS [TsTokenCategory]
(Int -> ReadS TsTokenCategory)
-> ReadS [TsTokenCategory]
-> ReadPrec TsTokenCategory
-> ReadPrec [TsTokenCategory]
-> Read TsTokenCategory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TsTokenCategory
readsPrec :: Int -> ReadS TsTokenCategory
$creadList :: ReadS [TsTokenCategory]
readList :: ReadS [TsTokenCategory]
$creadPrec :: ReadPrec TsTokenCategory
readPrec :: ReadPrec TsTokenCategory
$creadListPrec :: ReadPrec [TsTokenCategory]
readListPrec :: ReadPrec [TsTokenCategory]
Read, Int -> TsTokenCategory
TsTokenCategory -> Int
TsTokenCategory -> [TsTokenCategory]
TsTokenCategory -> TsTokenCategory
TsTokenCategory -> TsTokenCategory -> [TsTokenCategory]
TsTokenCategory
-> TsTokenCategory -> TsTokenCategory -> [TsTokenCategory]
(TsTokenCategory -> TsTokenCategory)
-> (TsTokenCategory -> TsTokenCategory)
-> (Int -> TsTokenCategory)
-> (TsTokenCategory -> Int)
-> (TsTokenCategory -> [TsTokenCategory])
-> (TsTokenCategory -> TsTokenCategory -> [TsTokenCategory])
-> (TsTokenCategory -> TsTokenCategory -> [TsTokenCategory])
-> (TsTokenCategory
    -> TsTokenCategory -> TsTokenCategory -> [TsTokenCategory])
-> Enum TsTokenCategory
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: TsTokenCategory -> TsTokenCategory
succ :: TsTokenCategory -> TsTokenCategory
$cpred :: TsTokenCategory -> TsTokenCategory
pred :: TsTokenCategory -> TsTokenCategory
$ctoEnum :: Int -> TsTokenCategory
toEnum :: Int -> TsTokenCategory
$cfromEnum :: TsTokenCategory -> Int
fromEnum :: TsTokenCategory -> Int
$cenumFrom :: TsTokenCategory -> [TsTokenCategory]
enumFrom :: TsTokenCategory -> [TsTokenCategory]
$cenumFromThen :: TsTokenCategory -> TsTokenCategory -> [TsTokenCategory]
enumFromThen :: TsTokenCategory -> TsTokenCategory -> [TsTokenCategory]
$cenumFromTo :: TsTokenCategory -> TsTokenCategory -> [TsTokenCategory]
enumFromTo :: TsTokenCategory -> TsTokenCategory -> [TsTokenCategory]
$cenumFromThenTo :: TsTokenCategory
-> TsTokenCategory -> TsTokenCategory -> [TsTokenCategory]
enumFromThenTo :: TsTokenCategory
-> TsTokenCategory -> TsTokenCategory -> [TsTokenCategory]
Enum, TsTokenCategory
TsTokenCategory -> TsTokenCategory -> Bounded TsTokenCategory
forall a. a -> a -> Bounded a
$cminBound :: TsTokenCategory
minBound :: TsTokenCategory
$cmaxBound :: TsTokenCategory
maxBound :: TsTokenCategory
Bounded)

makeNestedPrisms ''TsDeclaration
makeNestedPrisms ''TsModuleName
makeNestedPrisms ''TsImportClause
makeNestedPrisms ''TsNamedBindings
makeNestedPrisms ''TsImportSpecifier
makeNestedPrisms ''TsModuleReference
makeNestedPrisms ''TsExportClause
makeNestedPrisms ''TsVariableDeclaration
makeNestedPrisms ''TsEnumMember
makeNestedPrisms ''TsHeritage
makeNestedPrisms ''TsType
makeNestedPrisms ''TsProperty
makeNestedPrisms ''TsPropertyName
makeNestedPrisms ''TsLiteral
makeNestedPrisms ''TsTypeParameter
makeNestedPrisms ''TsSignature
makeNestedPrisms ''TsParameter
makeNestedPrisms ''TsBindingName
makeNestedPrisms ''TsBindingElement

punctuation :: [(TsTokenCategory, Text)]
punctuation :: [(TsTokenCategory, Text)]
punctuation =
  [ (TsTokenCategory
OpenBraceToken, Text
"{"), (TsTokenCategory
CloseBraceToken, Text
"}")
  , (TsTokenCategory
OpenParenToken, Text
"("), (TsTokenCategory
CloseParenToken, Text
")")
  , (TsTokenCategory
OpenBracketToken, Text
"["), (TsTokenCategory
CloseBracketToken, Text
"]")
  , (TsTokenCategory
DotToken, Text
"."), (TsTokenCategory
DotDotDotToken, Text
"..."), (TsTokenCategory
SemicolonToken, Text
";")
  , (TsTokenCategory
CommaToken, Text
","), (TsTokenCategory
LessThanToken, Text
"<"), (TsTokenCategory
GreaterThanToken, Text
">")
  , (TsTokenCategory
QuestionToken, Text
"?"), (TsTokenCategory
ColonToken, Text
":"), (TsTokenCategory
EqualsToken, Text
"=")
  , (TsTokenCategory
EqualsGreaterThanToken, Text
"=>"), (TsTokenCategory
BarToken, Text
"|"), (TsTokenCategory
AmpersandToken, Text
"&")
  , (TsTokenCategory
MinusToken, Text
"-"), (TsTokenCategory
PlusToken, Text
"+"), (TsTokenCategory
AsteriskToken, Text
"*")
  , (TsTokenCategory
ExclamationToken, Text
"!")
  ]

-- | Keywords which aren't identifiers.
reservedWords :: [(TsTokenCategory, Text)]
reservedWords :: [(TsTokenCategory, Text)]
reservedWords =
  [ (TsTokenCategory
ClassKeyword, Text
"class"), (TsTokenCategory
ConstKeyword, Text
"const")
  , (TsTokenCategory
DefaultKeyword, Text
"default"), (TsTokenCategory
EnumKeyword, Text
"enum")
  , (TsTokenCategory
ExportKeyword, Text
"export"), (TsTokenCategory
ExtendsKeyword, Text
"extends")
  , (TsTokenCategory
FalseKeyword, Text
"false"), (TsTokenCategory
FunctionKeyword, Text
"function")
  , (TsTokenCategory
ImportKeyword, Text
"import"), (TsTokenCategory
InKeyword, Text
"in"), (TsTokenCategory
NewKeyword, Text
"new")
  , (TsTokenCategory
NullKeyword, Text
"null"), (TsTokenCategory
ThisKeyword, Text
"this"), (TsTokenCategory
TrueKeyword, Text
"true")
  , (TsTokenCategory
TypeOfKeyword, Text
"typeof"), (TsTokenCategory
VarKeyword, Text
"var"), (TsTokenCategory
VoidKeyword, Text
"void")
  ]

-- | Keywords which are also identifiers, by their context.
contextualKeywords :: [(TsTokenCategory, Text)]
contextualKeywords :: [(TsTokenCategory, Text)]
contextualKeywords =
  [ (TsTokenCategory
AbstractKeyword, Text
"abstract"), (TsTokenCategory
AccessorKeyword, Text
"accessor")
  , (TsTokenCategory
AnyKeyword, Text
"any"), (TsTokenCategory
AsKeyword, Text
"as"), (TsTokenCategory
AssertsKeyword, Text
"asserts")
  , (TsTokenCategory
BigIntKeyword, Text
"bigint"), (TsTokenCategory
BooleanKeyword, Text
"boolean")
  , (TsTokenCategory
ConstructorKeyword, Text
"constructor"), (TsTokenCategory
DeclareKeyword, Text
"declare")
  , (TsTokenCategory
FromKeyword, Text
"from"), (TsTokenCategory
GetKeyword, Text
"get"), (TsTokenCategory
GlobalKeyword, Text
"global")
  , (TsTokenCategory
ImplementsKeyword, Text
"implements"), (TsTokenCategory
InferKeyword, Text
"infer")
  , (TsTokenCategory
InterfaceKeyword, Text
"interface"), (TsTokenCategory
IntrinsicKeyword, Text
"intrinsic")
  , (TsTokenCategory
IsKeyword, Text
"is"), (TsTokenCategory
KeyOfKeyword, Text
"keyof"), (TsTokenCategory
LetKeyword, Text
"let")
  , (TsTokenCategory
ModuleKeyword, Text
"module"), (TsTokenCategory
NamespaceKeyword, Text
"namespace")
  , (TsTokenCategory
NeverKeyword, Text
"never"), (TsTokenCategory
NumberKeyword, Text
"number")
  , (TsTokenCategory
ObjectKeyword, Text
"object"), (TsTokenCategory
OutKeyword, Text
"out")
  , (TsTokenCategory
OverrideKeyword, Text
"override"), (TsTokenCategory
PrivateKeyword, Text
"private")
  , (TsTokenCategory
ProtectedKeyword, Text
"protected"), (TsTokenCategory
PublicKeyword, Text
"public")
  , (TsTokenCategory
ReadonlyKeyword, Text
"readonly"), (TsTokenCategory
RequireKeyword, Text
"require")
  , (TsTokenCategory
SetKeyword, Text
"set"), (TsTokenCategory
StaticKeyword, Text
"static")
  , (TsTokenCategory
StringKeyword, Text
"string"), (TsTokenCategory
SymbolKeyword, Text
"symbol")
  , (TsTokenCategory
TypeKeyword, Text
"type"), (TsTokenCategory
UndefinedKeyword, Text
"undefined")
  , (TsTokenCategory
UniqueKeyword, Text
"unique"), (TsTokenCategory
UnknownKeyword, Text
"unknown")
  ]

keywords :: [(TsTokenCategory, Text)]
keywords :: [(TsTokenCategory, Text)]
keywords = [(TsTokenCategory, Text)]
reservedWords [(TsTokenCategory, Text)]
-> [(TsTokenCategory, Text)] -> [(TsTokenCategory, Text)]
forall a. Semigroup a => a -> a -> a
<> [(TsTokenCategory, Text)]
contextualKeywords

-- | The token of a punctuation or keyword category.
symbol :: TsTokenCategory -> TsToken
symbol :: TsTokenCategory -> TsToken
symbol TsTokenCategory
category =
  TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
category (Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" (TsTokenCategory -> [(TsTokenCategory, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup TsTokenCategory
category ([(TsTokenCategory, Text)]
punctuation [(TsTokenCategory, Text)]
-> [(TsTokenCategory, Text)] -> [(TsTokenCategory, Text)]
forall a. Semigroup a => a -> a -> a
<> [(TsTokenCategory, Text)]
keywords)))

-- | One of some punctuation tokens, by its category.
symbolOf :: [TsTokenCategory] -> Prism' TsToken TsTokenCategory
symbolOf :: [TsTokenCategory] -> Prism' TsToken TsTokenCategory
symbolOf [TsTokenCategory]
categories = (TsTokenCategory -> TsToken)
-> (TsToken -> Maybe TsTokenCategory)
-> Prism' TsToken TsTokenCategory
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' TsTokenCategory -> TsToken
symbol ((TsToken -> Maybe TsTokenCategory)
 -> Prism' TsToken TsTokenCategory)
-> (TsToken -> Maybe TsTokenCategory)
-> Prism' TsToken TsTokenCategory
forall a b. (a -> b) -> a -> b
$ \TsToken
t ->
  if TsToken -> TsTokenCategory
tokenCategory TsToken
t TsTokenCategory -> [TsTokenCategory] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [TsTokenCategory]
categories Bool -> Bool -> Bool
&& TsToken
t TsToken -> TsToken -> Bool
forall a. Eq a => a -> a -> Bool
== TsTokenCategory -> TsToken
symbol (TsToken -> TsTokenCategory
tokenCategory TsToken
t)
    then TsTokenCategory -> Maybe TsTokenCategory
forall a. a -> Maybe a
Just (TsToken -> TsTokenCategory
tokenCategory TsToken
t) else Maybe TsTokenCategory
forall a. Maybe a
Nothing

{- | A token, scanned from its characters. Its trivia, whitespace,
newlines & comments, are tokens, as the scanner of the TypeScript compiler
scans without skipping them. A @}@ is never a template's middle or tail,
which `tsTokensGrammar` rescans in its context, as the compiler's parser
rescans it.

A number is spelled by its digits, letters, separators & points,
as in @0xFF@, @1_000.5@ or @1n@, but not by a signed exponent.

It's a `RegGrammar`, since each token's spelling is a regular language.
-}
tsTokenGrammar :: RegGrammar Char TsToken
tsTokenGrammar :: RegGrammar Char TsToken
tsTokenGrammar = [p TsToken TsToken] -> p TsToken TsToken
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ TsTokenCategory -> Prism' TsToken String
kindOf TsTokenCategory
WhitespaceTrivia (Market String String String (Identity String)
 -> Market String String TsToken (Identity TsToken))
-> p String String -> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Alternator p => p a b -> p [a] [b]
someP (forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
oneOf @Char (String
" \t\f\v" :: String))
  , TsTokenCategory -> Prism' TsToken String
kindOf TsTokenCategory
NewLineTrivia (Market String String String (Identity String)
 -> Market String String TsToken (Identity TsToken))
-> p String String -> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? [p String String] -> p String String
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [String -> Prism' String ()
forall a. Eq a => a -> Prism' a ()
only String
"\n" (Market () () () (Identity ())
 -> Market () () String (Identity String))
-> p () () -> p String String
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"\n", String -> Prism' String ()
forall a. Eq a => a -> Prism' a ()
only String
"\r\n" (Market () () () (Identity ())
 -> Market () () String (Identity String))
-> p () () -> p String String
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"\r\n"]
  , Market
  (Either String String)
  (Either String String)
  (Either String String)
  (Identity (Either String String))
-> Market
     (Either String String)
     (Either String String)
     TsToken
     (Identity TsToken)
Prism' TsToken (Either String String)
_Comment (Market
   (Either String String)
   (Either String String)
   (Either String String)
   (Identity (Either String String))
 -> Market
      (Either String String)
      (Either String String)
      TsToken
      (Identity TsToken))
-> p (Either String String) (Either String String)
-> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"/" p () ()
-> p (Either String String) (Either String String)
-> p (Either String String) (Either String String)
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p (Either String String) (Either String String)]
-> p (Either String String) (Either String String)
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Market String String String (Identity String)
-> Market
     String
     String
     (Either String String)
     (Identity (Either String String))
forall a c b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Either a c) (f (Either b c))
_Left (Market String String String (Identity String)
 -> Market
      String
      String
      (Either String String)
      (Identity (Either String String)))
-> p String String
-> p (Either String String) (Either String String)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"/" p () () -> p String String -> p String String
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
notOneOf @Char (String
"\r\n" :: String))
      , Market String String String (Identity String)
-> Market
     String
     String
     (Either String String)
     (Identity (Either String String))
forall c a b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Either c a) (f (Either c b))
_Right (Market String String String (Identity String)
 -> Market
      String
      String
      (Either String String)
      (Identity (Either String String)))
-> p String String
-> p (Either String String) (Either String String)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p String String
blockComment
      ]
  , Market String String String (Identity String)
-> Market String String TsToken (Identity TsToken)
Prism' TsToken String
_Word (Market String String String (Identity String)
 -> Market String String TsToken (Identity TsToken))
-> p String String -> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Char Char
RegGrammar Char Char
identifierStart p Char Char -> p String String -> p String String
forall s t a b (p :: * -> * -> *).
(Cons s t a b, Monoidal p, Choice p) =>
p a b -> p s t -> p s t
>:< p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP p Char Char
identifierPart
  , TsTokenCategory -> Prism' TsToken String
kindOf TsTokenCategory
PrivateIdentifier (Market String String String (Identity String)
 -> Market String String TsToken (Identity TsToken))
-> p String String -> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"#"
      p () () -> p String String -> p String String
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* (p Char Char
RegGrammar Char Char
identifierStart p Char Char -> p String String -> p String String
forall s t a b (p :: * -> * -> *).
(Cons s t a b, Monoidal p, Choice p) =>
p a b -> p s t -> p s t
>:< p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP p Char Char
identifierPart)
  , Market String String String (Identity String)
-> Market String String TsToken (Identity TsToken)
Prism' TsToken String
_Number (Market String String String (Identity String)
 -> Market String String TsToken (Identity TsToken))
-> p String String -> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
DecimalNumber p Char Char -> p String String -> p String String
forall s t a b (p :: * -> * -> *).
(Cons s t a b, Monoidal p, Choice p) =>
p a b -> p s t -> p s t
>:< p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP p Char Char
numberPart
  , TsTokenCategory -> Prism' TsToken String
kindOf TsTokenCategory
StringLiteral (Market String String String (Identity String)
 -> Market String String TsToken (Identity TsToken))
-> p String String -> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? [p String String] -> p String String
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"\"" p () () -> p String String -> p String String
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (Char -> RegGrammar Char Char
stringChar Char
'"') p String String -> p () () -> p String String
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"\""
      , String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"'" p () () -> p String String -> p String String
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (Char -> RegGrammar Char Char
stringChar Char
'\'') p String String -> p () () -> p String String
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"'"
      ]
  , Market
  (String, TsTokenCategory)
  (String, TsTokenCategory)
  (String, TsTokenCategory)
  (Identity (String, TsTokenCategory))
-> Market
     (String, TsTokenCategory)
     (String, TsTokenCategory)
     TsToken
     (Identity TsToken)
Prism' TsToken (String, TsTokenCategory)
_Template (Market
   (String, TsTokenCategory)
   (String, TsTokenCategory)
   (String, TsTokenCategory)
   (Identity (String, TsTokenCategory))
 -> Market
      (String, TsTokenCategory)
      (String, TsTokenCategory)
      TsToken
      (Identity TsToken))
-> p (String, TsTokenCategory) (String, TsTokenCategory)
-> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"`" p () () -> p String String -> p String String
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP p Char Char
RegGrammar Char Char
templateChar p String String
-> p TsTokenCategory TsTokenCategory
-> p (String, TsTokenCategory) (String, TsTokenCategory)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
NoSubstitutionTemplateLiteral (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"`"
      , TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
TemplateHead (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"${"
      ]
  , [TsTokenCategory] -> Prism' TsToken TsTokenCategory
symbolOf [TsTokenCategory
DotToken, TsTokenCategory
DotDotDotToken] (Market
   TsTokenCategory
   TsTokenCategory
   TsTokenCategory
   (Identity TsTokenCategory)
 -> Market
      TsTokenCategory TsTokenCategory TsToken (Identity TsToken))
-> p TsTokenCategory TsTokenCategory -> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"." p () ()
-> p TsTokenCategory TsTokenCategory
-> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
DotDotDotToken (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"..", TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
DotToken (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP]
  , [TsTokenCategory] -> Prism' TsToken TsTokenCategory
symbolOf [TsTokenCategory
EqualsToken, TsTokenCategory
EqualsGreaterThanToken] (Market
   TsTokenCategory
   TsTokenCategory
   TsTokenCategory
   (Identity TsTokenCategory)
 -> Market
      TsTokenCategory TsTokenCategory TsToken (Identity TsToken))
-> p TsTokenCategory TsTokenCategory -> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"=" p () ()
-> p TsTokenCategory TsTokenCategory
-> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
EqualsGreaterThanToken (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
">", TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
EqualsToken (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP]
  , [p TsToken TsToken] -> p TsToken TsToken
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ TsToken -> Prism' TsToken ()
forall a. Eq a => a -> Prism' a ()
only (TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
category Text
text) (Market () () () (Identity ())
 -> Market () () TsToken (Identity TsToken))
-> p () () -> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal (Text -> String
Text.unpack Text
text)
      | (TsTokenCategory
category, Text
text) <- [(TsTokenCategory, Text)]
punctuation
      , TsTokenCategory
category TsTokenCategory -> [TsTokenCategory] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem`
          [TsTokenCategory
DotToken, TsTokenCategory
DotDotDotToken, TsTokenCategory
EqualsToken, TsTokenCategory
EqualsGreaterThanToken]
      ]
  ]
  where
    identifierPart :: p Char Char
identifierPart = [p Char Char] -> p Char Char
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ p Char Char
RegGrammar Char Char
identifierStart, forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
DecimalNumber, forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
NonSpacingMark
      , forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
SpacingCombiningMark, forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
ConnectorPunctuation
      ]
    numberPart :: p Char Char
numberPart = [p Char Char] -> p Char Char
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
DecimalNumber, forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
UppercaseLetter
      , forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
LowercaseLetter, forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
oneOf @Char (String
"_." :: String)
      ]
    -- @\*[^*]*\*+([^*/][^*]*\*+)*\/@, after its first @/@.
    blockComment :: p String String
blockComment = Market
  (String, (String, [(Char, (String, String))]))
  (String, (String, [(Char, (String, String))]))
  (String, (String, [(Char, (String, String))]))
  (Identity (String, (String, [(Char, (String, String))])))
-> Market
     (String, (String, [(Char, (String, String))]))
     (String, (String, [(Char, (String, String))]))
     String
     (Identity String)
Prism' String (String, (String, [(Char, (String, String))]))
_BlockComment (Market
   (String, (String, [(Char, (String, String))]))
   (String, (String, [(Char, (String, String))]))
   (String, (String, [(Char, (String, String))]))
   (Identity (String, (String, [(Char, (String, String))])))
 -> Market
      (String, (String, [(Char, (String, String))]))
      (String, (String, [(Char, (String, String))]))
      String
      (Identity String))
-> p (String, (String, [(Char, (String, String))]))
     (String, (String, [(Char, (String, String))]))
-> p String String
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"*"
      p () () -> p String String -> p String String
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
notOneOf @Char (String
"*" :: String))
      p String String
-> p (String, [(Char, (String, String))])
     (String, [(Char, (String, String))])
-> p (String, (String, [(Char, (String, String))]))
     (String, (String, [(Char, (String, String))]))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Alternator p => p a b -> p [a] [b]
someP (Char -> p Char Char
forall token p. Tokenized token p => token -> p
token Char
'*')
      p String String
-> p [(Char, (String, String))] [(Char, (String, String))]
-> p (String, [(Char, (String, String))])
     (String, [(Char, (String, String))])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p (Char, (String, String)) (Char, (String, String))
-> p [(Char, (String, String))] [(Char, (String, String))]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP
        ( forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
notOneOf @Char (String
"*/" :: String)
          p Char Char
-> p (String, String) (String, String)
-> p (Char, (String, String)) (Char, (String, String))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
notOneOf @Char (String
"*" :: String))
          p String String
-> p String String -> p (String, String) (String, String)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Alternator p => p a b -> p [a] [b]
someP (Char -> p Char Char
forall token p. Tokenized token p => token -> p
token Char
'*')
        )
      p [(Char, (String, String))] [(Char, (String, String))]
-> p () ()
-> p [(Char, (String, String))] [(Char, (String, String))]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"/"

identifierStart :: RegGrammar Char Char
identifierStart :: RegGrammar Char Char
identifierStart = [p Char Char] -> p Char Char
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
UppercaseLetter, forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
LowercaseLetter
  , forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
TitlecaseLetter, forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
ModifierLetter
  , forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
OtherLetter, forall token p. Tokenized token p => Categorize token -> p
asIn @Char GeneralCategory
Categorize Char
LetterNumber
  , forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
oneOf @Char (String
"_$" :: String)
  ]

stringChar :: Char -> RegGrammar Char Char
stringChar :: Char -> RegGrammar Char Char
stringChar Char
quote = [p Char Char] -> p Char Char
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
notOneOf @Char (Char
quote Char -> ShowS
forall a. a -> [a] -> [a]
: Char
'\\' Char -> ShowS
forall a. a -> [a] -> [a]
: [Char
'\0' .. Char
'\31'])
  , String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"\\" p () () -> p Char Char -> p Char Char
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p Char Char] -> p Char Char
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
oneOf @Char (String
"\"\\/'" :: String)
      , Char -> Prism' Char ()
forall a. Eq a => a -> Prism' a ()
only Char
'\b' (Market () () () (Identity ())
 -> Market () () Char (Identity Char))
-> p () () -> p Char Char
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"b", Char -> Prism' Char ()
forall a. Eq a => a -> Prism' a ()
only Char
'\f' (Market () () () (Identity ())
 -> Market () () Char (Identity Char))
-> p () () -> p Char Char
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"f"
      , Char -> Prism' Char ()
forall a. Eq a => a -> Prism' a ()
only Char
'\n' (Market () () () (Identity ())
 -> Market () () Char (Identity Char))
-> p () () -> p Char Char
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"n", Char -> Prism' Char ()
forall a. Eq a => a -> Prism' a ()
only Char
'\r' (Market () () () (Identity ())
 -> Market () () Char (Identity Char))
-> p () () -> p Char Char
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"r"
      , Char -> Prism' Char ()
forall a. Eq a => a -> Prism' a ()
only Char
'\t' (Market () () () (Identity ())
 -> Market () () Char (Identity Char))
-> p () () -> p Char Char
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"t"
      , String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"u" p () () -> p Char Char -> p Char Char
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* (Market String String String (Identity String)
-> Market String String Char (Identity Char)
Prism' Char String
_HexCode (Market String String String (Identity String)
 -> Market String String Char (Identity Char))
-> p String String -> p Char Char
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? Int -> p Char Char -> p String String
forall (p :: * -> * -> *) s a.
(Monoidal p, Choice p, AsEmpty s, Cons s s a a) =>
Int -> p a a -> p s s
replicateP Int
4 (forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
oneOf @Char String
hexDigits))
      ]
  ]
  where
    hexDigits :: String
hexDigits = String
"0123456789abcdefABCDEF" :: String

templateChar :: RegGrammar Char Char
templateChar :: RegGrammar Char Char
templateChar = [p Char Char] -> p Char Char
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
notOneOf @Char (String
"`$\\" :: String)
  , String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"\\" p () () -> p Char Char -> p Char Char
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* forall token p (f :: * -> *).
(Tokenized token p, Foldable f) =>
f token -> p
oneOf @Char (String
"`$\\" :: String)
  ]

{- | Tokens, scanned from their characters without their trivia,
as the TypeScript compiler's scanner skips trivia, & printed with them,
as `tsGrammar` prints them, so that `tsGrammar` parses by `parsecG`.
A @}@ which closes a template's substitution is scanned as the template's
middle or tail, by the depth of braces within the substitutions open,
as the compiler's parser rescans it.

It's a `CtxGrammar` by monadic bonding: each token is scanned in the
context of the tokens before it, whose braces & templates bond, by
@P.@`Data.Profunctor.Monadic.Do.>>=`, the depths that a @}@ is scanned by.
-}
tsTokensGrammar :: CtxGrammar Char [TsToken]
tsTokensGrammar :: CtxGrammar Char [TsToken]
tsTokensGrammar = ([TsToken] -> [TsToken])
-> p [TsToken] [TsToken] -> p [TsToken] [TsToken]
forall b c a. (b -> c) -> p a b -> p a c
forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap
  (\[TsToken]
scanned -> [TsToken
t | TsToken
t <- [TsToken]
scanned, TsToken -> TsTokenCategory
tokenCategory TsToken
t TsTokenCategory -> [TsTokenCategory] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [TsTokenCategory]
trivial])
  ([Int] -> p [TsToken] [TsToken]
forall (p :: * -> * -> *).
(Lexical Char p, Alternator p, Filtrator p, MonadicTry p) =>
[Int] -> p [TsToken] [TsToken]
tokensWithin [])
  where
    trivial :: [TsTokenCategory]
trivial =
      [ TsTokenCategory
WhitespaceTrivia, TsTokenCategory
NewLineTrivia
      , TsTokenCategory
SingleLineCommentTrivia, TsTokenCategory
MultiLineCommentTrivia
      ]

{- | Tokens, within the substitutions of templates, by the depth of braces
within each, innermost first.
-}
tokensWithin
  :: (Lexical Char p, Alternator p, Filtrator p, MonadicTry p)
  => [Int] -> p [TsToken] [TsToken]
tokensWithin :: forall (p :: * -> * -> *).
(Lexical Char p, Alternator p, Filtrator p, MonadicTry p) =>
[Int] -> p [TsToken] [TsToken]
tokensWithin [Int]
depths = [p [TsToken] [TsToken]] -> p [TsToken] [TsToken]
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market
  (TsToken, [TsToken])
  (TsToken, [TsToken])
  (TsToken, [TsToken])
  (Identity (TsToken, [TsToken]))
-> Market
     (TsToken, [TsToken])
     (TsToken, [TsToken])
     [TsToken]
     (Identity [TsToken])
forall s t a b. Cons s t a b => Prism s t (a, s) (b, t)
Prism [TsToken] [TsToken] (TsToken, [TsToken]) (TsToken, [TsToken])
_Cons (Market
   (TsToken, [TsToken])
   (TsToken, [TsToken])
   (TsToken, [TsToken])
   (Identity (TsToken, [TsToken]))
 -> Market
      (TsToken, [TsToken])
      (TsToken, [TsToken])
      [TsToken]
      (Identity [TsToken]))
-> p (TsToken, [TsToken]) (TsToken, [TsToken])
-> p [TsToken] [TsToken]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? (p TsToken TsToken
tokenWithin p TsToken TsToken
-> (TsToken -> p [TsToken] [TsToken])
-> p (TsToken, [TsToken]) (TsToken, [TsToken])
forall (p :: * -> * -> *) a b c d.
Monadic p =>
p a b -> (b -> p c d) -> p (a, c) (b, d)
P.>>= [Int] -> p [TsToken] [TsToken]
forall (p :: * -> * -> *).
(Lexical Char p, Alternator p, Filtrator p, MonadicTry p) =>
[Int] -> p [TsToken] [TsToken]
tokensWithin ([Int] -> p [TsToken] [TsToken])
-> (TsToken -> [Int]) -> TsToken -> p [TsToken] [TsToken]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> TsToken -> [Int]
forall {a}. Num a => [a] -> TsToken -> [a]
within [Int]
depths)
  , Market () () () (Identity ())
-> Market () () [TsToken] (Identity [TsToken])
forall a. AsEmpty a => Prism' a ()
Prism' [TsToken] ()
_Empty (Market () () () (Identity ())
 -> Market () () [TsToken] (Identity [TsToken]))
-> p () () -> p [TsToken] [TsToken]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]
  where
    tokenWithin :: p TsToken TsToken
tokenWithin = case [Int]
depths of
      Int
0 : [Int]
_ -> [p TsToken TsToken] -> p TsToken TsToken
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP [p TsToken TsToken
templateContinuation, p TsToken TsToken
RegGrammar Char TsToken
tsTokenGrammar]
      [Int]
_ -> p TsToken TsToken
RegGrammar Char TsToken
tsTokenGrammar
    templateContinuation :: p TsToken TsToken
templateContinuation = Market
  (String, TsTokenCategory)
  (String, TsTokenCategory)
  (String, TsTokenCategory)
  (Identity (String, TsTokenCategory))
-> Market
     (String, TsTokenCategory)
     (String, TsTokenCategory)
     TsToken
     (Identity TsToken)
Prism' TsToken (String, TsTokenCategory)
_Template (Market
   (String, TsTokenCategory)
   (String, TsTokenCategory)
   (String, TsTokenCategory)
   (Identity (String, TsTokenCategory))
 -> Market
      (String, TsTokenCategory)
      (String, TsTokenCategory)
      TsToken
      (Identity TsToken))
-> p (String, TsTokenCategory) (String, TsTokenCategory)
-> p TsToken TsToken
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"}"
      p () () -> p String String -> p String String
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Char Char -> p String String
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP p Char Char
RegGrammar Char Char
templateChar p String String
-> p TsTokenCategory TsTokenCategory
-> p (String, TsTokenCategory) (String, TsTokenCategory)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
        [ TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
TemplateTail (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"`"
        , TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
TemplateMiddle (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? String -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal String
"${"
        ]
    within :: [a] -> TsToken -> [a]
within [a]
ds (TsToken TsTokenCategory
category Text
_) = case (TsTokenCategory
category, [a]
ds) of
      (TsTokenCategory
TemplateHead, [a]
_) -> a
0 a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
ds
      (TsTokenCategory
TemplateTail, [a]
_) -> Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop Int
1 [a]
ds
      (TsTokenCategory
OpenBraceToken, a
d : [a]
others) -> a
d a -> a -> a
forall a. Num a => a -> a -> a
+ a
1 a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
others
      (TsTokenCategory
CloseBraceToken, a
d : [a]
others) -> a
d a -> a -> a
forall a. Num a => a -> a -> a
- a
1 a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
others
      (TsTokenCategory, [a])
_ -> [a]
ds

-- | A token of a category, by its text.
kindOf :: TsTokenCategory -> Prism' TsToken String
kindOf :: TsTokenCategory -> Prism' TsToken String
kindOf TsTokenCategory
category = (String -> TsToken)
-> (TsToken -> Maybe String) -> Prism' TsToken String
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
category (Text -> TsToken) -> (String -> Text) -> String -> TsToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Text.pack)
  (\(TsToken TsTokenCategory
category' Text
text) ->
    if TsTokenCategory
category TsTokenCategory -> TsTokenCategory -> Bool
forall a. Eq a => a -> a -> Bool
== TsTokenCategory
category' then String -> Maybe String
forall a. a -> Maybe a
Just (Text -> String
Text.unpack Text
text) else Maybe String
forall a. Maybe a
Nothing)

-- | An identifier or keyword, by its text.
_Word :: Prism' TsToken String
_Word :: Prism' TsToken String
_Word = (String -> TsToken)
-> (TsToken -> Maybe String) -> Prism' TsToken String
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' String -> TsToken
word ((TsToken -> Maybe String) -> Prism' TsToken String)
-> (TsToken -> Maybe String) -> Prism' TsToken String
forall a b. (a -> b) -> a -> b
$ \(TsToken TsTokenCategory
category Text
text) ->
  if TsTokenCategory
category TsTokenCategory -> TsTokenCategory -> Bool
forall a. Eq a => a -> a -> Bool
== TsTokenCategory
Identifier Bool -> Bool -> Bool
|| TsTokenCategory
category TsTokenCategory -> [TsTokenCategory] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` ((TsTokenCategory, Text) -> TsTokenCategory)
-> [(TsTokenCategory, Text)] -> [TsTokenCategory]
forall a b. (a -> b) -> [a] -> [b]
map (TsTokenCategory, Text) -> TsTokenCategory
forall a b. (a, b) -> a
fst [(TsTokenCategory, Text)]
keywords
    then String -> Maybe String
forall a. a -> Maybe a
Just (Text -> String
Text.unpack Text
text) else Maybe String
forall a. Maybe a
Nothing
  where
    word :: String -> TsToken
word String
chars = case Text -> [(Text, TsTokenCategory)] -> Maybe TsTokenCategory
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
text [(Text
t, TsTokenCategory
k) | (TsTokenCategory
k, Text
t) <- [(TsTokenCategory, Text)]
keywords] of
      Just TsTokenCategory
category -> TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
category Text
text
      Maybe TsTokenCategory
Nothing -> TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
Identifier Text
text
      where
        text :: Text
text = String -> Text
Text.pack String
chars

-- | A number, or a big integer, which ends in @n@, by its spelling.
_Number :: Prism' TsToken String
_Number :: Prism' TsToken String
_Number = (String -> TsToken)
-> (TsToken -> Maybe String) -> Prism' TsToken String
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' String -> TsToken
number ((TsToken -> Maybe String) -> Prism' TsToken String)
-> (TsToken -> Maybe String) -> Prism' TsToken String
forall a b. (a -> b) -> a -> b
$ \case
  TsToken TsTokenCategory
NumericLiteral Text
text -> String -> Maybe String
forall a. a -> Maybe a
Just (Text -> String
Text.unpack Text
text)
  TsToken TsTokenCategory
BigIntLiteral Text
text -> String -> Maybe String
forall a. a -> Maybe a
Just (Text -> String
Text.unpack Text
text)
  TsToken
_ -> Maybe String
forall a. Maybe a
Nothing
  where
    number :: String -> TsToken
number String
chars
      | Bool -> Bool
not (String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
chars) Bool -> Bool -> Bool
&& String -> Char
forall a. HasCallStack => [a] -> a
last String
chars Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'n' Bool -> Bool -> Bool
&& Char
'.' Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` String
chars =
          TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
BigIntLiteral (String -> Text
Text.pack String
chars)
      | Bool
otherwise = TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
NumericLiteral (String -> Text
Text.pack String
chars)

{- | A comment, by its text after its first @/@, of a line, after @//@,
or of a block, from its @*@.
-}
_Comment :: Prism' TsToken (Either String String)
_Comment :: Prism' TsToken (Either String String)
_Comment = (Either String String -> TsToken)
-> (TsToken -> Maybe (Either String String))
-> Prism' TsToken (Either String String)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\case
    Left String
line -> TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
SingleLineCommentTrivia (String -> Text
Text.pack (String
"//" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
line))
    Right String
block' -> TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
MultiLineCommentTrivia (String -> Text
Text.pack (Char
'/' Char -> ShowS
forall a. a -> [a] -> [a]
: String
block')))
  (\case
    TsToken TsTokenCategory
SingleLineCommentTrivia Text
text ->
      String -> Either String String
forall a b. a -> Either a b
Left (String -> Either String String)
-> (Text -> String) -> Text -> Either String String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Either String String)
-> Maybe Text -> Maybe (Either String String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Text -> Maybe Text
Text.stripPrefix Text
"//" Text
text
    TsToken TsTokenCategory
MultiLineCommentTrivia Text
text ->
      String -> Either String String
forall a b. b -> Either a b
Right (String -> Either String String)
-> (Text -> String) -> Text -> Either String String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Either String String)
-> Maybe Text -> Maybe (Either String String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Text -> Maybe Text
Text.stripPrefix Text
"/" Text
text
    TsToken
_ -> Maybe (Either String String)
forall a. Maybe a
Nothing)

{- | A block comment's text, from its @*@, by the parts of
@\*[^*]*\*+([^*/][^*]*\*+)*\/@.
-}
_BlockComment
  :: Prism' String (String, (String, [(Char, (String, String))]))
_BlockComment :: Prism' String (String, (String, [(Char, (String, String))]))
_BlockComment = ((String, (String, [(Char, (String, String))])) -> String)
-> (String -> Maybe (String, (String, [(Char, (String, String))])))
-> Prism' String (String, (String, [(Char, (String, String))]))
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (String, (String, [(Char, (String, String))])) -> String
build String -> Maybe (String, (String, [(Char, (String, String))]))
split
  where
    build :: (String, (String, [(Char, (String, String))])) -> String
build (String
start, (String
stars, [(Char, (String, String))]
others)) = Char
'*' Char -> ShowS
forall a. a -> [a] -> [a]
: String
start String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
stars
      String -> ShowS
forall a. Semigroup a => a -> a -> a
<> [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [Char
c Char -> ShowS
forall a. a -> [a] -> [a]
: String
text String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
more | (Char
c, (String
text, String
more)) <- [(Char, (String, String))]
others] String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"/"
    split :: String -> Maybe (String, (String, [(Char, (String, String))]))
split = \case
      Char
'*' : String
str | Bool -> Bool
not (String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
str), String -> Char
forall a. HasCallStack => [a] -> a
last String
str Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'/' -> String -> Maybe (String, (String, [(Char, (String, String))]))
body (ShowS
forall a. HasCallStack => [a] -> [a]
init String
str)
      String
_ -> Maybe (String, (String, [(Char, (String, String))]))
forall a. Maybe a
Nothing
    body :: String -> Maybe (String, (String, [(Char, (String, String))]))
body String
str =
      let
        (String
start, String
rest) = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'*') String
str
        (String
stars, String
others) = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
span (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'*') String
rest
      in
        if String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
stars then Maybe (String, (String, [(Char, (String, String))]))
forall a. Maybe a
Nothing else (String
start,) ((String, [(Char, (String, String))])
 -> (String, (String, [(Char, (String, String))])))
-> ([(Char, (String, String))]
    -> (String, [(Char, (String, String))]))
-> [(Char, (String, String))]
-> (String, (String, [(Char, (String, String))]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
stars,) ([(Char, (String, String))]
 -> (String, (String, [(Char, (String, String))])))
-> Maybe [(Char, (String, String))]
-> Maybe (String, (String, [(Char, (String, String))]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Maybe [(Char, (String, String))]
pieces String
others
    pieces :: String -> Maybe [(Char, (String, String))]
pieces = \case
      [] -> [(Char, (String, String))] -> Maybe [(Char, (String, String))]
forall a. a -> Maybe a
Just []
      Char
c : String
str | Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
'*', Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
'/' ->
        let
          (String
text, String
rest) = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'*') String
str
          (String
more, String
others) = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
span (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'*') String
rest
        in
          if String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
more then Maybe [(Char, (String, String))]
forall a. Maybe a
Nothing
          else ((Char
c, (String
text, String
more)) (Char, (String, String))
-> [(Char, (String, String))] -> [(Char, (String, String))]
forall a. a -> [a] -> [a]
:) ([(Char, (String, String))] -> [(Char, (String, String))])
-> Maybe [(Char, (String, String))]
-> Maybe [(Char, (String, String))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Maybe [(Char, (String, String))]
pieces String
others
      String
_ -> Maybe [(Char, (String, String))]
forall a. Maybe a
Nothing

-- | A template's literal & its category.
_Template :: Prism' TsToken (String, TsTokenCategory)
_Template :: Prism' TsToken (String, TsTokenCategory)
_Template = ((String, TsTokenCategory) -> TsToken)
-> (TsToken -> Maybe (String, TsTokenCategory))
-> Prism' TsToken (String, TsTokenCategory)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\(String
chars, TsTokenCategory
category) -> TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
category (String -> Text
Text.pack String
chars))
  (\(TsToken TsTokenCategory
category Text
text) ->
    if TsTokenCategory
category TsTokenCategory -> [TsTokenCategory] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [TsTokenCategory]
templates
      then (String, TsTokenCategory) -> Maybe (String, TsTokenCategory)
forall a. a -> Maybe a
Just (Text -> String
Text.unpack Text
text, TsTokenCategory
category) else Maybe (String, TsTokenCategory)
forall a. Maybe a
Nothing)
  where
    templates :: [TsTokenCategory]
templates =
      [TsTokenCategory
NoSubstitutionTemplateLiteral, TsTokenCategory
TemplateHead, TsTokenCategory
TemplateMiddle, TsTokenCategory
TemplateTail]

-- | A character, by the hexadecimal digits of a @\\u@ escape.
_HexCode :: Prism' Char String
_HexCode :: Prism' Char String
_HexCode = (String -> Char) -> (Char -> Maybe String) -> Prism' Char String
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\String
digits -> Int -> Char
chr (Int -> ((Int, String) -> Int) -> Maybe (Int, String) -> Int
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int
0 (Int, String) -> Int
forall a b. (a, b) -> a
fst ([(Int, String)] -> Maybe (Int, String)
forall a. [a] -> Maybe a
listToMaybe (ReadS Int
forall a. (Eq a, Num a) => ReadS a
readHex String
digits))))
  (\Char
c -> if Char -> Int
ord Char
c Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0x10000
    then String -> Maybe String
forall a. a -> Maybe a
Just (ShowS
pad (Int -> ShowS
forall a. Integral a => a -> ShowS
showHex (Char -> Int
ord Char
c) String
"")) else Maybe String
forall a. Maybe a
Nothing)
  where
    pad :: ShowS
pad String
digits = Int -> Char -> String
forall a. Int -> a -> [a]
replicate (Int
4 Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
digits) Char
'0' String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
digits

-- Syntax --

-- | The interpreters of TypeScript's syntax.
type TsGrammatical p =
  (Lexical TsToken p, Alternator p, Filtrator p, MonadicTry p)

{- | The declarations of a declaration file, of tokens, by the TypeScript
compiler's syntax, printed one per line, indented within blocks, & with
object types on one line. Trivia print conventionally, & parse only
from tokens with trivia, by `parseG`, since `tsTokensGrammar` scans
without them. Its @;@s print, & parse if they're there.

It's a `CtxGrammar` by `try`, rather than by monadic bonding, since it
isn't @LL(1)@: TypeScript's syntax needs more lookahead in places,
where it backtracks by `try`: declarations' & members' modifiers, imports'
forms & their @type@ & @as@, comma-separated lists after their first item,
members' signatures, constructors & accessors, a binding's name before
its @:@, type parameters' modifiers, @asserts@ & @is@ predicates,
function, conditional, @typeof import@, mapped & named tuple member types.

Printing a file, of many tokens, is linear into a stream which grows
at its end in constant time, like a `Data.Sequence.Seq`, rather than
a list.
-}
tsGrammar :: CtxGrammar TsToken [TsDeclaration]
tsGrammar :: CtxGrammar TsToken [TsDeclaration]
tsGrammar = p TsDeclaration TsDeclaration -> p [TsDeclaration] [TsDeclaration]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (Int -> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *).
TsGrammatical p =>
Int -> p TsDeclaration TsDeclaration
declaration Int
0 p TsDeclaration TsDeclaration
-> p () () -> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
newline)

-- | A declaration, at a depth of indentation.
declaration :: TsGrammatical p => Int -> p TsDeclaration TsDeclaration
declaration :: forall (p :: * -> * -> *).
TsGrammatical p =>
Int -> p TsDeclaration TsDeclaration
declaration Int
depth = String
-> p TsDeclaration TsDeclaration -> p TsDeclaration TsDeclaration
forall bnf. BackusNaurForm bnf => String -> bnf -> bnf
rule String
"declaration" (p TsDeclaration TsDeclaration -> p TsDeclaration TsDeclaration)
-> p TsDeclaration TsDeclaration -> p TsDeclaration TsDeclaration
forall a b. (a -> b) -> a -> b
$ [p TsDeclaration TsDeclaration] -> p TsDeclaration TsDeclaration
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market
  (TsTokenCategory, TsDeclaration)
  (TsTokenCategory, TsDeclaration)
  (TsTokenCategory, TsDeclaration)
  (Identity (TsTokenCategory, TsDeclaration))
-> Market
     (TsTokenCategory, TsDeclaration)
     (TsTokenCategory, TsDeclaration)
     TsDeclaration
     (Identity TsDeclaration)
Prism' TsDeclaration (TsTokenCategory, TsDeclaration)
_Modified (Market
   (TsTokenCategory, TsDeclaration)
   (TsTokenCategory, TsDeclaration)
   (TsTokenCategory, TsDeclaration)
   (Identity (TsTokenCategory, TsDeclaration))
 -> Market
      (TsTokenCategory, TsDeclaration)
      (TsTokenCategory, TsDeclaration)
      TsDeclaration
      (Identity TsDeclaration))
-> p (TsTokenCategory, TsDeclaration)
     (TsTokenCategory, TsDeclaration)
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (TsTokenCategory, TsDeclaration) (TsTokenCategory, TsDeclaration)
-> p (TsTokenCategory, TsDeclaration)
     (TsTokenCategory, TsDeclaration)
forall a.
p (TsTokenCategory, TsDeclaration) a
-> p (TsTokenCategory, TsDeclaration) a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      ( [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
          [ TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
category (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
          | TsTokenCategory
category <-
            [ TsTokenCategory
ExportKeyword, TsTokenCategory
DeclareKeyword, TsTokenCategory
DefaultKeyword
            , TsTokenCategory
AbstractKeyword, TsTokenCategory
ConstKeyword
            ]
          ]
        p TsTokenCategory TsTokenCategory
-> p TsDeclaration TsDeclaration
-> p (TsTokenCategory, TsDeclaration)
     (TsTokenCategory, TsDeclaration)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< Int -> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *).
TsGrammatical p =>
Int -> p TsDeclaration TsDeclaration
declaration Int
depth
      )
  , Market
  (Text, ([TsTypeParameter], TsType))
  (Text, ([TsTypeParameter], TsType))
  ([TsTokenCategory], (Text, ([TsTypeParameter], TsType)))
  (Identity ([TsTokenCategory], (Text, ([TsTypeParameter], TsType))))
-> Market
     (Text, ([TsTypeParameter], TsType))
     (Text, ([TsTypeParameter], TsType))
     TsDeclaration
     (Identity TsDeclaration)
Prism'
  TsDeclaration
  ([TsTokenCategory], (Text, ([TsTypeParameter], TsType)))
_TypeAliasDeclaration (Market
   (Text, ([TsTypeParameter], TsType))
   (Text, ([TsTypeParameter], TsType))
   ([TsTokenCategory], (Text, ([TsTypeParameter], TsType)))
   (Identity ([TsTokenCategory], (Text, ([TsTypeParameter], TsType))))
 -> Market
      (Text, ([TsTypeParameter], TsType))
      (Text, ([TsTypeParameter], TsType))
      TsDeclaration
      (Identity TsDeclaration))
-> (Market
      (Text, ([TsTypeParameter], TsType))
      (Text, ([TsTypeParameter], TsType))
      (Text, ([TsTypeParameter], TsType))
      (Identity (Text, ([TsTypeParameter], TsType)))
    -> Market
         (Text, ([TsTypeParameter], TsType))
         (Text, ([TsTypeParameter], TsType))
         ([TsTokenCategory], (Text, ([TsTypeParameter], TsType)))
         (Identity
            ([TsTokenCategory], (Text, ([TsTypeParameter], TsType)))))
-> Market
     (Text, ([TsTypeParameter], TsType))
     (Text, ([TsTypeParameter], TsType))
     (Text, ([TsTypeParameter], TsType))
     (Identity (Text, ([TsTypeParameter], TsType)))
-> Market
     (Text, ([TsTypeParameter], TsType))
     (Text, ([TsTypeParameter], TsType))
     TsDeclaration
     (Identity TsDeclaration)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (Text, ([TsTypeParameter], TsType))
  (Text, ([TsTypeParameter], TsType))
  (Text, ([TsTypeParameter], TsType))
  (Identity (Text, ([TsTypeParameter], TsType)))
-> Market
     (Text, ([TsTypeParameter], TsType))
     (Text, ([TsTypeParameter], TsType))
     ([TsTokenCategory], (Text, ([TsTypeParameter], TsType)))
     (Identity ([TsTokenCategory], (Text, ([TsTypeParameter], TsType))))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (Text, ([TsTypeParameter], TsType))
   (Text, ([TsTypeParameter], TsType))
   (Text, ([TsTypeParameter], TsType))
   (Identity (Text, ([TsTypeParameter], TsType)))
 -> Market
      (Text, ([TsTypeParameter], TsType))
      (Text, ([TsTypeParameter], TsType))
      TsDeclaration
      (Identity TsDeclaration))
-> p (Text, ([TsTypeParameter], TsType))
     (Text, ([TsTypeParameter], TsType))
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
TypeKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier p Text Text
-> p ([TsTypeParameter], TsType) ([TsTypeParameter], TsType)
-> p (Text, ([TsTypeParameter], TsType))
     (Text, ([TsTypeParameter], TsType))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsTypeParameter] [TsTypeParameter]
forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsTypeParameter] [TsTypeParameter]
typeParameters
      p [TsTypeParameter] [TsTypeParameter]
-> p TsType TsType
-> p ([TsTypeParameter], TsType) ([TsTypeParameter], TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
EqualsToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode
      p TsType TsType -> p () () -> p TsType TsType
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
  , Market
  (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
  (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
  ([TsTokenCategory],
   (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))
  (Identity
     ([TsTokenCategory],
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))))
-> Market
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     TsDeclaration
     (Identity TsDeclaration)
Prism'
  TsDeclaration
  ([TsTokenCategory],
   (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))
_InterfaceDeclaration (Market
   (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
   (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
   ([TsTokenCategory],
    (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))
   (Identity
      ([TsTokenCategory],
       (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))))
 -> Market
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
      TsDeclaration
      (Identity TsDeclaration))
-> (Market
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
      (Identity
         (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))
    -> Market
         (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
         (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
         ([TsTokenCategory],
          (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))
         (Identity
            ([TsTokenCategory],
             (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))))
-> Market
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     (Identity
        (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))
-> Market
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     TsDeclaration
     (Identity TsDeclaration)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
  (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
  (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
  (Identity
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))
-> Market
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     ([TsTokenCategory],
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))
     (Identity
        ([TsTokenCategory],
         (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers
      (Market
   (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
   (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
   (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
   (Identity
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty]))))
 -> Market
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
      (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
      TsDeclaration
      (Identity TsDeclaration))
-> p (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
InterfaceKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier p Text Text
-> p ([TsTypeParameter], ([TsHeritage], [TsProperty]))
     ([TsTypeParameter], ([TsHeritage], [TsProperty]))
-> p (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
     (Text, ([TsTypeParameter], ([TsHeritage], [TsProperty])))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsTypeParameter] [TsTypeParameter]
forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsTypeParameter] [TsTypeParameter]
typeParameters
      p [TsTypeParameter] [TsTypeParameter]
-> p ([TsHeritage], [TsProperty]) ([TsHeritage], [TsProperty])
-> p ([TsTypeParameter], ([TsHeritage], [TsProperty]))
     ([TsTypeParameter], ([TsHeritage], [TsProperty]))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< TsTokenCategory -> p [TsHeritage] [TsHeritage]
forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p [TsHeritage] [TsHeritage]
heritageClause TsTokenCategory
ExtendsKeyword
      p [TsHeritage] [TsHeritage]
-> p [TsProperty] [TsProperty]
-> p ([TsHeritage], [TsProperty]) ([TsHeritage], [TsProperty])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< Int
-> p () ()
-> (Int -> p TsProperty TsProperty)
-> p [TsProperty] [TsProperty]
forall (p :: * -> * -> *) a.
TsGrammatical p =>
Int -> p () () -> (Int -> p a a) -> p [a] [a]
block Int
depth p () ()
memberSeparator (p TsProperty TsProperty -> Int -> p TsProperty TsProperty
forall a b. a -> b -> a
const p TsProperty TsProperty
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsProperty TsProperty
member)
  , Market
  (Text,
   ([TsTypeParameter],
    (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
  (Text,
   ([TsTypeParameter],
    (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
  ([TsTokenCategory],
   (Text,
    ([TsTypeParameter],
     (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))
  (Identity
     ([TsTokenCategory],
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))))
-> Market
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     TsDeclaration
     (Identity TsDeclaration)
Prism'
  TsDeclaration
  ([TsTokenCategory],
   (Text,
    ([TsTypeParameter],
     (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))
_ClassDeclaration (Market
   (Text,
    ([TsTypeParameter],
     (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
   (Text,
    ([TsTypeParameter],
     (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
   ([TsTokenCategory],
    (Text,
     ([TsTypeParameter],
      (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))
   (Identity
      ([TsTokenCategory],
       (Text,
        ([TsTypeParameter],
         (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))))
 -> Market
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
      TsDeclaration
      (Identity TsDeclaration))
-> (Market
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
      (Identity
         (Text,
          ([TsTypeParameter],
           (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))
    -> Market
         (Text,
          ([TsTypeParameter],
           (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
         (Text,
          ([TsTypeParameter],
           (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
         ([TsTokenCategory],
          (Text,
           ([TsTypeParameter],
            (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))
         (Identity
            ([TsTokenCategory],
             (Text,
              ([TsTypeParameter],
               (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))))
-> Market
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     (Identity
        (Text,
         ([TsTypeParameter],
          (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))
-> Market
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     TsDeclaration
     (Identity TsDeclaration)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (Text,
   ([TsTypeParameter],
    (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
  (Text,
   ([TsTypeParameter],
    (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
  (Text,
   ([TsTypeParameter],
    (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
  (Identity
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))
-> Market
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     ([TsTokenCategory],
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))
     (Identity
        ([TsTokenCategory],
         (Text,
          ([TsTypeParameter],
           (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (Text,
    ([TsTypeParameter],
     (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
   (Text,
    ([TsTypeParameter],
     (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
   (Text,
    ([TsTypeParameter],
     (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
   (Identity
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty])))))
 -> Market
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
      (Text,
       ([TsTypeParameter],
        (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
      TsDeclaration
      (Identity TsDeclaration))
-> p (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ClassKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier p Text Text
-> p ([TsTypeParameter],
      (Maybe TsHeritage, ([TsHeritage], [TsProperty])))
     ([TsTypeParameter],
      (Maybe TsHeritage, ([TsHeritage], [TsProperty])))
-> p (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
     (Text,
      ([TsTypeParameter],
       (Maybe TsHeritage, ([TsHeritage], [TsProperty]))))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsTypeParameter] [TsTypeParameter]
forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsTypeParameter] [TsTypeParameter]
typeParameters
      p [TsTypeParameter] [TsTypeParameter]
-> p (Maybe TsHeritage, ([TsHeritage], [TsProperty]))
     (Maybe TsHeritage, ([TsHeritage], [TsProperty]))
-> p ([TsTypeParameter],
      (Maybe TsHeritage, ([TsHeritage], [TsProperty])))
     ([TsTypeParameter],
      (Maybe TsHeritage, ([TsHeritage], [TsProperty])))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsHeritage TsHeritage -> p (Maybe TsHeritage) (Maybe TsHeritage)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
ExtendsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsHeritage TsHeritage -> p TsHeritage TsHeritage
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsHeritage TsHeritage
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsHeritage TsHeritage
heritage)
      p (Maybe TsHeritage) (Maybe TsHeritage)
-> p ([TsHeritage], [TsProperty]) ([TsHeritage], [TsProperty])
-> p (Maybe TsHeritage, ([TsHeritage], [TsProperty]))
     (Maybe TsHeritage, ([TsHeritage], [TsProperty]))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< TsTokenCategory -> p [TsHeritage] [TsHeritage]
forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p [TsHeritage] [TsHeritage]
heritageClause TsTokenCategory
ImplementsKeyword
      p [TsHeritage] [TsHeritage]
-> p [TsProperty] [TsProperty]
-> p ([TsHeritage], [TsProperty]) ([TsHeritage], [TsProperty])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< Int
-> p () ()
-> (Int -> p TsProperty TsProperty)
-> p [TsProperty] [TsProperty]
forall (p :: * -> * -> *) a.
TsGrammatical p =>
Int -> p () () -> (Int -> p a a) -> p [a] [a]
block Int
depth p () ()
memberSeparator (p TsProperty TsProperty -> Int -> p TsProperty TsProperty
forall a b. a -> b -> a
const p TsProperty TsProperty
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsProperty TsProperty
member)
  , Market
  (Text, TsSignature)
  (Text, TsSignature)
  ([TsTokenCategory], (Text, TsSignature))
  (Identity ([TsTokenCategory], (Text, TsSignature)))
-> Market
     (Text, TsSignature)
     (Text, TsSignature)
     TsDeclaration
     (Identity TsDeclaration)
Prism' TsDeclaration ([TsTokenCategory], (Text, TsSignature))
_FunctionDeclaration (Market
   (Text, TsSignature)
   (Text, TsSignature)
   ([TsTokenCategory], (Text, TsSignature))
   (Identity ([TsTokenCategory], (Text, TsSignature)))
 -> Market
      (Text, TsSignature)
      (Text, TsSignature)
      TsDeclaration
      (Identity TsDeclaration))
-> (Market
      (Text, TsSignature)
      (Text, TsSignature)
      (Text, TsSignature)
      (Identity (Text, TsSignature))
    -> Market
         (Text, TsSignature)
         (Text, TsSignature)
         ([TsTokenCategory], (Text, TsSignature))
         (Identity ([TsTokenCategory], (Text, TsSignature))))
-> Market
     (Text, TsSignature)
     (Text, TsSignature)
     (Text, TsSignature)
     (Identity (Text, TsSignature))
-> Market
     (Text, TsSignature)
     (Text, TsSignature)
     TsDeclaration
     (Identity TsDeclaration)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (Text, TsSignature)
  (Text, TsSignature)
  (Text, TsSignature)
  (Identity (Text, TsSignature))
-> Market
     (Text, TsSignature)
     (Text, TsSignature)
     ([TsTokenCategory], (Text, TsSignature))
     (Identity ([TsTokenCategory], (Text, TsSignature)))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers
      (Market
   (Text, TsSignature)
   (Text, TsSignature)
   (Text, TsSignature)
   (Identity (Text, TsSignature))
 -> Market
      (Text, TsSignature)
      (Text, TsSignature)
      TsDeclaration
      (Identity TsDeclaration))
-> p (Text, TsSignature) (Text, TsSignature)
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
FunctionKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier p Text Text
-> p TsSignature TsSignature
-> p (Text, TsSignature) (Text, TsSignature)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsSignature TsSignature
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsSignature TsSignature
signature p TsSignature TsSignature -> p () () -> p TsSignature TsSignature
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
  , Market
  (TsTokenCategory, [TsVariableDeclaration])
  (TsTokenCategory, [TsVariableDeclaration])
  ([TsTokenCategory], (TsTokenCategory, [TsVariableDeclaration]))
  (Identity
     ([TsTokenCategory], (TsTokenCategory, [TsVariableDeclaration])))
-> Market
     (TsTokenCategory, [TsVariableDeclaration])
     (TsTokenCategory, [TsVariableDeclaration])
     TsDeclaration
     (Identity TsDeclaration)
Prism'
  TsDeclaration
  ([TsTokenCategory], (TsTokenCategory, [TsVariableDeclaration]))
_VariableStatement (Market
   (TsTokenCategory, [TsVariableDeclaration])
   (TsTokenCategory, [TsVariableDeclaration])
   ([TsTokenCategory], (TsTokenCategory, [TsVariableDeclaration]))
   (Identity
      ([TsTokenCategory], (TsTokenCategory, [TsVariableDeclaration])))
 -> Market
      (TsTokenCategory, [TsVariableDeclaration])
      (TsTokenCategory, [TsVariableDeclaration])
      TsDeclaration
      (Identity TsDeclaration))
-> (Market
      (TsTokenCategory, [TsVariableDeclaration])
      (TsTokenCategory, [TsVariableDeclaration])
      (TsTokenCategory, [TsVariableDeclaration])
      (Identity (TsTokenCategory, [TsVariableDeclaration]))
    -> Market
         (TsTokenCategory, [TsVariableDeclaration])
         (TsTokenCategory, [TsVariableDeclaration])
         ([TsTokenCategory], (TsTokenCategory, [TsVariableDeclaration]))
         (Identity
            ([TsTokenCategory], (TsTokenCategory, [TsVariableDeclaration]))))
-> Market
     (TsTokenCategory, [TsVariableDeclaration])
     (TsTokenCategory, [TsVariableDeclaration])
     (TsTokenCategory, [TsVariableDeclaration])
     (Identity (TsTokenCategory, [TsVariableDeclaration]))
-> Market
     (TsTokenCategory, [TsVariableDeclaration])
     (TsTokenCategory, [TsVariableDeclaration])
     TsDeclaration
     (Identity TsDeclaration)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (TsTokenCategory, [TsVariableDeclaration])
  (TsTokenCategory, [TsVariableDeclaration])
  (TsTokenCategory, [TsVariableDeclaration])
  (Identity (TsTokenCategory, [TsVariableDeclaration]))
-> Market
     (TsTokenCategory, [TsVariableDeclaration])
     (TsTokenCategory, [TsVariableDeclaration])
     ([TsTokenCategory], (TsTokenCategory, [TsVariableDeclaration]))
     (Identity
        ([TsTokenCategory], (TsTokenCategory, [TsVariableDeclaration])))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (TsTokenCategory, [TsVariableDeclaration])
   (TsTokenCategory, [TsVariableDeclaration])
   (TsTokenCategory, [TsVariableDeclaration])
   (Identity (TsTokenCategory, [TsVariableDeclaration]))
 -> Market
      (TsTokenCategory, [TsVariableDeclaration])
      (TsTokenCategory, [TsVariableDeclaration])
      TsDeclaration
      (Identity TsDeclaration))
-> p (TsTokenCategory, [TsVariableDeclaration])
     (TsTokenCategory, [TsVariableDeclaration])
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
category (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      | TsTokenCategory
category <- [TsTokenCategory
VarKeyword, TsTokenCategory
LetKeyword, TsTokenCategory
ConstKeyword]
      ]
      p TsTokenCategory TsTokenCategory
-> p [TsVariableDeclaration] [TsVariableDeclaration]
-> p (TsTokenCategory, [TsVariableDeclaration])
     (TsTokenCategory, [TsVariableDeclaration])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsVariableDeclaration TsVariableDeclaration
-> p [TsVariableDeclaration] [TsVariableDeclaration]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
commas1 p TsVariableDeclaration TsVariableDeclaration
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsVariableDeclaration TsVariableDeclaration
variable p [TsVariableDeclaration] [TsVariableDeclaration]
-> p () () -> p [TsVariableDeclaration] [TsVariableDeclaration]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
  , Market
  (Text, [TsEnumMember])
  (Text, [TsEnumMember])
  ([TsTokenCategory], (Text, [TsEnumMember]))
  (Identity ([TsTokenCategory], (Text, [TsEnumMember])))
-> Market
     (Text, [TsEnumMember])
     (Text, [TsEnumMember])
     TsDeclaration
     (Identity TsDeclaration)
Prism' TsDeclaration ([TsTokenCategory], (Text, [TsEnumMember]))
_EnumDeclaration (Market
   (Text, [TsEnumMember])
   (Text, [TsEnumMember])
   ([TsTokenCategory], (Text, [TsEnumMember]))
   (Identity ([TsTokenCategory], (Text, [TsEnumMember])))
 -> Market
      (Text, [TsEnumMember])
      (Text, [TsEnumMember])
      TsDeclaration
      (Identity TsDeclaration))
-> (Market
      (Text, [TsEnumMember])
      (Text, [TsEnumMember])
      (Text, [TsEnumMember])
      (Identity (Text, [TsEnumMember]))
    -> Market
         (Text, [TsEnumMember])
         (Text, [TsEnumMember])
         ([TsTokenCategory], (Text, [TsEnumMember]))
         (Identity ([TsTokenCategory], (Text, [TsEnumMember]))))
-> Market
     (Text, [TsEnumMember])
     (Text, [TsEnumMember])
     (Text, [TsEnumMember])
     (Identity (Text, [TsEnumMember]))
-> Market
     (Text, [TsEnumMember])
     (Text, [TsEnumMember])
     TsDeclaration
     (Identity TsDeclaration)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (Text, [TsEnumMember])
  (Text, [TsEnumMember])
  (Text, [TsEnumMember])
  (Identity (Text, [TsEnumMember]))
-> Market
     (Text, [TsEnumMember])
     (Text, [TsEnumMember])
     ([TsTokenCategory], (Text, [TsEnumMember]))
     (Identity ([TsTokenCategory], (Text, [TsEnumMember])))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (Text, [TsEnumMember])
   (Text, [TsEnumMember])
   (Text, [TsEnumMember])
   (Identity (Text, [TsEnumMember]))
 -> Market
      (Text, [TsEnumMember])
      (Text, [TsEnumMember])
      TsDeclaration
      (Identity TsDeclaration))
-> p (Text, [TsEnumMember]) (Text, [TsEnumMember])
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
EnumKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier p Text Text
-> p [TsEnumMember] [TsEnumMember]
-> p (Text, [TsEnumMember]) (Text, [TsEnumMember])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< Int
-> p () ()
-> (Int -> p TsEnumMember TsEnumMember)
-> p [TsEnumMember] [TsEnumMember]
forall (p :: * -> * -> *) a.
TsGrammatical p =>
Int -> p () () -> (Int -> p a a) -> p [a] [a]
block Int
depth p () ()
enumSeparator (p TsEnumMember TsEnumMember -> Int -> p TsEnumMember TsEnumMember
forall a b. a -> b -> a
const p TsEnumMember TsEnumMember
enumMember)
  , Market
  (TsModuleName, Maybe [TsDeclaration])
  (TsModuleName, Maybe [TsDeclaration])
  ([TsTokenCategory], (TsModuleName, Maybe [TsDeclaration]))
  (Identity
     ([TsTokenCategory], (TsModuleName, Maybe [TsDeclaration])))
-> Market
     (TsModuleName, Maybe [TsDeclaration])
     (TsModuleName, Maybe [TsDeclaration])
     TsDeclaration
     (Identity TsDeclaration)
Prism'
  TsDeclaration
  ([TsTokenCategory], (TsModuleName, Maybe [TsDeclaration]))
_ModuleDeclaration (Market
   (TsModuleName, Maybe [TsDeclaration])
   (TsModuleName, Maybe [TsDeclaration])
   ([TsTokenCategory], (TsModuleName, Maybe [TsDeclaration]))
   (Identity
      ([TsTokenCategory], (TsModuleName, Maybe [TsDeclaration])))
 -> Market
      (TsModuleName, Maybe [TsDeclaration])
      (TsModuleName, Maybe [TsDeclaration])
      TsDeclaration
      (Identity TsDeclaration))
-> (Market
      (TsModuleName, Maybe [TsDeclaration])
      (TsModuleName, Maybe [TsDeclaration])
      (TsModuleName, Maybe [TsDeclaration])
      (Identity (TsModuleName, Maybe [TsDeclaration]))
    -> Market
         (TsModuleName, Maybe [TsDeclaration])
         (TsModuleName, Maybe [TsDeclaration])
         ([TsTokenCategory], (TsModuleName, Maybe [TsDeclaration]))
         (Identity
            ([TsTokenCategory], (TsModuleName, Maybe [TsDeclaration]))))
-> Market
     (TsModuleName, Maybe [TsDeclaration])
     (TsModuleName, Maybe [TsDeclaration])
     (TsModuleName, Maybe [TsDeclaration])
     (Identity (TsModuleName, Maybe [TsDeclaration]))
-> Market
     (TsModuleName, Maybe [TsDeclaration])
     (TsModuleName, Maybe [TsDeclaration])
     TsDeclaration
     (Identity TsDeclaration)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (TsModuleName, Maybe [TsDeclaration])
  (TsModuleName, Maybe [TsDeclaration])
  (TsModuleName, Maybe [TsDeclaration])
  (Identity (TsModuleName, Maybe [TsDeclaration]))
-> Market
     (TsModuleName, Maybe [TsDeclaration])
     (TsModuleName, Maybe [TsDeclaration])
     ([TsTokenCategory], (TsModuleName, Maybe [TsDeclaration]))
     (Identity
        ([TsTokenCategory], (TsModuleName, Maybe [TsDeclaration])))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (TsModuleName, Maybe [TsDeclaration])
   (TsModuleName, Maybe [TsDeclaration])
   (TsModuleName, Maybe [TsDeclaration])
   (Identity (TsModuleName, Maybe [TsDeclaration]))
 -> Market
      (TsModuleName, Maybe [TsDeclaration])
      (TsModuleName, Maybe [TsDeclaration])
      TsDeclaration
      (Identity TsDeclaration))
-> p (TsModuleName, Maybe [TsDeclaration])
     (TsModuleName, Maybe [TsDeclaration])
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? [p TsModuleName TsModuleName] -> p TsModuleName TsModuleName
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Market
  TsEntityName TsEntityName TsEntityName (Identity TsEntityName)
-> Market
     TsEntityName TsEntityName TsModuleName (Identity TsModuleName)
Prism' TsModuleName TsEntityName
_NamespaceName (Market
   TsEntityName TsEntityName TsEntityName (Identity TsEntityName)
 -> Market
      TsEntityName TsEntityName TsModuleName (Identity TsModuleName))
-> p TsEntityName TsEntityName -> p TsModuleName TsModuleName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
NamespaceKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p TsEntityName TsEntityName -> p TsEntityName TsEntityName
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsEntityName TsEntityName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsEntityName TsEntityName
entityName
      , Market Text Text Text (Identity Text)
-> Market Text Text TsModuleName (Identity TsModuleName)
Prism' TsModuleName Text
_ExternalModuleName (Market Text Text Text (Identity Text)
 -> Market Text Text TsModuleName (Identity TsModuleName))
-> p Text Text -> p TsModuleName TsModuleName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text -> p Text Text
forall a. p Text a -> p Text a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
          (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ModuleKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
StringLiteral)
      , Market
  TsEntityName TsEntityName TsEntityName (Identity TsEntityName)
-> Market
     TsEntityName TsEntityName TsModuleName (Identity TsModuleName)
Prism' TsModuleName TsEntityName
_ModuleName (Market
   TsEntityName TsEntityName TsEntityName (Identity TsEntityName)
 -> Market
      TsEntityName TsEntityName TsModuleName (Identity TsModuleName))
-> p TsEntityName TsEntityName -> p TsModuleName TsModuleName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ModuleKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p TsEntityName TsEntityName -> p TsEntityName TsEntityName
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsEntityName TsEntityName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsEntityName TsEntityName
entityName
      , Market () () () (Identity ())
-> Market () () TsModuleName (Identity TsModuleName)
Prism' TsModuleName ()
_GlobalAugmentation (Market () () () (Identity ())
 -> Market () () TsModuleName (Identity TsModuleName))
-> p () () -> p TsModuleName TsModuleName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
GlobalKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      ]
      p TsModuleName TsModuleName
-> p (Maybe [TsDeclaration]) (Maybe [TsDeclaration])
-> p (TsModuleName, Maybe [TsDeclaration])
     (TsModuleName, Maybe [TsDeclaration])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< [p (Maybe [TsDeclaration]) (Maybe [TsDeclaration])]
-> p (Maybe [TsDeclaration]) (Maybe [TsDeclaration])
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
        [ Market
  [TsDeclaration]
  [TsDeclaration]
  [TsDeclaration]
  (Identity [TsDeclaration])
-> Market
     [TsDeclaration]
     [TsDeclaration]
     (Maybe [TsDeclaration])
     (Identity (Maybe [TsDeclaration]))
forall a b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Maybe a) (f (Maybe b))
_Just (Market
   [TsDeclaration]
   [TsDeclaration]
   [TsDeclaration]
   (Identity [TsDeclaration])
 -> Market
      [TsDeclaration]
      [TsDeclaration]
      (Maybe [TsDeclaration])
      (Identity (Maybe [TsDeclaration])))
-> p [TsDeclaration] [TsDeclaration]
-> p (Maybe [TsDeclaration]) (Maybe [TsDeclaration])
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? Int
-> p () ()
-> (Int -> p TsDeclaration TsDeclaration)
-> p [TsDeclaration] [TsDeclaration]
forall (p :: * -> * -> *) a.
TsGrammatical p =>
Int -> p () () -> (Int -> p a a) -> p [a] [a]
block Int
depth p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP Int -> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *).
TsGrammatical p =>
Int -> p TsDeclaration TsDeclaration
declaration
        , Maybe [TsDeclaration] -> Prism' (Maybe [TsDeclaration]) ()
forall a. Eq a => a -> Prism' a ()
only Maybe [TsDeclaration]
forall a. Maybe a
Nothing (Market () () () (Identity ())
 -> Market
      () () (Maybe [TsDeclaration]) (Identity (Maybe [TsDeclaration])))
-> p () () -> p (Maybe [TsDeclaration]) (Maybe [TsDeclaration])
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
        ]
  , Market
  (Bool, (Text, TsModuleReference))
  (Bool, (Text, TsModuleReference))
  ([TsTokenCategory], (Bool, (Text, TsModuleReference)))
  (Identity ([TsTokenCategory], (Bool, (Text, TsModuleReference))))
-> Market
     (Bool, (Text, TsModuleReference))
     (Bool, (Text, TsModuleReference))
     TsDeclaration
     (Identity TsDeclaration)
Prism'
  TsDeclaration
  ([TsTokenCategory], (Bool, (Text, TsModuleReference)))
_ImportEqualsDeclaration (Market
   (Bool, (Text, TsModuleReference))
   (Bool, (Text, TsModuleReference))
   ([TsTokenCategory], (Bool, (Text, TsModuleReference)))
   (Identity ([TsTokenCategory], (Bool, (Text, TsModuleReference))))
 -> Market
      (Bool, (Text, TsModuleReference))
      (Bool, (Text, TsModuleReference))
      TsDeclaration
      (Identity TsDeclaration))
-> (Market
      (Bool, (Text, TsModuleReference))
      (Bool, (Text, TsModuleReference))
      (Bool, (Text, TsModuleReference))
      (Identity (Bool, (Text, TsModuleReference)))
    -> Market
         (Bool, (Text, TsModuleReference))
         (Bool, (Text, TsModuleReference))
         ([TsTokenCategory], (Bool, (Text, TsModuleReference)))
         (Identity ([TsTokenCategory], (Bool, (Text, TsModuleReference)))))
-> Market
     (Bool, (Text, TsModuleReference))
     (Bool, (Text, TsModuleReference))
     (Bool, (Text, TsModuleReference))
     (Identity (Bool, (Text, TsModuleReference)))
-> Market
     (Bool, (Text, TsModuleReference))
     (Bool, (Text, TsModuleReference))
     TsDeclaration
     (Identity TsDeclaration)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (Bool, (Text, TsModuleReference))
  (Bool, (Text, TsModuleReference))
  (Bool, (Text, TsModuleReference))
  (Identity (Bool, (Text, TsModuleReference)))
-> Market
     (Bool, (Text, TsModuleReference))
     (Bool, (Text, TsModuleReference))
     ([TsTokenCategory], (Bool, (Text, TsModuleReference)))
     (Identity ([TsTokenCategory], (Bool, (Text, TsModuleReference))))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (Bool, (Text, TsModuleReference))
   (Bool, (Text, TsModuleReference))
   (Bool, (Text, TsModuleReference))
   (Identity (Bool, (Text, TsModuleReference)))
 -> Market
      (Bool, (Text, TsModuleReference))
      (Bool, (Text, TsModuleReference))
      TsDeclaration
      (Identity TsDeclaration))
-> p (Bool, (Text, TsModuleReference))
     (Bool, (Text, TsModuleReference))
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (Bool, (Text, TsModuleReference))
  (Bool, (Text, TsModuleReference))
-> p (Bool, (Text, TsModuleReference))
     (Bool, (Text, TsModuleReference))
forall a.
p (Bool, (Text, TsModuleReference)) a
-> p (Bool, (Text, TsModuleReference)) a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      ( p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ImportKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Bool Bool -> p Bool Bool
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
typeOnly p Bool Bool
-> p (Text, TsModuleReference) (Text, TsModuleReference)
-> p (Bool, (Text, TsModuleReference))
     (Bool, (Text, TsModuleReference))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier
        p Text Text
-> p TsModuleReference TsModuleReference
-> p (Text, TsModuleReference) (Text, TsModuleReference)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
EqualsToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p TsModuleReference TsModuleReference
-> p TsModuleReference TsModuleReference
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p TsModuleReference TsModuleReference]
-> p TsModuleReference TsModuleReference
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
          [ Market Text Text Text (Identity Text)
-> Market Text Text TsModuleReference (Identity TsModuleReference)
Prism' TsModuleReference Text
_ExternalModuleReference (Market Text Text Text (Identity Text)
 -> Market Text Text TsModuleReference (Identity TsModuleReference))
-> p Text Text -> p TsModuleReference TsModuleReference
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
RequireKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
              p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
StringLiteral
              p Text Text -> p () () -> p Text Text
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
          , Market
  TsEntityName TsEntityName TsEntityName (Identity TsEntityName)
-> Market
     TsEntityName
     TsEntityName
     TsModuleReference
     (Identity TsModuleReference)
Prism' TsModuleReference TsEntityName
_EntityModuleReference (Market
   TsEntityName TsEntityName TsEntityName (Identity TsEntityName)
 -> Market
      TsEntityName
      TsEntityName
      TsModuleReference
      (Identity TsModuleReference))
-> p TsEntityName TsEntityName
-> p TsModuleReference TsModuleReference
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsEntityName TsEntityName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsEntityName TsEntityName
entityName
          ]
        p TsModuleReference TsModuleReference
-> p () () -> p TsModuleReference TsModuleReference
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
      )
  , Market Text Text Text (Identity Text)
-> Market Text Text TsDeclaration (Identity TsDeclaration)
Prism' TsDeclaration Text
_BareImport (Market Text Text Text (Identity Text)
 -> Market Text Text TsDeclaration (Identity TsDeclaration))
-> p Text Text -> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text -> p Text Text
forall a. p Text a -> p Text a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ImportKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
StringLiteral)
      p Text Text -> p () () -> p Text Text
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
  , Market
  (Bool, (TsImportClause, Text))
  (Bool, (TsImportClause, Text))
  (Bool, (TsImportClause, Text))
  (Identity (Bool, (TsImportClause, Text)))
-> Market
     (Bool, (TsImportClause, Text))
     (Bool, (TsImportClause, Text))
     TsDeclaration
     (Identity TsDeclaration)
Prism' TsDeclaration (Bool, (TsImportClause, Text))
_ClauseImport (Market
   (Bool, (TsImportClause, Text))
   (Bool, (TsImportClause, Text))
   (Bool, (TsImportClause, Text))
   (Identity (Bool, (TsImportClause, Text)))
 -> Market
      (Bool, (TsImportClause, Text))
      (Bool, (TsImportClause, Text))
      TsDeclaration
      (Identity TsDeclaration))
-> p (Bool, (TsImportClause, Text)) (Bool, (TsImportClause, Text))
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ImportKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Bool Bool -> p Bool Bool
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
typeOnly
      p Bool Bool
-> p (TsImportClause, Text) (TsImportClause, Text)
-> p (Bool, (TsImportClause, Text)) (Bool, (TsImportClause, Text))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsImportClause TsImportClause
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsImportClause TsImportClause
importClause
      p TsImportClause TsImportClause
-> p Text Text -> p (TsImportClause, Text) (TsImportClause, Text)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
FromKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
StringLiteral
      p Text Text -> p () () -> p Text Text
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
  , Market
  TsDeclaration TsDeclaration TsDeclaration (Identity TsDeclaration)
-> Market
     TsDeclaration TsDeclaration TsDeclaration (Identity TsDeclaration)
Prism' TsDeclaration TsDeclaration
_Exported (Market
   TsDeclaration TsDeclaration TsDeclaration (Identity TsDeclaration)
 -> Market
      TsDeclaration TsDeclaration TsDeclaration (Identity TsDeclaration))
-> p TsDeclaration TsDeclaration -> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ExportKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () ()
-> p TsDeclaration TsDeclaration -> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p TsDeclaration TsDeclaration] -> p TsDeclaration TsDeclaration
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Market
  (Bool, TsEntityName)
  (Bool, TsEntityName)
  (Bool, TsEntityName)
  (Identity (Bool, TsEntityName))
-> Market
     (Bool, TsEntityName)
     (Bool, TsEntityName)
     TsDeclaration
     (Identity TsDeclaration)
Prism' TsDeclaration (Bool, TsEntityName)
_ExportAssignment (Market
   (Bool, TsEntityName)
   (Bool, TsEntityName)
   (Bool, TsEntityName)
   (Identity (Bool, TsEntityName))
 -> Market
      (Bool, TsEntityName)
      (Bool, TsEntityName)
      TsDeclaration
      (Identity TsDeclaration))
-> p (Bool, TsEntityName) (Bool, TsEntityName)
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? [p Bool Bool] -> p Bool Bool
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
          [ Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
True (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
EqualsToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
          , Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
False (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
DefaultKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
          ]
          p Bool Bool
-> p TsEntityName TsEntityName
-> p (Bool, TsEntityName) (Bool, TsEntityName)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsEntityName TsEntityName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsEntityName TsEntityName
entityName p TsEntityName TsEntityName
-> p () () -> p TsEntityName TsEntityName
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
      , Market Text Text Text (Identity Text)
-> Market Text Text TsDeclaration (Identity TsDeclaration)
Prism' TsDeclaration Text
_NamespaceExportDeclaration (Market Text Text Text (Identity Text)
 -> Market Text Text TsDeclaration (Identity TsDeclaration))
-> p Text Text -> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
AsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
          p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
NamespaceKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier p Text Text -> p () () -> p Text Text
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
      , Market
  (Bool, (TsExportClause, Maybe Text))
  (Bool, (TsExportClause, Maybe Text))
  (Bool, (TsExportClause, Maybe Text))
  (Identity (Bool, (TsExportClause, Maybe Text)))
-> Market
     (Bool, (TsExportClause, Maybe Text))
     (Bool, (TsExportClause, Maybe Text))
     TsDeclaration
     (Identity TsDeclaration)
Prism' TsDeclaration (Bool, (TsExportClause, Maybe Text))
_ExportDeclaration (Market
   (Bool, (TsExportClause, Maybe Text))
   (Bool, (TsExportClause, Maybe Text))
   (Bool, (TsExportClause, Maybe Text))
   (Identity (Bool, (TsExportClause, Maybe Text)))
 -> Market
      (Bool, (TsExportClause, Maybe Text))
      (Bool, (TsExportClause, Maybe Text))
      TsDeclaration
      (Identity TsDeclaration))
-> p (Bool, (TsExportClause, Maybe Text))
     (Bool, (TsExportClause, Maybe Text))
-> p TsDeclaration TsDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Bool Bool -> p Bool Bool
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
typeOnly
          p Bool Bool
-> p (TsExportClause, Maybe Text) (TsExportClause, Maybe Text)
-> p (Bool, (TsExportClause, Maybe Text))
     (Bool, (TsExportClause, Maybe Text))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< [p TsExportClause TsExportClause]
-> p TsExportClause TsExportClause
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
            [ Market
  (Maybe Text) (Maybe Text) (Maybe Text) (Identity (Maybe Text))
-> Market
     (Maybe Text) (Maybe Text) TsExportClause (Identity TsExportClause)
Prism' TsExportClause (Maybe Text)
_NamespaceExport (Market
   (Maybe Text) (Maybe Text) (Maybe Text) (Identity (Maybe Text))
 -> Market
      (Maybe Text) (Maybe Text) TsExportClause (Identity TsExportClause))
-> p (Maybe Text) (Maybe Text) -> p TsExportClause TsExportClause
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
AsteriskToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
                p () ()
-> p (Maybe Text) (Maybe Text) -> p (Maybe Text) (Maybe Text)
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text -> p (Maybe Text) (Maybe Text)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
AsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier)
            , Market
  [TsImportSpecifier]
  [TsImportSpecifier]
  [TsImportSpecifier]
  (Identity [TsImportSpecifier])
-> Market
     [TsImportSpecifier]
     [TsImportSpecifier]
     TsExportClause
     (Identity TsExportClause)
Prism' TsExportClause [TsImportSpecifier]
_NamedExports (Market
   [TsImportSpecifier]
   [TsImportSpecifier]
   [TsImportSpecifier]
   (Identity [TsImportSpecifier])
 -> Market
      [TsImportSpecifier]
      [TsImportSpecifier]
      TsExportClause
      (Identity TsExportClause))
-> p [TsImportSpecifier] [TsImportSpecifier]
-> p TsExportClause TsExportClause
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsImportSpecifier TsImportSpecifier
-> p [TsImportSpecifier] [TsImportSpecifier]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
braced p TsImportSpecifier TsImportSpecifier
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsImportSpecifier TsImportSpecifier
specifier
            ]
          p TsExportClause TsExportClause
-> p (Maybe Text) (Maybe Text)
-> p (TsExportClause, Maybe Text) (TsExportClause, Maybe Text)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Text Text -> p (Maybe Text) (Maybe Text)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP
            (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
FromKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
StringLiteral)
          p (Maybe Text) (Maybe Text)
-> p () () -> p (Maybe Text) (Maybe Text)
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon
      ]
  ]
  where
    memberSeparator :: p () ()
memberSeparator = p () () -> p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () () -> p () ()
printed ([p () ()] -> p () ()
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
SemicolonToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP, p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CommaToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP])
    enumSeparator :: p () ()
enumSeparator = p () () -> p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () () -> p () ()
printed (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CommaToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP)
    enumMember :: p TsEnumMember TsEnumMember
enumMember = Market
  (TsPropertyName, Maybe TsLiteral)
  (TsPropertyName, Maybe TsLiteral)
  (TsPropertyName, Maybe TsLiteral)
  (Identity (TsPropertyName, Maybe TsLiteral))
-> Market
     (TsPropertyName, Maybe TsLiteral)
     (TsPropertyName, Maybe TsLiteral)
     TsEnumMember
     (Identity TsEnumMember)
Iso' TsEnumMember (TsPropertyName, Maybe TsLiteral)
_TsEnumMember (Market
   (TsPropertyName, Maybe TsLiteral)
   (TsPropertyName, Maybe TsLiteral)
   (TsPropertyName, Maybe TsLiteral)
   (Identity (TsPropertyName, Maybe TsLiteral))
 -> Market
      (TsPropertyName, Maybe TsLiteral)
      (TsPropertyName, Maybe TsLiteral)
      TsEnumMember
      (Identity TsEnumMember))
-> p (TsPropertyName, Maybe TsLiteral)
     (TsPropertyName, Maybe TsLiteral)
-> p TsEnumMember TsEnumMember
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsPropertyName TsPropertyName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsPropertyName TsPropertyName
propertyName
      p TsPropertyName TsPropertyName
-> p (Maybe TsLiteral) (Maybe TsLiteral)
-> p (TsPropertyName, Maybe TsLiteral)
     (TsPropertyName, Maybe TsLiteral)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsLiteral TsLiteral -> p (Maybe TsLiteral) (Maybe TsLiteral)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
EqualsToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsLiteral TsLiteral -> p TsLiteral TsLiteral
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsLiteral TsLiteral
forall (p :: * -> * -> *). TsGrammatical p => p TsLiteral TsLiteral
literal)

-- | Declarations without modifiers, which `_Modified` adds.
noModifiers :: Prism' ([TsTokenCategory], a) a
noModifiers :: forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers = (a -> ([TsTokenCategory], a))
-> (([TsTokenCategory], a) -> Maybe a)
-> forall {p :: * -> * -> *} {f :: * -> *}.
   (Choice p, Applicative f) =>
   p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ([],) ((([TsTokenCategory], a) -> Maybe a)
 -> forall {p :: * -> * -> *} {f :: * -> *}.
    (Choice p, Applicative f) =>
    p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a)))
-> (([TsTokenCategory], a) -> Maybe a)
-> forall {p :: * -> * -> *} {f :: * -> *}.
   (Choice p, Applicative f) =>
   p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
forall a b. (a -> b) -> a -> b
$ \case
  ([], a
a) -> a -> Maybe a
forall a. a -> Maybe a
Just a
a
  ([TsTokenCategory], a)
_ -> Maybe a
forall a. Maybe a
Nothing

-- | A declaration, with a modifier.
_Modified :: Prism' TsDeclaration (TsTokenCategory, TsDeclaration)
_Modified :: Prism' TsDeclaration (TsTokenCategory, TsDeclaration)
_Modified = ((TsTokenCategory, TsDeclaration) -> TsDeclaration)
-> (TsDeclaration -> Maybe (TsTokenCategory, TsDeclaration))
-> Prism' TsDeclaration (TsTokenCategory, TsDeclaration)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (\(TsTokenCategory
m, TsDeclaration
decl) -> ASetter
  TsDeclaration TsDeclaration [TsTokenCategory] [TsTokenCategory]
-> ([TsTokenCategory] -> [TsTokenCategory])
-> TsDeclaration
-> TsDeclaration
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter
  TsDeclaration TsDeclaration [TsTokenCategory] [TsTokenCategory]
Traversal' TsDeclaration [TsTokenCategory]
modifiers (TsTokenCategory
m TsTokenCategory -> [TsTokenCategory] -> [TsTokenCategory]
forall a. a -> [a] -> [a]
:) TsDeclaration
decl) ((TsDeclaration -> Maybe (TsTokenCategory, TsDeclaration))
 -> Prism' TsDeclaration (TsTokenCategory, TsDeclaration))
-> (TsDeclaration -> Maybe (TsTokenCategory, TsDeclaration))
-> Prism' TsDeclaration (TsTokenCategory, TsDeclaration)
forall a b. (a -> b) -> a -> b
$ \TsDeclaration
decl ->
  case TsDeclaration
decl TsDeclaration
-> Getting
     (First [TsTokenCategory]) TsDeclaration [TsTokenCategory]
-> Maybe [TsTokenCategory]
forall s a. s -> Getting (First a) s a -> Maybe a
^? Getting (First [TsTokenCategory]) TsDeclaration [TsTokenCategory]
Traversal' TsDeclaration [TsTokenCategory]
modifiers of
    Just (TsTokenCategory
m : [TsTokenCategory]
ms) -> (TsTokenCategory, TsDeclaration)
-> Maybe (TsTokenCategory, TsDeclaration)
forall a. a -> Maybe a
Just (TsTokenCategory
m, ASetter
  TsDeclaration TsDeclaration [TsTokenCategory] [TsTokenCategory]
-> [TsTokenCategory] -> TsDeclaration -> TsDeclaration
forall s t a b. ASetter s t a b -> b -> s -> t
set ASetter
  TsDeclaration TsDeclaration [TsTokenCategory] [TsTokenCategory]
Traversal' TsDeclaration [TsTokenCategory]
modifiers [TsTokenCategory]
ms TsDeclaration
decl)
    Maybe [TsTokenCategory]
_ -> Maybe (TsTokenCategory, TsDeclaration)
forall a. Maybe a
Nothing
  where
    modifiers :: Traversal' TsDeclaration [TsTokenCategory]
    modifiers :: Traversal' TsDeclaration [TsTokenCategory]
modifiers [TsTokenCategory] -> f [TsTokenCategory]
f = \case
      TypeAliasDeclaration [TsTokenCategory]
ms Text
n [TsTypeParameter]
t TsType
v ->
        (\[TsTokenCategory]
ms' -> [TsTokenCategory]
-> Text -> [TsTypeParameter] -> TsType -> TsDeclaration
TypeAliasDeclaration [TsTokenCategory]
ms' Text
n [TsTypeParameter]
t TsType
v) ([TsTokenCategory] -> TsDeclaration)
-> f [TsTokenCategory] -> f TsDeclaration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      InterfaceDeclaration [TsTokenCategory]
ms Text
n [TsTypeParameter]
t [TsHeritage]
h [TsProperty]
b ->
        (\[TsTokenCategory]
ms' -> [TsTokenCategory]
-> Text
-> [TsTypeParameter]
-> [TsHeritage]
-> [TsProperty]
-> TsDeclaration
InterfaceDeclaration [TsTokenCategory]
ms' Text
n [TsTypeParameter]
t [TsHeritage]
h [TsProperty]
b) ([TsTokenCategory] -> TsDeclaration)
-> f [TsTokenCategory] -> f TsDeclaration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      ClassDeclaration [TsTokenCategory]
ms Text
n [TsTypeParameter]
t Maybe TsHeritage
e [TsHeritage]
i [TsProperty]
b ->
        (\[TsTokenCategory]
ms' -> [TsTokenCategory]
-> Text
-> [TsTypeParameter]
-> Maybe TsHeritage
-> [TsHeritage]
-> [TsProperty]
-> TsDeclaration
ClassDeclaration [TsTokenCategory]
ms' Text
n [TsTypeParameter]
t Maybe TsHeritage
e [TsHeritage]
i [TsProperty]
b) ([TsTokenCategory] -> TsDeclaration)
-> f [TsTokenCategory] -> f TsDeclaration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      FunctionDeclaration [TsTokenCategory]
ms Text
n TsSignature
s ->
        (\[TsTokenCategory]
ms' -> [TsTokenCategory] -> Text -> TsSignature -> TsDeclaration
FunctionDeclaration [TsTokenCategory]
ms' Text
n TsSignature
s) ([TsTokenCategory] -> TsDeclaration)
-> f [TsTokenCategory] -> f TsDeclaration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      VariableStatement [TsTokenCategory]
ms TsTokenCategory
k [TsVariableDeclaration]
vs ->
        (\[TsTokenCategory]
ms' -> [TsTokenCategory]
-> TsTokenCategory -> [TsVariableDeclaration] -> TsDeclaration
VariableStatement [TsTokenCategory]
ms' TsTokenCategory
k [TsVariableDeclaration]
vs) ([TsTokenCategory] -> TsDeclaration)
-> f [TsTokenCategory] -> f TsDeclaration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      EnumDeclaration [TsTokenCategory]
ms Text
n [TsEnumMember]
es -> (\[TsTokenCategory]
ms' -> [TsTokenCategory] -> Text -> [TsEnumMember] -> TsDeclaration
EnumDeclaration [TsTokenCategory]
ms' Text
n [TsEnumMember]
es) ([TsTokenCategory] -> TsDeclaration)
-> f [TsTokenCategory] -> f TsDeclaration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      ModuleDeclaration [TsTokenCategory]
ms TsModuleName
n Maybe [TsDeclaration]
b ->
        (\[TsTokenCategory]
ms' -> [TsTokenCategory]
-> TsModuleName -> Maybe [TsDeclaration] -> TsDeclaration
ModuleDeclaration [TsTokenCategory]
ms' TsModuleName
n Maybe [TsDeclaration]
b) ([TsTokenCategory] -> TsDeclaration)
-> f [TsTokenCategory] -> f TsDeclaration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      ImportEqualsDeclaration [TsTokenCategory]
ms Bool
t Text
n TsModuleReference
r ->
        (\[TsTokenCategory]
ms' -> [TsTokenCategory]
-> Bool -> Text -> TsModuleReference -> TsDeclaration
ImportEqualsDeclaration [TsTokenCategory]
ms' Bool
t Text
n TsModuleReference
r) ([TsTokenCategory] -> TsDeclaration)
-> f [TsTokenCategory] -> f TsDeclaration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      TsDeclaration
decl -> TsDeclaration -> f TsDeclaration
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TsDeclaration
decl

-- | An import of a module, for its effects.
_BareImport :: Prism' TsDeclaration Text
_BareImport :: Prism' TsDeclaration Text
_BareImport = (Text -> TsDeclaration)
-> (TsDeclaration -> Maybe Text) -> Prism' TsDeclaration Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (Bool -> Maybe TsImportClause -> Text -> TsDeclaration
ImportDeclaration Bool
False Maybe TsImportClause
forall a. Maybe a
Nothing) ((TsDeclaration -> Maybe Text) -> Prism' TsDeclaration Text)
-> (TsDeclaration -> Maybe Text) -> Prism' TsDeclaration Text
forall a b. (a -> b) -> a -> b
$ \case
  ImportDeclaration Bool
False Maybe TsImportClause
Nothing Text
name -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
name
  TsDeclaration
_ -> Maybe Text
forall a. Maybe a
Nothing

-- | An import, of types only or not, by its clause, from a module.
_ClauseImport :: Prism' TsDeclaration (Bool, (TsImportClause, Text))
_ClauseImport :: Prism' TsDeclaration (Bool, (TsImportClause, Text))
_ClauseImport = ((Bool, (TsImportClause, Text)) -> TsDeclaration)
-> (TsDeclaration -> Maybe (Bool, (TsImportClause, Text)))
-> Prism' TsDeclaration (Bool, (TsImportClause, Text))
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\(Bool
types, (TsImportClause
clause, Text
name)) -> Bool -> Maybe TsImportClause -> Text -> TsDeclaration
ImportDeclaration Bool
types (TsImportClause -> Maybe TsImportClause
forall a. a -> Maybe a
Just TsImportClause
clause) Text
name)
  (\case
    ImportDeclaration Bool
types (Just TsImportClause
clause) Text
name -> (Bool, (TsImportClause, Text))
-> Maybe (Bool, (TsImportClause, Text))
forall a. a -> Maybe a
Just (Bool
types, (TsImportClause
clause, Text
name))
    TsDeclaration
_ -> Maybe (Bool, (TsImportClause, Text))
forall a. Maybe a
Nothing)

-- | An export's declaration, which isn't a modified declaration.
_Exported :: Prism' TsDeclaration TsDeclaration
_Exported :: Prism' TsDeclaration TsDeclaration
_Exported = (TsDeclaration -> TsDeclaration)
-> (TsDeclaration -> Maybe TsDeclaration)
-> Prism' TsDeclaration TsDeclaration
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' TsDeclaration -> TsDeclaration
forall a. a -> a
id ((TsDeclaration -> Maybe TsDeclaration)
 -> Prism' TsDeclaration TsDeclaration)
-> (TsDeclaration -> Maybe TsDeclaration)
-> Prism' TsDeclaration TsDeclaration
forall a b. (a -> b) -> a -> b
$ \case
  decl :: TsDeclaration
decl@(ExportAssignment {}) -> TsDeclaration -> Maybe TsDeclaration
forall a. a -> Maybe a
Just TsDeclaration
decl
  decl :: TsDeclaration
decl@(NamespaceExportDeclaration Text
_) -> TsDeclaration -> Maybe TsDeclaration
forall a. a -> Maybe a
Just TsDeclaration
decl
  decl :: TsDeclaration
decl@(ExportDeclaration {}) -> TsDeclaration -> Maybe TsDeclaration
forall a. a -> Maybe a
Just TsDeclaration
decl
  TsDeclaration
_ -> Maybe TsDeclaration
forall a. Maybe a
Nothing

-- | Whether an import or export is of types only.
typeOnly :: TsGrammatical p => p Bool Bool
typeOnly :: forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
typeOnly = [p Bool Bool] -> p Bool Bool
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
True (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> p () ()
forall a. p () a -> p () a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
TypeKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space)
  , Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
False (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]

importClause :: TsGrammatical p => p TsImportClause TsImportClause
importClause :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsImportClause TsImportClause
importClause = Market
  (Maybe Text, Maybe TsNamedBindings)
  (Maybe Text, Maybe TsNamedBindings)
  (Maybe Text, Maybe TsNamedBindings)
  (Identity (Maybe Text, Maybe TsNamedBindings))
-> Market
     (Maybe Text, Maybe TsNamedBindings)
     (Maybe Text, Maybe TsNamedBindings)
     TsImportClause
     (Identity TsImportClause)
Iso' TsImportClause (Maybe Text, Maybe TsNamedBindings)
_TsImportClause (Market
   (Maybe Text, Maybe TsNamedBindings)
   (Maybe Text, Maybe TsNamedBindings)
   (Maybe Text, Maybe TsNamedBindings)
   (Identity (Maybe Text, Maybe TsNamedBindings))
 -> Market
      (Maybe Text, Maybe TsNamedBindings)
      (Maybe Text, Maybe TsNamedBindings)
      TsImportClause
      (Identity TsImportClause))
-> p (Maybe Text, Maybe TsNamedBindings)
     (Maybe Text, Maybe TsNamedBindings)
-> p TsImportClause TsImportClause
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? [p (Maybe Text, Maybe TsNamedBindings)
   (Maybe Text, Maybe TsNamedBindings)]
-> p (Maybe Text, Maybe TsNamedBindings)
     (Maybe Text, Maybe TsNamedBindings)
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ (Market Text Text Text (Identity Text)
-> Market Text Text (Maybe Text) (Identity (Maybe Text))
forall a b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Maybe a) (f (Maybe b))
_Just (Market Text Text Text (Identity Text)
 -> Market Text Text (Maybe Text) (Identity (Maybe Text)))
-> p Text Text -> p (Maybe Text) (Maybe Text)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier) p (Maybe Text) (Maybe Text)
-> p (Maybe TsNamedBindings) (Maybe TsNamedBindings)
-> p (Maybe Text, Maybe TsNamedBindings)
     (Maybe Text, Maybe TsNamedBindings)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< [p (Maybe TsNamedBindings) (Maybe TsNamedBindings)]
-> p (Maybe TsNamedBindings) (Maybe TsNamedBindings)
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Market
  TsNamedBindings
  TsNamedBindings
  TsNamedBindings
  (Identity TsNamedBindings)
-> Market
     TsNamedBindings
     TsNamedBindings
     (Maybe TsNamedBindings)
     (Identity (Maybe TsNamedBindings))
forall a b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Maybe a) (f (Maybe b))
_Just (Market
   TsNamedBindings
   TsNamedBindings
   TsNamedBindings
   (Identity TsNamedBindings)
 -> Market
      TsNamedBindings
      TsNamedBindings
      (Maybe TsNamedBindings)
      (Identity (Maybe TsNamedBindings)))
-> p TsNamedBindings TsNamedBindings
-> p (Maybe TsNamedBindings) (Maybe TsNamedBindings)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CommaToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p TsNamedBindings TsNamedBindings
-> p TsNamedBindings TsNamedBindings
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsNamedBindings TsNamedBindings
namedBindings
      , Maybe TsNamedBindings -> Prism' (Maybe TsNamedBindings) ()
forall a. Eq a => a -> Prism' a ()
only Maybe TsNamedBindings
forall a. Maybe a
Nothing (Market () () () (Identity ())
 -> Market
      () () (Maybe TsNamedBindings) (Identity (Maybe TsNamedBindings)))
-> p () () -> p (Maybe TsNamedBindings) (Maybe TsNamedBindings)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      ]
  , (Maybe Text -> Prism' (Maybe Text) ()
forall a. Eq a => a -> Prism' a ()
only Maybe Text
forall a. Maybe a
Nothing (Market () () () (Identity ())
 -> Market () () (Maybe Text) (Identity (Maybe Text)))
-> p () () -> p (Maybe Text) (Maybe Text)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP) p (Maybe Text) (Maybe Text)
-> p (Maybe TsNamedBindings) (Maybe TsNamedBindings)
-> p (Maybe Text, Maybe TsNamedBindings)
     (Maybe Text, Maybe TsNamedBindings)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< (Market
  TsNamedBindings
  TsNamedBindings
  TsNamedBindings
  (Identity TsNamedBindings)
-> Market
     TsNamedBindings
     TsNamedBindings
     (Maybe TsNamedBindings)
     (Identity (Maybe TsNamedBindings))
forall a b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Maybe a) (f (Maybe b))
_Just (Market
   TsNamedBindings
   TsNamedBindings
   TsNamedBindings
   (Identity TsNamedBindings)
 -> Market
      TsNamedBindings
      TsNamedBindings
      (Maybe TsNamedBindings)
      (Identity (Maybe TsNamedBindings)))
-> p TsNamedBindings TsNamedBindings
-> p (Maybe TsNamedBindings) (Maybe TsNamedBindings)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsNamedBindings TsNamedBindings
namedBindings)
  ]
  where
    namedBindings :: p TsNamedBindings TsNamedBindings
namedBindings = [p TsNamedBindings TsNamedBindings]
-> p TsNamedBindings TsNamedBindings
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Market Text Text Text (Identity Text)
-> Market Text Text TsNamedBindings (Identity TsNamedBindings)
Prism' TsNamedBindings Text
_NamespaceImport (Market Text Text Text (Identity Text)
 -> Market Text Text TsNamedBindings (Identity TsNamedBindings))
-> p Text Text -> p TsNamedBindings TsNamedBindings
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
AsteriskToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
          p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
AsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier
      , Market
  [TsImportSpecifier]
  [TsImportSpecifier]
  [TsImportSpecifier]
  (Identity [TsImportSpecifier])
-> Market
     [TsImportSpecifier]
     [TsImportSpecifier]
     TsNamedBindings
     (Identity TsNamedBindings)
Prism' TsNamedBindings [TsImportSpecifier]
_NamedImports (Market
   [TsImportSpecifier]
   [TsImportSpecifier]
   [TsImportSpecifier]
   (Identity [TsImportSpecifier])
 -> Market
      [TsImportSpecifier]
      [TsImportSpecifier]
      TsNamedBindings
      (Identity TsNamedBindings))
-> p [TsImportSpecifier] [TsImportSpecifier]
-> p TsNamedBindings TsNamedBindings
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsImportSpecifier TsImportSpecifier
-> p [TsImportSpecifier] [TsImportSpecifier]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
braced p TsImportSpecifier TsImportSpecifier
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsImportSpecifier TsImportSpecifier
specifier
      ]

specifier :: TsGrammatical p => p TsImportSpecifier TsImportSpecifier
specifier :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsImportSpecifier TsImportSpecifier
specifier = Market
  (Bool, (Maybe Text, Text))
  (Bool, (Maybe Text, Text))
  (Bool, (Maybe Text, Text))
  (Identity (Bool, (Maybe Text, Text)))
-> Market
     (Bool, (Maybe Text, Text))
     (Bool, (Maybe Text, Text))
     TsImportSpecifier
     (Identity TsImportSpecifier)
Iso' TsImportSpecifier (Bool, (Maybe Text, Text))
_TsImportSpecifier (Market
   (Bool, (Maybe Text, Text))
   (Bool, (Maybe Text, Text))
   (Bool, (Maybe Text, Text))
   (Identity (Bool, (Maybe Text, Text)))
 -> Market
      (Bool, (Maybe Text, Text))
      (Bool, (Maybe Text, Text))
      TsImportSpecifier
      (Identity TsImportSpecifier))
-> p (Bool, (Maybe Text, Text)) (Bool, (Maybe Text, Text))
-> p TsImportSpecifier TsImportSpecifier
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
typeOnly
  p Bool Bool
-> p (Maybe Text, Text) (Maybe Text, Text)
-> p (Bool, (Maybe Text, Text)) (Bool, (Maybe Text, Text))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< [p (Maybe Text) (Maybe Text)] -> p (Maybe Text) (Maybe Text)
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
    [ Market Text Text Text (Identity Text)
-> Market Text Text (Maybe Text) (Identity (Maybe Text))
forall a b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Maybe a) (f (Maybe b))
_Just (Market Text Text Text (Identity Text)
 -> Market Text Text (Maybe Text) (Identity (Maybe Text)))
-> p Text Text -> p (Maybe Text) (Maybe Text)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text -> p Text Text
forall a. p Text a -> p Text a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifierName p Text Text -> p () () -> p Text Text
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
AsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space)
    , Maybe Text -> Prism' (Maybe Text) ()
forall a. Eq a => a -> Prism' a ()
only Maybe Text
forall a. Maybe a
Nothing (Market () () () (Identity ())
 -> Market () () (Maybe Text) (Identity (Maybe Text)))
-> p () () -> p (Maybe Text) (Maybe Text)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
    ]
  p (Maybe Text) (Maybe Text)
-> p Text Text -> p (Maybe Text, Text) (Maybe Text, Text)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifierName

-- | A brace of comma separated items, on a line.
braced :: TsGrammatical p => p a a -> p [a] [a]
braced :: forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
braced p a a
item = p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p [a] [a] -> p [a] [a]
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p [a] [a]] -> p [a] [a]
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market () () () (Identity ()) -> Market () () [a] (Identity [a])
forall a. AsEmpty a => Prism' a ()
Prism' [a] ()
_Empty (Market () () () (Identity ()) -> Market () () [a] (Identity [a]))
-> p () () -> p [a] [a]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p [a] [a] -> p [a] [a]
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p a a -> p [a] [a]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
commas1 p a a
item
      p [a] [a] -> p () () -> p [a] [a]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
CloseBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]

variable :: TsGrammatical p => p TsVariableDeclaration TsVariableDeclaration
variable :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsVariableDeclaration TsVariableDeclaration
variable = Market
  (Text, (Maybe TsType, Maybe TsLiteral))
  (Text, (Maybe TsType, Maybe TsLiteral))
  (Text, (Maybe TsType, Maybe TsLiteral))
  (Identity (Text, (Maybe TsType, Maybe TsLiteral)))
-> Market
     (Text, (Maybe TsType, Maybe TsLiteral))
     (Text, (Maybe TsType, Maybe TsLiteral))
     TsVariableDeclaration
     (Identity TsVariableDeclaration)
Iso' TsVariableDeclaration (Text, (Maybe TsType, Maybe TsLiteral))
_TsVariableDeclaration (Market
   (Text, (Maybe TsType, Maybe TsLiteral))
   (Text, (Maybe TsType, Maybe TsLiteral))
   (Text, (Maybe TsType, Maybe TsLiteral))
   (Identity (Text, (Maybe TsType, Maybe TsLiteral)))
 -> Market
      (Text, (Maybe TsType, Maybe TsLiteral))
      (Text, (Maybe TsType, Maybe TsLiteral))
      TsVariableDeclaration
      (Identity TsVariableDeclaration))
-> p (Text, (Maybe TsType, Maybe TsLiteral))
     (Text, (Maybe TsType, Maybe TsLiteral))
-> p TsVariableDeclaration TsVariableDeclaration
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier
  p Text Text
-> p (Maybe TsType, Maybe TsLiteral)
     (Maybe TsType, Maybe TsLiteral)
-> p (Text, (Maybe TsType, Maybe TsLiteral))
     (Text, (Maybe TsType, Maybe TsLiteral))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode)
  p (Maybe TsType) (Maybe TsType)
-> p (Maybe TsLiteral) (Maybe TsLiteral)
-> p (Maybe TsType, Maybe TsLiteral)
     (Maybe TsType, Maybe TsLiteral)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsLiteral TsLiteral -> p (Maybe TsLiteral) (Maybe TsLiteral)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
EqualsToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsLiteral TsLiteral -> p TsLiteral TsLiteral
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsLiteral TsLiteral
forall (p :: * -> * -> *). TsGrammatical p => p TsLiteral TsLiteral
literal)

-- | @extends@ or @implements@ & its heritage, or nothing for none.
heritageClause :: TsGrammatical p => TsTokenCategory -> p [TsHeritage] [TsHeritage]
heritageClause :: forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p [TsHeritage] [TsHeritage]
heritageClause TsTokenCategory
keyword = [p [TsHeritage] [TsHeritage]] -> p [TsHeritage] [TsHeritage]
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market
  (TsHeritage, [TsHeritage])
  (TsHeritage, [TsHeritage])
  (TsHeritage, [TsHeritage])
  (Identity (TsHeritage, [TsHeritage]))
-> Market
     (TsHeritage, [TsHeritage])
     (TsHeritage, [TsHeritage])
     [TsHeritage]
     (Identity [TsHeritage])
forall s t a b. Cons s t a b => Prism s t (a, s) (b, t)
Prism
  [TsHeritage]
  [TsHeritage]
  (TsHeritage, [TsHeritage])
  (TsHeritage, [TsHeritage])
_Cons (Market
   (TsHeritage, [TsHeritage])
   (TsHeritage, [TsHeritage])
   (TsHeritage, [TsHeritage])
   (Identity (TsHeritage, [TsHeritage]))
 -> Market
      (TsHeritage, [TsHeritage])
      (TsHeritage, [TsHeritage])
      [TsHeritage]
      (Identity [TsHeritage]))
-> p (TsHeritage, [TsHeritage]) (TsHeritage, [TsHeritage])
-> p [TsHeritage] [TsHeritage]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
keyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsHeritage TsHeritage -> p TsHeritage TsHeritage
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsHeritage TsHeritage
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsHeritage TsHeritage
heritage
      p TsHeritage TsHeritage
-> p [TsHeritage] [TsHeritage]
-> p (TsHeritage, [TsHeritage]) (TsHeritage, [TsHeritage])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsHeritage TsHeritage -> p [TsHeritage] [TsHeritage]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (p TsHeritage TsHeritage -> p TsHeritage TsHeritage
forall a. p TsHeritage a -> p TsHeritage a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
comma p () () -> p TsHeritage TsHeritage -> p TsHeritage TsHeritage
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsHeritage TsHeritage
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsHeritage TsHeritage
heritage))
  , Market () () () (Identity ())
-> Market () () [TsHeritage] (Identity [TsHeritage])
forall a. AsEmpty a => Prism' a ()
Prism' [TsHeritage] ()
_Empty (Market () () () (Identity ())
 -> Market () () [TsHeritage] (Identity [TsHeritage]))
-> p () () -> p [TsHeritage] [TsHeritage]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]

heritage :: TsGrammatical p => p TsHeritage TsHeritage
heritage :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsHeritage TsHeritage
heritage = Market
  (TsEntityName, [TsType])
  (TsEntityName, [TsType])
  (TsEntityName, [TsType])
  (Identity (TsEntityName, [TsType]))
-> Market
     (TsEntityName, [TsType])
     (TsEntityName, [TsType])
     TsHeritage
     (Identity TsHeritage)
Iso' TsHeritage (TsEntityName, [TsType])
_TsHeritage (Market
   (TsEntityName, [TsType])
   (TsEntityName, [TsType])
   (TsEntityName, [TsType])
   (Identity (TsEntityName, [TsType]))
 -> Market
      (TsEntityName, [TsType])
      (TsEntityName, [TsType])
      TsHeritage
      (Identity TsHeritage))
-> p (TsEntityName, [TsType]) (TsEntityName, [TsType])
-> p TsHeritage TsHeritage
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsEntityName TsEntityName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsEntityName TsEntityName
entityName p TsEntityName TsEntityName
-> p [TsType] [TsType]
-> p (TsEntityName, [TsType]) (TsEntityName, [TsType])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsType] [TsType]
forall (p :: * -> * -> *). TsGrammatical p => p [TsType] [TsType]
typeArguments

{- | A block of items, each on its line, indented & separated, or @{}@.
-}
block
  :: TsGrammatical p
  => Int -> p () () -> (Int -> p a a) -> p [a] [a]
block :: forall (p :: * -> * -> *) a.
TsGrammatical p =>
Int -> p () () -> (Int -> p a a) -> p [a] [a]
block Int
depth p () ()
separator Int -> p a a
item = p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p [a] [a] -> p [a] [a]
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p [a] [a]] -> p [a] [a]
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market () () () (Identity ()) -> Market () () [a] (Identity [a])
forall a. AsEmpty a => Prism' a ()
Prism' [a] ()
_Empty (Market () () () (Identity ()) -> Market () () [a] (Identity [a]))
-> p () () -> p [a] [a]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , p a a -> p [a] [a]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Alternator p => p a b -> p [a] [b]
someP (Int -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
Int -> p () ()
indented (Int
depth Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) p () () -> p a a -> p a a
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* Int -> p a a
item (Int
depth Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) p a a -> p () () -> p a a
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
separator)
    p [a] [a] -> p () () -> p [a] [a]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< Int -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
Int -> p () ()
indented Int
depth p [a] [a] -> p () () -> p [a] [a]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]

-- | A member of an object type, interface or class.
member :: TsGrammatical p => p TsProperty TsProperty
member :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsProperty TsProperty
member = String
-> (p TsProperty TsProperty -> p TsProperty TsProperty)
-> p TsProperty TsProperty
forall bnf. BackusNaurForm bnf => String -> (bnf -> bnf) -> bnf
ruleRec String
"member" ((p TsProperty TsProperty -> p TsProperty TsProperty)
 -> p TsProperty TsProperty)
-> (p TsProperty TsProperty -> p TsProperty TsProperty)
-> p TsProperty TsProperty
forall a b. (a -> b) -> a -> b
$ \p TsProperty TsProperty
self -> [p TsProperty TsProperty] -> p TsProperty TsProperty
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market
  (TsTokenCategory, TsProperty)
  (TsTokenCategory, TsProperty)
  (TsTokenCategory, TsProperty)
  (Identity (TsTokenCategory, TsProperty))
-> Market
     (TsTokenCategory, TsProperty)
     (TsTokenCategory, TsProperty)
     TsProperty
     (Identity TsProperty)
Prism' TsProperty (TsTokenCategory, TsProperty)
_ModifiedMember (Market
   (TsTokenCategory, TsProperty)
   (TsTokenCategory, TsProperty)
   (TsTokenCategory, TsProperty)
   (Identity (TsTokenCategory, TsProperty))
 -> Market
      (TsTokenCategory, TsProperty)
      (TsTokenCategory, TsProperty)
      TsProperty
      (Identity TsProperty))
-> p (TsTokenCategory, TsProperty) (TsTokenCategory, TsProperty)
-> p TsProperty TsProperty
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (TsTokenCategory, TsProperty) (TsTokenCategory, TsProperty)
-> p (TsTokenCategory, TsProperty) (TsTokenCategory, TsProperty)
forall a.
p (TsTokenCategory, TsProperty) a
-> p (TsTokenCategory, TsProperty) a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      ( [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
          [ TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
category (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
          | TsTokenCategory
category <-
            [ TsTokenCategory
PublicKeyword, TsTokenCategory
PrivateKeyword, TsTokenCategory
ProtectedKeyword, TsTokenCategory
StaticKeyword
            , TsTokenCategory
ReadonlyKeyword, TsTokenCategory
AbstractKeyword, TsTokenCategory
OverrideKeyword
            , TsTokenCategory
DeclareKeyword, TsTokenCategory
AccessorKeyword
            ]
          ]
        p TsTokenCategory TsTokenCategory
-> p TsProperty TsProperty
-> p (TsTokenCategory, TsProperty) (TsTokenCategory, TsProperty)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsProperty TsProperty
self
      )
  , Market TsSignature TsSignature TsSignature (Identity TsSignature)
-> Market TsSignature TsSignature TsProperty (Identity TsProperty)
Prism' TsProperty TsSignature
_CallSignature (Market TsSignature TsSignature TsSignature (Identity TsSignature)
 -> Market TsSignature TsSignature TsProperty (Identity TsProperty))
-> p TsSignature TsSignature -> p TsProperty TsProperty
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsSignature TsSignature
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsSignature TsSignature
signature
  , Market TsSignature TsSignature TsSignature (Identity TsSignature)
-> Market TsSignature TsSignature TsProperty (Identity TsProperty)
Prism' TsProperty TsSignature
_ConstructSignature (Market TsSignature TsSignature TsSignature (Identity TsSignature)
 -> Market TsSignature TsSignature TsProperty (Identity TsProperty))
-> p TsSignature TsSignature -> p TsProperty TsProperty
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsSignature TsSignature -> p TsSignature TsSignature
forall a. p TsSignature a -> p TsSignature a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
NewKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsSignature TsSignature -> p TsSignature TsSignature
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsSignature TsSignature
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsSignature TsSignature
signature)
  , Market
  (Text, (TsType, TsType))
  (Text, (TsType, TsType))
  ([TsTokenCategory], (Text, (TsType, TsType)))
  (Identity ([TsTokenCategory], (Text, (TsType, TsType))))
-> Market
     (Text, (TsType, TsType))
     (Text, (TsType, TsType))
     TsProperty
     (Identity TsProperty)
Prism' TsProperty ([TsTokenCategory], (Text, (TsType, TsType)))
_IndexSignature (Market
   (Text, (TsType, TsType))
   (Text, (TsType, TsType))
   ([TsTokenCategory], (Text, (TsType, TsType)))
   (Identity ([TsTokenCategory], (Text, (TsType, TsType))))
 -> Market
      (Text, (TsType, TsType))
      (Text, (TsType, TsType))
      TsProperty
      (Identity TsProperty))
-> (Market
      (Text, (TsType, TsType))
      (Text, (TsType, TsType))
      (Text, (TsType, TsType))
      (Identity (Text, (TsType, TsType)))
    -> Market
         (Text, (TsType, TsType))
         (Text, (TsType, TsType))
         ([TsTokenCategory], (Text, (TsType, TsType)))
         (Identity ([TsTokenCategory], (Text, (TsType, TsType)))))
-> Market
     (Text, (TsType, TsType))
     (Text, (TsType, TsType))
     (Text, (TsType, TsType))
     (Identity (Text, (TsType, TsType)))
-> Market
     (Text, (TsType, TsType))
     (Text, (TsType, TsType))
     TsProperty
     (Identity TsProperty)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (Text, (TsType, TsType))
  (Text, (TsType, TsType))
  (Text, (TsType, TsType))
  (Identity (Text, (TsType, TsType)))
-> Market
     (Text, (TsType, TsType))
     (Text, (TsType, TsType))
     ([TsTokenCategory], (Text, (TsType, TsType)))
     (Identity ([TsTokenCategory], (Text, (TsType, TsType))))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (Text, (TsType, TsType))
   (Text, (TsType, TsType))
   (Text, (TsType, TsType))
   (Identity (Text, (TsType, TsType)))
 -> Market
      (Text, (TsType, TsType))
      (Text, (TsType, TsType))
      TsProperty
      (Identity TsProperty))
-> p (Text, (TsType, TsType)) (Text, (TsType, TsType))
-> p TsProperty TsProperty
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text -> p Text Text
forall a. p Text a -> p Text a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      ( p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier
        p Text Text -> p () () -> p Text Text
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      )
      p Text Text
-> p (TsType, TsType) (TsType, TsType)
-> p (Text, (TsType, TsType)) (Text, (TsType, TsType))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode p TsType TsType -> p () () -> p TsType TsType
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      p TsType TsType
-> p TsType TsType -> p (TsType, TsType) (TsType, TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode
  , Market
  [TsParameter]
  [TsParameter]
  ([TsTokenCategory], [TsParameter])
  (Identity ([TsTokenCategory], [TsParameter]))
-> Market
     [TsParameter] [TsParameter] TsProperty (Identity TsProperty)
Prism' TsProperty ([TsTokenCategory], [TsParameter])
_Constructor (Market
   [TsParameter]
   [TsParameter]
   ([TsTokenCategory], [TsParameter])
   (Identity ([TsTokenCategory], [TsParameter]))
 -> Market
      [TsParameter] [TsParameter] TsProperty (Identity TsProperty))
-> (Market
      [TsParameter] [TsParameter] [TsParameter] (Identity [TsParameter])
    -> Market
         [TsParameter]
         [TsParameter]
         ([TsTokenCategory], [TsParameter])
         (Identity ([TsTokenCategory], [TsParameter])))
-> Market
     [TsParameter] [TsParameter] [TsParameter] (Identity [TsParameter])
-> Market
     [TsParameter] [TsParameter] TsProperty (Identity TsProperty)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  [TsParameter] [TsParameter] [TsParameter] (Identity [TsParameter])
-> Market
     [TsParameter]
     [TsParameter]
     ([TsTokenCategory], [TsParameter])
     (Identity ([TsTokenCategory], [TsParameter]))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   [TsParameter] [TsParameter] [TsParameter] (Identity [TsParameter])
 -> Market
      [TsParameter] [TsParameter] TsProperty (Identity TsProperty))
-> p [TsParameter] [TsParameter] -> p TsProperty TsProperty
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p [TsParameter] [TsParameter] -> p [TsParameter] [TsParameter]
forall a. p [TsParameter] a -> p [TsParameter] a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ConstructorKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () ()
-> p [TsParameter] [TsParameter] -> p [TsParameter] [TsParameter]
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p [TsParameter] [TsParameter]
forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsParameter] [TsParameter]
parameters)
  , Market
  (TsPropertyName, Maybe TsType)
  (TsPropertyName, Maybe TsType)
  ([TsTokenCategory], (TsPropertyName, Maybe TsType))
  (Identity ([TsTokenCategory], (TsPropertyName, Maybe TsType)))
-> Market
     (TsPropertyName, Maybe TsType)
     (TsPropertyName, Maybe TsType)
     TsProperty
     (Identity TsProperty)
Prism'
  TsProperty ([TsTokenCategory], (TsPropertyName, Maybe TsType))
_GetAccessor (Market
   (TsPropertyName, Maybe TsType)
   (TsPropertyName, Maybe TsType)
   ([TsTokenCategory], (TsPropertyName, Maybe TsType))
   (Identity ([TsTokenCategory], (TsPropertyName, Maybe TsType)))
 -> Market
      (TsPropertyName, Maybe TsType)
      (TsPropertyName, Maybe TsType)
      TsProperty
      (Identity TsProperty))
-> (Market
      (TsPropertyName, Maybe TsType)
      (TsPropertyName, Maybe TsType)
      (TsPropertyName, Maybe TsType)
      (Identity (TsPropertyName, Maybe TsType))
    -> Market
         (TsPropertyName, Maybe TsType)
         (TsPropertyName, Maybe TsType)
         ([TsTokenCategory], (TsPropertyName, Maybe TsType))
         (Identity ([TsTokenCategory], (TsPropertyName, Maybe TsType))))
-> Market
     (TsPropertyName, Maybe TsType)
     (TsPropertyName, Maybe TsType)
     (TsPropertyName, Maybe TsType)
     (Identity (TsPropertyName, Maybe TsType))
-> Market
     (TsPropertyName, Maybe TsType)
     (TsPropertyName, Maybe TsType)
     TsProperty
     (Identity TsProperty)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (TsPropertyName, Maybe TsType)
  (TsPropertyName, Maybe TsType)
  (TsPropertyName, Maybe TsType)
  (Identity (TsPropertyName, Maybe TsType))
-> Market
     (TsPropertyName, Maybe TsType)
     (TsPropertyName, Maybe TsType)
     ([TsTokenCategory], (TsPropertyName, Maybe TsType))
     (Identity ([TsTokenCategory], (TsPropertyName, Maybe TsType)))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (TsPropertyName, Maybe TsType)
   (TsPropertyName, Maybe TsType)
   (TsPropertyName, Maybe TsType)
   (Identity (TsPropertyName, Maybe TsType))
 -> Market
      (TsPropertyName, Maybe TsType)
      (TsPropertyName, Maybe TsType)
      TsProperty
      (Identity TsProperty))
-> p (TsPropertyName, Maybe TsType) (TsPropertyName, Maybe TsType)
-> p TsProperty TsProperty
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsPropertyName TsPropertyName -> p TsPropertyName TsPropertyName
forall a. p TsPropertyName a -> p TsPropertyName a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
GetKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p TsPropertyName TsPropertyName
-> p TsPropertyName TsPropertyName
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsPropertyName TsPropertyName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsPropertyName TsPropertyName
propertyName)
      p TsPropertyName TsPropertyName
-> p (Maybe TsType) (Maybe TsType)
-> p (TsPropertyName, Maybe TsType) (TsPropertyName, Maybe TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      p () ()
-> p (Maybe TsType) (Maybe TsType)
-> p (Maybe TsType) (Maybe TsType)
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode)
  , Market
  (TsPropertyName, TsParameter)
  (TsPropertyName, TsParameter)
  ([TsTokenCategory], (TsPropertyName, TsParameter))
  (Identity ([TsTokenCategory], (TsPropertyName, TsParameter)))
-> Market
     (TsPropertyName, TsParameter)
     (TsPropertyName, TsParameter)
     TsProperty
     (Identity TsProperty)
Prism'
  TsProperty ([TsTokenCategory], (TsPropertyName, TsParameter))
_SetAccessor (Market
   (TsPropertyName, TsParameter)
   (TsPropertyName, TsParameter)
   ([TsTokenCategory], (TsPropertyName, TsParameter))
   (Identity ([TsTokenCategory], (TsPropertyName, TsParameter)))
 -> Market
      (TsPropertyName, TsParameter)
      (TsPropertyName, TsParameter)
      TsProperty
      (Identity TsProperty))
-> (Market
      (TsPropertyName, TsParameter)
      (TsPropertyName, TsParameter)
      (TsPropertyName, TsParameter)
      (Identity (TsPropertyName, TsParameter))
    -> Market
         (TsPropertyName, TsParameter)
         (TsPropertyName, TsParameter)
         ([TsTokenCategory], (TsPropertyName, TsParameter))
         (Identity ([TsTokenCategory], (TsPropertyName, TsParameter))))
-> Market
     (TsPropertyName, TsParameter)
     (TsPropertyName, TsParameter)
     (TsPropertyName, TsParameter)
     (Identity (TsPropertyName, TsParameter))
-> Market
     (TsPropertyName, TsParameter)
     (TsPropertyName, TsParameter)
     TsProperty
     (Identity TsProperty)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (TsPropertyName, TsParameter)
  (TsPropertyName, TsParameter)
  (TsPropertyName, TsParameter)
  (Identity (TsPropertyName, TsParameter))
-> Market
     (TsPropertyName, TsParameter)
     (TsPropertyName, TsParameter)
     ([TsTokenCategory], (TsPropertyName, TsParameter))
     (Identity ([TsTokenCategory], (TsPropertyName, TsParameter)))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (TsPropertyName, TsParameter)
   (TsPropertyName, TsParameter)
   (TsPropertyName, TsParameter)
   (Identity (TsPropertyName, TsParameter))
 -> Market
      (TsPropertyName, TsParameter)
      (TsPropertyName, TsParameter)
      TsProperty
      (Identity TsProperty))
-> p (TsPropertyName, TsParameter) (TsPropertyName, TsParameter)
-> p TsProperty TsProperty
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsPropertyName TsPropertyName -> p TsPropertyName TsPropertyName
forall a. p TsPropertyName a -> p TsPropertyName a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
SetKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p TsPropertyName TsPropertyName
-> p TsPropertyName TsPropertyName
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsPropertyName TsPropertyName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsPropertyName TsPropertyName
propertyName)
      p TsPropertyName TsPropertyName
-> p TsParameter TsParameter
-> p (TsPropertyName, TsParameter) (TsPropertyName, TsParameter)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p TsParameter TsParameter -> p TsParameter TsParameter
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsParameter TsParameter
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsParameter TsParameter
parameter
      p TsParameter TsParameter -> p () () -> p TsParameter TsParameter
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , Market
  (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
  (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
  (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
  (Identity
     (TsPropertyName, (Bool, Either TsSignature (Maybe TsType))))
-> Market
     (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
     (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
     TsProperty
     (Identity TsProperty)
Prism'
  TsProperty
  (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
_Named (Market
   (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
   (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
   (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
   (Identity
      (TsPropertyName, (Bool, Either TsSignature (Maybe TsType))))
 -> Market
      (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
      (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
      TsProperty
      (Identity TsProperty))
-> p (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
     (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
-> p TsProperty TsProperty
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsPropertyName TsPropertyName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsPropertyName TsPropertyName
propertyName p TsPropertyName TsPropertyName
-> p (Bool, Either TsSignature (Maybe TsType))
     (Bool, Either TsSignature (Maybe TsType))
-> p (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
     (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
question p Bool Bool
-> p (Either TsSignature (Maybe TsType))
     (Either TsSignature (Maybe TsType))
-> p (Bool, Either TsSignature (Maybe TsType))
     (Bool, Either TsSignature (Maybe TsType))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*<
      ( p TsSignature TsSignature
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsSignature TsSignature
signature
        p TsSignature TsSignature
-> p (Maybe TsType) (Maybe TsType)
-> p (Either TsSignature (Maybe TsType))
     (Either TsSignature (Maybe TsType))
forall a b c d. p a b -> p c d -> p (Either a c) (Either b d)
forall (p :: * -> * -> *) a b c d.
CocartesianMonoidal p =>
p a b -> p c d -> p (Either a c) (Either b d)
>+< p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode)
      )
  ]

-- | A member, with a modifier.
_ModifiedMember :: Prism' TsProperty (TsTokenCategory, TsProperty)
_ModifiedMember :: Prism' TsProperty (TsTokenCategory, TsProperty)
_ModifiedMember = ((TsTokenCategory, TsProperty) -> TsProperty)
-> (TsProperty -> Maybe (TsTokenCategory, TsProperty))
-> Prism' TsProperty (TsTokenCategory, TsProperty)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (\(TsTokenCategory
m, TsProperty
prop) -> ASetter TsProperty TsProperty [TsTokenCategory] [TsTokenCategory]
-> ([TsTokenCategory] -> [TsTokenCategory])
-> TsProperty
-> TsProperty
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter TsProperty TsProperty [TsTokenCategory] [TsTokenCategory]
Traversal' TsProperty [TsTokenCategory]
modifiers (TsTokenCategory
m TsTokenCategory -> [TsTokenCategory] -> [TsTokenCategory]
forall a. a -> [a] -> [a]
:) TsProperty
prop) ((TsProperty -> Maybe (TsTokenCategory, TsProperty))
 -> Prism' TsProperty (TsTokenCategory, TsProperty))
-> (TsProperty -> Maybe (TsTokenCategory, TsProperty))
-> Prism' TsProperty (TsTokenCategory, TsProperty)
forall a b. (a -> b) -> a -> b
$ \TsProperty
prop ->
  case TsProperty
prop TsProperty
-> Getting (First [TsTokenCategory]) TsProperty [TsTokenCategory]
-> Maybe [TsTokenCategory]
forall s a. s -> Getting (First a) s a -> Maybe a
^? Getting (First [TsTokenCategory]) TsProperty [TsTokenCategory]
Traversal' TsProperty [TsTokenCategory]
modifiers of
    Just (TsTokenCategory
m : [TsTokenCategory]
ms) -> (TsTokenCategory, TsProperty)
-> Maybe (TsTokenCategory, TsProperty)
forall a. a -> Maybe a
Just (TsTokenCategory
m, ASetter TsProperty TsProperty [TsTokenCategory] [TsTokenCategory]
-> [TsTokenCategory] -> TsProperty -> TsProperty
forall s t a b. ASetter s t a b -> b -> s -> t
set ASetter TsProperty TsProperty [TsTokenCategory] [TsTokenCategory]
Traversal' TsProperty [TsTokenCategory]
modifiers [TsTokenCategory]
ms TsProperty
prop)
    Maybe [TsTokenCategory]
_ -> Maybe (TsTokenCategory, TsProperty)
forall a. Maybe a
Nothing
  where
    modifiers :: Traversal' TsProperty [TsTokenCategory]
    modifiers :: Traversal' TsProperty [TsTokenCategory]
modifiers [TsTokenCategory] -> f [TsTokenCategory]
f = \case
      PropertySignature [TsTokenCategory]
ms TsPropertyName
n Bool
o Maybe TsType
t ->
        (\[TsTokenCategory]
ms' -> [TsTokenCategory]
-> TsPropertyName -> Bool -> Maybe TsType -> TsProperty
PropertySignature [TsTokenCategory]
ms' TsPropertyName
n Bool
o Maybe TsType
t) ([TsTokenCategory] -> TsProperty)
-> f [TsTokenCategory] -> f TsProperty
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      MethodSignature [TsTokenCategory]
ms TsPropertyName
n Bool
o TsSignature
s ->
        (\[TsTokenCategory]
ms' -> [TsTokenCategory]
-> TsPropertyName -> Bool -> TsSignature -> TsProperty
MethodSignature [TsTokenCategory]
ms' TsPropertyName
n Bool
o TsSignature
s) ([TsTokenCategory] -> TsProperty)
-> f [TsTokenCategory] -> f TsProperty
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      IndexSignature [TsTokenCategory]
ms Text
n TsType
k TsType
t -> (\[TsTokenCategory]
ms' -> [TsTokenCategory] -> Text -> TsType -> TsType -> TsProperty
IndexSignature [TsTokenCategory]
ms' Text
n TsType
k TsType
t) ([TsTokenCategory] -> TsProperty)
-> f [TsTokenCategory] -> f TsProperty
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      GetAccessor [TsTokenCategory]
ms TsPropertyName
n Maybe TsType
t -> (\[TsTokenCategory]
ms' -> [TsTokenCategory] -> TsPropertyName -> Maybe TsType -> TsProperty
GetAccessor [TsTokenCategory]
ms' TsPropertyName
n Maybe TsType
t) ([TsTokenCategory] -> TsProperty)
-> f [TsTokenCategory] -> f TsProperty
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      SetAccessor [TsTokenCategory]
ms TsPropertyName
n TsParameter
p -> (\[TsTokenCategory]
ms' -> [TsTokenCategory] -> TsPropertyName -> TsParameter -> TsProperty
SetAccessor [TsTokenCategory]
ms' TsPropertyName
n TsParameter
p) ([TsTokenCategory] -> TsProperty)
-> f [TsTokenCategory] -> f TsProperty
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      Constructor [TsTokenCategory]
ms [TsParameter]
ps -> (\[TsTokenCategory]
ms' -> [TsTokenCategory] -> [TsParameter] -> TsProperty
Constructor [TsTokenCategory]
ms' [TsParameter]
ps) ([TsTokenCategory] -> TsProperty)
-> f [TsTokenCategory] -> f TsProperty
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TsTokenCategory] -> f [TsTokenCategory]
f [TsTokenCategory]
ms
      TsProperty
prop -> TsProperty -> f TsProperty
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TsProperty
prop

{- | A method or property without modifiers, by its name, whether it's
optional, & its signature or type.
-}
_Named
  :: Prism' TsProperty
      (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
_Named :: Prism'
  TsProperty
  (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
_Named = ((TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
 -> TsProperty)
-> (TsProperty
    -> Maybe
         (TsPropertyName, (Bool, Either TsSignature (Maybe TsType))))
-> Prism'
     TsProperty
     (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\case
    (TsPropertyName
name, (Bool
optional, Left TsSignature
sig)) -> [TsTokenCategory]
-> TsPropertyName -> Bool -> TsSignature -> TsProperty
MethodSignature [] TsPropertyName
name Bool
optional TsSignature
sig
    (TsPropertyName
name, (Bool
optional, Right Maybe TsType
t)) -> [TsTokenCategory]
-> TsPropertyName -> Bool -> Maybe TsType -> TsProperty
PropertySignature [] TsPropertyName
name Bool
optional Maybe TsType
t)
  (\case
    MethodSignature [] TsPropertyName
name Bool
optional TsSignature
sig -> (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
-> Maybe
     (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
forall a. a -> Maybe a
Just (TsPropertyName
name, (Bool
optional, TsSignature -> Either TsSignature (Maybe TsType)
forall a b. a -> Either a b
Left TsSignature
sig))
    PropertySignature [] TsPropertyName
name Bool
optional Maybe TsType
t -> (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
-> Maybe
     (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
forall a. a -> Maybe a
Just (TsPropertyName
name, (Bool
optional, Maybe TsType -> Either TsSignature (Maybe TsType)
forall a b. b -> Either a b
Right Maybe TsType
t))
    TsProperty
_ -> Maybe (TsPropertyName, (Bool, Either TsSignature (Maybe TsType)))
forall a. Maybe a
Nothing)

propertyName :: TsGrammatical p => p TsPropertyName TsPropertyName
propertyName :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsPropertyName TsPropertyName
propertyName = [p TsPropertyName TsPropertyName]
-> p TsPropertyName TsPropertyName
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market Text Text Text (Identity Text)
-> Market Text Text TsPropertyName (Identity TsPropertyName)
Prism' TsPropertyName Text
_PropertyIdentifier (Market Text Text Text (Identity Text)
 -> Market Text Text TsPropertyName (Identity TsPropertyName))
-> p Text Text -> p TsPropertyName TsPropertyName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifierName
  , Market Text Text Text (Identity Text)
-> Market Text Text TsPropertyName (Identity TsPropertyName)
Prism' TsPropertyName Text
_PropertyString (Market Text Text Text (Identity Text)
 -> Market Text Text TsPropertyName (Identity TsPropertyName))
-> p Text Text -> p TsPropertyName TsPropertyName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
StringLiteral
  , Market Text Text Text (Identity Text)
-> Market Text Text TsPropertyName (Identity TsPropertyName)
Prism' TsPropertyName Text
_PropertyNumeric (Market Text Text Text (Identity Text)
 -> Market Text Text TsPropertyName (Identity TsPropertyName))
-> p Text Text -> p TsPropertyName TsPropertyName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
NumericLiteral
  , Market Text Text Text (Identity Text)
-> Market Text Text TsPropertyName (Identity TsPropertyName)
Prism' TsPropertyName Text
_PropertyPrivate (Market Text Text Text (Identity Text)
 -> Market Text Text TsPropertyName (Identity TsPropertyName))
-> p Text Text -> p TsPropertyName TsPropertyName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
PrivateIdentifier
  , Market
  TsEntityName TsEntityName TsEntityName (Identity TsEntityName)
-> Market
     TsEntityName TsEntityName TsPropertyName (Identity TsPropertyName)
Prism' TsPropertyName TsEntityName
_ComputedPropertyName (Market
   TsEntityName TsEntityName TsEntityName (Identity TsEntityName)
 -> Market
      TsEntityName TsEntityName TsPropertyName (Identity TsPropertyName))
-> p TsEntityName TsEntityName -> p TsPropertyName TsPropertyName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      p () ()
-> p TsEntityName TsEntityName -> p TsEntityName TsEntityName
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsEntityName TsEntityName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsEntityName TsEntityName
entityName p TsEntityName TsEntityName
-> p () () -> p TsEntityName TsEntityName
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]

-- | @\<T>(x: T): U@, with a return type or not.
signature :: TsGrammatical p => p TsSignature TsSignature
signature :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsSignature TsSignature
signature = Market
  ([TsTypeParameter], ([TsParameter], Maybe TsType))
  ([TsTypeParameter], ([TsParameter], Maybe TsType))
  ([TsTypeParameter], ([TsParameter], Maybe TsType))
  (Identity ([TsTypeParameter], ([TsParameter], Maybe TsType)))
-> Market
     ([TsTypeParameter], ([TsParameter], Maybe TsType))
     ([TsTypeParameter], ([TsParameter], Maybe TsType))
     TsSignature
     (Identity TsSignature)
Iso' TsSignature ([TsTypeParameter], ([TsParameter], Maybe TsType))
_TsSignature (Market
   ([TsTypeParameter], ([TsParameter], Maybe TsType))
   ([TsTypeParameter], ([TsParameter], Maybe TsType))
   ([TsTypeParameter], ([TsParameter], Maybe TsType))
   (Identity ([TsTypeParameter], ([TsParameter], Maybe TsType)))
 -> Market
      ([TsTypeParameter], ([TsParameter], Maybe TsType))
      ([TsTypeParameter], ([TsParameter], Maybe TsType))
      TsSignature
      (Identity TsSignature))
-> p ([TsTypeParameter], ([TsParameter], Maybe TsType))
     ([TsTypeParameter], ([TsParameter], Maybe TsType))
-> p TsSignature TsSignature
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p [TsTypeParameter] [TsTypeParameter]
forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsTypeParameter] [TsTypeParameter]
typeParameters p [TsTypeParameter] [TsTypeParameter]
-> p ([TsParameter], Maybe TsType) ([TsParameter], Maybe TsType)
-> p ([TsTypeParameter], ([TsParameter], Maybe TsType))
     ([TsTypeParameter], ([TsParameter], Maybe TsType))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsParameter] [TsParameter]
forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsParameter] [TsParameter]
parameters
  p [TsParameter] [TsParameter]
-> p (Maybe TsType) (Maybe TsType)
-> p ([TsParameter], Maybe TsType) ([TsParameter], Maybe TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
returnType)

parameters :: TsGrammatical p => p [TsParameter] [TsParameter]
parameters :: forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsParameter] [TsParameter]
parameters = p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  p () ()
-> p [TsParameter] [TsParameter] -> p [TsParameter] [TsParameter]
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsParameter TsParameter -> p [TsParameter] [TsParameter]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
commas p TsParameter TsParameter
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsParameter TsParameter
parameter
  p [TsParameter] [TsParameter]
-> p () () -> p [TsParameter] [TsParameter]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP

parameter :: TsGrammatical p => p TsParameter TsParameter
parameter :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsParameter TsParameter
parameter = Market
  (Bool, (TsBindingName, (Bool, Maybe TsType)))
  (Bool, (TsBindingName, (Bool, Maybe TsType)))
  (Bool, (TsBindingName, (Bool, Maybe TsType)))
  (Identity (Bool, (TsBindingName, (Bool, Maybe TsType))))
-> Market
     (Bool, (TsBindingName, (Bool, Maybe TsType)))
     (Bool, (TsBindingName, (Bool, Maybe TsType)))
     TsParameter
     (Identity TsParameter)
Iso' TsParameter (Bool, (TsBindingName, (Bool, Maybe TsType)))
_TsParameter (Market
   (Bool, (TsBindingName, (Bool, Maybe TsType)))
   (Bool, (TsBindingName, (Bool, Maybe TsType)))
   (Bool, (TsBindingName, (Bool, Maybe TsType)))
   (Identity (Bool, (TsBindingName, (Bool, Maybe TsType))))
 -> Market
      (Bool, (TsBindingName, (Bool, Maybe TsType)))
      (Bool, (TsBindingName, (Bool, Maybe TsType)))
      TsParameter
      (Identity TsParameter))
-> p (Bool, (TsBindingName, (Bool, Maybe TsType)))
     (Bool, (TsBindingName, (Bool, Maybe TsType)))
-> p TsParameter TsParameter
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
dots p Bool Bool
-> p (TsBindingName, (Bool, Maybe TsType))
     (TsBindingName, (Bool, Maybe TsType))
-> p (Bool, (TsBindingName, (Bool, Maybe TsType)))
     (Bool, (TsBindingName, (Bool, Maybe TsType)))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsBindingName TsBindingName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsBindingName TsBindingName
bindingName p TsBindingName TsBindingName
-> p (Bool, Maybe TsType) (Bool, Maybe TsType)
-> p (TsBindingName, (Bool, Maybe TsType))
     (TsBindingName, (Bool, Maybe TsType))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
question
  p Bool Bool
-> p (Maybe TsType) (Maybe TsType)
-> p (Bool, Maybe TsType) (Bool, Maybe TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode)

bindingName :: TsGrammatical p => p TsBindingName TsBindingName
bindingName :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsBindingName TsBindingName
bindingName = String
-> (p TsBindingName TsBindingName -> p TsBindingName TsBindingName)
-> p TsBindingName TsBindingName
forall bnf. BackusNaurForm bnf => String -> (bnf -> bnf) -> bnf
ruleRec String
"binding" ((p TsBindingName TsBindingName -> p TsBindingName TsBindingName)
 -> p TsBindingName TsBindingName)
-> (p TsBindingName TsBindingName -> p TsBindingName TsBindingName)
-> p TsBindingName TsBindingName
forall a b. (a -> b) -> a -> b
$ \p TsBindingName TsBindingName
self -> [p TsBindingName TsBindingName] -> p TsBindingName TsBindingName
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market Text Text Text (Identity Text)
-> Market Text Text TsBindingName (Identity TsBindingName)
Prism' TsBindingName Text
_BindingIdentifier (Market Text Text Text (Identity Text)
 -> Market Text Text TsBindingName (Identity TsBindingName))
-> p Text Text -> p TsBindingName TsBindingName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? [p Text Text] -> p Text Text
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier, Text -> Prism' Text ()
forall a. Eq a => a -> Prism' a ()
only Text
"this" (Market () () () (Identity ())
 -> Market () () Text (Identity Text))
-> p () () -> p Text Text
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ThisKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP]
  , Market
  [TsBindingElement]
  [TsBindingElement]
  [TsBindingElement]
  (Identity [TsBindingElement])
-> Market
     [TsBindingElement]
     [TsBindingElement]
     TsBindingName
     (Identity TsBindingName)
Prism' TsBindingName [TsBindingElement]
_ObjectBindingPattern (Market
   [TsBindingElement]
   [TsBindingElement]
   [TsBindingElement]
   (Identity [TsBindingElement])
 -> Market
      [TsBindingElement]
      [TsBindingElement]
      TsBindingName
      (Identity TsBindingName))
-> p [TsBindingElement] [TsBindingElement]
-> p TsBindingName TsBindingName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsBindingElement TsBindingElement
-> p [TsBindingElement] [TsBindingElement]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
braced (p TsBindingName TsBindingName
-> p TsBindingElement TsBindingElement
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsBindingName TsBindingName
-> p TsBindingElement TsBindingElement
bindingElement p TsBindingName TsBindingName
self)
  , Market
  [TsBindingElement]
  [TsBindingElement]
  [TsBindingElement]
  (Identity [TsBindingElement])
-> Market
     [TsBindingElement]
     [TsBindingElement]
     TsBindingName
     (Identity TsBindingName)
Prism' TsBindingName [TsBindingElement]
_ArrayBindingPattern (Market
   [TsBindingElement]
   [TsBindingElement]
   [TsBindingElement]
   (Identity [TsBindingElement])
 -> Market
      [TsBindingElement]
      [TsBindingElement]
      TsBindingName
      (Identity TsBindingName))
-> p [TsBindingElement] [TsBindingElement]
-> p TsBindingName TsBindingName
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      p () ()
-> p [TsBindingElement] [TsBindingElement]
-> p [TsBindingElement] [TsBindingElement]
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsBindingElement TsBindingElement
-> p [TsBindingElement] [TsBindingElement]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
commas (p TsBindingName TsBindingName
-> p TsBindingElement TsBindingElement
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsBindingName TsBindingName
-> p TsBindingElement TsBindingElement
bindingElement p TsBindingName TsBindingName
self) p [TsBindingElement] [TsBindingElement]
-> p () () -> p [TsBindingElement] [TsBindingElement]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]

-- | An element of a binding pattern, by a binding name.
bindingElement
  :: TsGrammatical p
  => p TsBindingName TsBindingName -> p TsBindingElement TsBindingElement
bindingElement :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsBindingName TsBindingName
-> p TsBindingElement TsBindingElement
bindingElement p TsBindingName TsBindingName
name = Market
  (Bool, (Maybe TsPropertyName, TsBindingName))
  (Bool, (Maybe TsPropertyName, TsBindingName))
  (Bool, (Maybe TsPropertyName, TsBindingName))
  (Identity (Bool, (Maybe TsPropertyName, TsBindingName)))
-> Market
     (Bool, (Maybe TsPropertyName, TsBindingName))
     (Bool, (Maybe TsPropertyName, TsBindingName))
     TsBindingElement
     (Identity TsBindingElement)
Iso' TsBindingElement (Bool, (Maybe TsPropertyName, TsBindingName))
_TsBindingElement (Market
   (Bool, (Maybe TsPropertyName, TsBindingName))
   (Bool, (Maybe TsPropertyName, TsBindingName))
   (Bool, (Maybe TsPropertyName, TsBindingName))
   (Identity (Bool, (Maybe TsPropertyName, TsBindingName)))
 -> Market
      (Bool, (Maybe TsPropertyName, TsBindingName))
      (Bool, (Maybe TsPropertyName, TsBindingName))
      TsBindingElement
      (Identity TsBindingElement))
-> p (Bool, (Maybe TsPropertyName, TsBindingName))
     (Bool, (Maybe TsPropertyName, TsBindingName))
-> p TsBindingElement TsBindingElement
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
dots
  p Bool Bool
-> p (Maybe TsPropertyName, TsBindingName)
     (Maybe TsPropertyName, TsBindingName)
-> p (Bool, (Maybe TsPropertyName, TsBindingName))
     (Bool, (Maybe TsPropertyName, TsBindingName))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< [p (Maybe TsPropertyName) (Maybe TsPropertyName)]
-> p (Maybe TsPropertyName) (Maybe TsPropertyName)
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
    [ Market
  TsPropertyName
  TsPropertyName
  TsPropertyName
  (Identity TsPropertyName)
-> Market
     TsPropertyName
     TsPropertyName
     (Maybe TsPropertyName)
     (Identity (Maybe TsPropertyName))
forall a b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Maybe a) (f (Maybe b))
_Just (Market
   TsPropertyName
   TsPropertyName
   TsPropertyName
   (Identity TsPropertyName)
 -> Market
      TsPropertyName
      TsPropertyName
      (Maybe TsPropertyName)
      (Identity (Maybe TsPropertyName)))
-> p TsPropertyName TsPropertyName
-> p (Maybe TsPropertyName) (Maybe TsPropertyName)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsPropertyName TsPropertyName -> p TsPropertyName TsPropertyName
forall a. p TsPropertyName a -> p TsPropertyName a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p TsPropertyName TsPropertyName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsPropertyName TsPropertyName
propertyName p TsPropertyName TsPropertyName
-> p () () -> p TsPropertyName TsPropertyName
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space)
    , Maybe TsPropertyName -> Prism' (Maybe TsPropertyName) ()
forall a. Eq a => a -> Prism' a ()
only Maybe TsPropertyName
forall a. Maybe a
Nothing (Market () () () (Identity ())
 -> Market
      () () (Maybe TsPropertyName) (Identity (Maybe TsPropertyName)))
-> p () () -> p (Maybe TsPropertyName) (Maybe TsPropertyName)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
    ]
  p (Maybe TsPropertyName) (Maybe TsPropertyName)
-> p TsBindingName TsBindingName
-> p (Maybe TsPropertyName, TsBindingName)
     (Maybe TsPropertyName, TsBindingName)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsBindingName TsBindingName
name

typeParameters :: TsGrammatical p => p [TsTypeParameter] [TsTypeParameter]
typeParameters :: forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsTypeParameter] [TsTypeParameter]
typeParameters = p TsTypeParameter TsTypeParameter
-> p [TsTypeParameter] [TsTypeParameter]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
angled p TsTypeParameter TsTypeParameter
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsTypeParameter TsTypeParameter
typeParameter

typeParameter :: TsGrammatical p => p TsTypeParameter TsTypeParameter
typeParameter :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsTypeParameter TsTypeParameter
typeParameter = String
-> (p TsTypeParameter TsTypeParameter
    -> p TsTypeParameter TsTypeParameter)
-> p TsTypeParameter TsTypeParameter
forall bnf. BackusNaurForm bnf => String -> (bnf -> bnf) -> bnf
ruleRec String
"type parameter" ((p TsTypeParameter TsTypeParameter
  -> p TsTypeParameter TsTypeParameter)
 -> p TsTypeParameter TsTypeParameter)
-> (p TsTypeParameter TsTypeParameter
    -> p TsTypeParameter TsTypeParameter)
-> p TsTypeParameter TsTypeParameter
forall a b. (a -> b) -> a -> b
$ \p TsTypeParameter TsTypeParameter
self -> [p TsTypeParameter TsTypeParameter]
-> p TsTypeParameter TsTypeParameter
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market
  (TsTokenCategory, TsTypeParameter)
  (TsTokenCategory, TsTypeParameter)
  (TsTokenCategory, TsTypeParameter)
  (Identity (TsTokenCategory, TsTypeParameter))
-> Market
     (TsTokenCategory, TsTypeParameter)
     (TsTokenCategory, TsTypeParameter)
     TsTypeParameter
     (Identity TsTypeParameter)
Prism' TsTypeParameter (TsTokenCategory, TsTypeParameter)
_ModifiedParameter (Market
   (TsTokenCategory, TsTypeParameter)
   (TsTokenCategory, TsTypeParameter)
   (TsTokenCategory, TsTypeParameter)
   (Identity (TsTokenCategory, TsTypeParameter))
 -> Market
      (TsTokenCategory, TsTypeParameter)
      (TsTokenCategory, TsTypeParameter)
      TsTypeParameter
      (Identity TsTypeParameter))
-> p (TsTokenCategory, TsTypeParameter)
     (TsTokenCategory, TsTypeParameter)
-> p TsTypeParameter TsTypeParameter
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (TsTokenCategory, TsTypeParameter)
  (TsTokenCategory, TsTypeParameter)
-> p (TsTokenCategory, TsTypeParameter)
     (TsTokenCategory, TsTypeParameter)
forall a.
p (TsTokenCategory, TsTypeParameter) a
-> p (TsTokenCategory, TsTypeParameter) a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      ( [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
          [ TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
category (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
          | TsTokenCategory
category <- [TsTokenCategory
ConstKeyword, TsTokenCategory
InKeyword, TsTokenCategory
OutKeyword]
          ]
        p TsTokenCategory TsTokenCategory
-> p TsTypeParameter TsTypeParameter
-> p (TsTokenCategory, TsTypeParameter)
     (TsTokenCategory, TsTypeParameter)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsTypeParameter TsTypeParameter
self
      )
  , Market
  (Text, (Maybe TsType, Maybe TsType))
  (Text, (Maybe TsType, Maybe TsType))
  ([TsTokenCategory], (Text, (Maybe TsType, Maybe TsType)))
  (Identity
     ([TsTokenCategory], (Text, (Maybe TsType, Maybe TsType))))
-> Market
     (Text, (Maybe TsType, Maybe TsType))
     (Text, (Maybe TsType, Maybe TsType))
     TsTypeParameter
     (Identity TsTypeParameter)
Iso'
  TsTypeParameter
  ([TsTokenCategory], (Text, (Maybe TsType, Maybe TsType)))
_TsTypeParameter (Market
   (Text, (Maybe TsType, Maybe TsType))
   (Text, (Maybe TsType, Maybe TsType))
   ([TsTokenCategory], (Text, (Maybe TsType, Maybe TsType)))
   (Identity
      ([TsTokenCategory], (Text, (Maybe TsType, Maybe TsType))))
 -> Market
      (Text, (Maybe TsType, Maybe TsType))
      (Text, (Maybe TsType, Maybe TsType))
      TsTypeParameter
      (Identity TsTypeParameter))
-> (Market
      (Text, (Maybe TsType, Maybe TsType))
      (Text, (Maybe TsType, Maybe TsType))
      (Text, (Maybe TsType, Maybe TsType))
      (Identity (Text, (Maybe TsType, Maybe TsType)))
    -> Market
         (Text, (Maybe TsType, Maybe TsType))
         (Text, (Maybe TsType, Maybe TsType))
         ([TsTokenCategory], (Text, (Maybe TsType, Maybe TsType)))
         (Identity
            ([TsTokenCategory], (Text, (Maybe TsType, Maybe TsType)))))
-> Market
     (Text, (Maybe TsType, Maybe TsType))
     (Text, (Maybe TsType, Maybe TsType))
     (Text, (Maybe TsType, Maybe TsType))
     (Identity (Text, (Maybe TsType, Maybe TsType)))
-> Market
     (Text, (Maybe TsType, Maybe TsType))
     (Text, (Maybe TsType, Maybe TsType))
     TsTypeParameter
     (Identity TsTypeParameter)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  (Text, (Maybe TsType, Maybe TsType))
  (Text, (Maybe TsType, Maybe TsType))
  (Text, (Maybe TsType, Maybe TsType))
  (Identity (Text, (Maybe TsType, Maybe TsType)))
-> Market
     (Text, (Maybe TsType, Maybe TsType))
     (Text, (Maybe TsType, Maybe TsType))
     ([TsTokenCategory], (Text, (Maybe TsType, Maybe TsType)))
     (Identity
        ([TsTokenCategory], (Text, (Maybe TsType, Maybe TsType))))
forall a (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a) -> p ([TsTokenCategory], a) (f ([TsTokenCategory], a))
noModifiers (Market
   (Text, (Maybe TsType, Maybe TsType))
   (Text, (Maybe TsType, Maybe TsType))
   (Text, (Maybe TsType, Maybe TsType))
   (Identity (Text, (Maybe TsType, Maybe TsType)))
 -> Market
      (Text, (Maybe TsType, Maybe TsType))
      (Text, (Maybe TsType, Maybe TsType))
      TsTypeParameter
      (Identity TsTypeParameter))
-> p (Text, (Maybe TsType, Maybe TsType))
     (Text, (Maybe TsType, Maybe TsType))
-> p TsTypeParameter TsTypeParameter
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier
      p Text Text
-> p (Maybe TsType, Maybe TsType) (Maybe TsType, Maybe TsType)
-> p (Text, (Maybe TsType, Maybe TsType))
     (Text, (Maybe TsType, Maybe TsType))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
ExtendsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode)
      p (Maybe TsType) (Maybe TsType)
-> p (Maybe TsType) (Maybe TsType)
-> p (Maybe TsType, Maybe TsType) (Maybe TsType, Maybe TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
EqualsToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode)
  ]

-- | A type parameter, with a modifier.
_ModifiedParameter
  :: Prism' TsTypeParameter (TsTokenCategory, TsTypeParameter)
_ModifiedParameter :: Prism' TsTypeParameter (TsTokenCategory, TsTypeParameter)
_ModifiedParameter = ((TsTokenCategory, TsTypeParameter) -> TsTypeParameter)
-> (TsTypeParameter -> Maybe (TsTokenCategory, TsTypeParameter))
-> Prism' TsTypeParameter (TsTokenCategory, TsTypeParameter)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\(TsTokenCategory
m, TsTypeParameter [TsTokenCategory]
ms Text
n Maybe TsType
c Maybe TsType
d) -> [TsTokenCategory]
-> Text -> Maybe TsType -> Maybe TsType -> TsTypeParameter
TsTypeParameter (TsTokenCategory
m TsTokenCategory -> [TsTokenCategory] -> [TsTokenCategory]
forall a. a -> [a] -> [a]
: [TsTokenCategory]
ms) Text
n Maybe TsType
c Maybe TsType
d)
  (\case
    TsTypeParameter (TsTokenCategory
m : [TsTokenCategory]
ms) Text
n Maybe TsType
c Maybe TsType
d -> (TsTokenCategory, TsTypeParameter)
-> Maybe (TsTokenCategory, TsTypeParameter)
forall a. a -> Maybe a
Just (TsTokenCategory
m, [TsTokenCategory]
-> Text -> Maybe TsType -> Maybe TsType -> TsTypeParameter
TsTypeParameter [TsTokenCategory]
ms Text
n Maybe TsType
c Maybe TsType
d)
    TsTypeParameter
_ -> Maybe (TsTokenCategory, TsTypeParameter)
forall a. Maybe a
Nothing)

-- | Type arguments, @\<T, U>@, or none.
typeArguments :: TsGrammatical p => p [TsType] [TsType]
typeArguments :: forall (p :: * -> * -> *). TsGrammatical p => p [TsType] [TsType]
typeArguments = p TsType TsType -> p [TsType] [TsType]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
angled p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode

-- | @\<a, b>@, or nothing for none.
angled :: TsGrammatical p => p a a -> p [a] [a]
angled :: forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
angled p a a
item = [p [a] [a]] -> p [a] [a]
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market (a, [a]) (a, [a]) (a, [a]) (Identity (a, [a]))
-> Market (a, [a]) (a, [a]) [a] (Identity [a])
forall s t a b. Cons s t a b => Prism s t (a, s) (b, t)
Prism [a] [a] (a, [a]) (a, [a])
_Cons (Market (a, [a]) (a, [a]) (a, [a]) (Identity (a, [a]))
 -> Market (a, [a]) (a, [a]) [a] (Identity [a]))
-> p (a, [a]) (a, [a]) -> p [a] [a]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
LessThanToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p a a -> p a a
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p a a
item
      p a a -> p [a] [a] -> p (a, [a]) (a, [a])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p a a -> p [a] [a]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (p a a -> p a a
forall a. p a a -> p a a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
comma p () () -> p a a -> p a a
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p a a
item))
      p [a] [a] -> p () () -> p [a] [a]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< TsTokenCategory -> p () ()
forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p () ()
optionalToken TsTokenCategory
CommaToken
      p [a] [a] -> p () () -> p [a] [a]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
GreaterThanToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , Market () () () (Identity ()) -> Market () () [a] (Identity [a])
forall a. AsEmpty a => Prism' a ()
Prism' [a] ()
_Empty (Market () () () (Identity ()) -> Market () () [a] (Identity [a]))
-> p () () -> p [a] [a]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]

-- | A return type, which may be a type predicate.
returnType :: TsGrammatical p => p TsType TsType
returnType :: forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
returnType = [p TsType TsType] -> p TsType TsType
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market
  (Text, Maybe TsType)
  (Text, Maybe TsType)
  (Text, Maybe TsType)
  (Identity (Text, Maybe TsType))
-> Market
     (Text, Maybe TsType) (Text, Maybe TsType) TsType (Identity TsType)
Prism' TsType (Text, Maybe TsType)
_AssertsPredicate (Market
   (Text, Maybe TsType)
   (Text, Maybe TsType)
   (Text, Maybe TsType)
   (Identity (Text, Maybe TsType))
 -> Market
      (Text, Maybe TsType) (Text, Maybe TsType) TsType (Identity TsType))
-> p (Text, Maybe TsType) (Text, Maybe TsType) -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text -> p Text Text
forall a. p Text a -> p Text a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
AssertsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
name)
      p Text Text
-> p (Maybe TsType) (Maybe TsType)
-> p (Text, Maybe TsType) (Text, Maybe TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
IsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode)
  , Market
  (Text, TsType)
  (Text, TsType)
  (Text, TsType)
  (Identity (Text, TsType))
-> Market (Text, TsType) (Text, TsType) TsType (Identity TsType)
Prism' TsType (Text, TsType)
_IsPredicate (Market
   (Text, TsType)
   (Text, TsType)
   (Text, TsType)
   (Identity (Text, TsType))
 -> Market (Text, TsType) (Text, TsType) TsType (Identity TsType))
-> p (Text, TsType) (Text, TsType) -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p Text Text -> p Text Text
forall a. p Text a -> p Text a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p Text Text
name p Text Text -> p () () -> p Text Text
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
IsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space)
      p Text Text -> p TsType TsType -> p (Text, TsType) (Text, TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode
  , p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode
  ]
  where
    name :: p Text Text
name = [p Text Text] -> p Text Text
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP [p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier, Text -> Prism' Text ()
forall a. Eq a => a -> Prism' a ()
only Text
"this" (Market () () () (Identity ())
 -> Market () () Text (Identity Text))
-> p () () -> p Text Text
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ThisKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP]

-- | An asserting type predicate.
_AssertsPredicate :: Prism' TsType (Text, Maybe TsType)
_AssertsPredicate :: Prism' TsType (Text, Maybe TsType)
_AssertsPredicate = ((Text, Maybe TsType) -> TsType)
-> (TsType -> Maybe (Text, Maybe TsType))
-> Prism' TsType (Text, Maybe TsType)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Text -> Maybe TsType -> TsType) -> (Text, Maybe TsType) -> TsType
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (Bool -> Text -> Maybe TsType -> TsType
TypePredicate Bool
True)) ((TsType -> Maybe (Text, Maybe TsType))
 -> Prism' TsType (Text, Maybe TsType))
-> (TsType -> Maybe (Text, Maybe TsType))
-> Prism' TsType (Text, Maybe TsType)
forall a b. (a -> b) -> a -> b
$ \case
  TypePredicate Bool
True Text
name Maybe TsType
t -> (Text, Maybe TsType) -> Maybe (Text, Maybe TsType)
forall a. a -> Maybe a
Just (Text
name, Maybe TsType
t)
  TsType
_ -> Maybe (Text, Maybe TsType)
forall a. Maybe a
Nothing

-- | A type predicate, which isn't asserting.
_IsPredicate :: Prism' TsType (Text, TsType)
_IsPredicate :: Prism' TsType (Text, TsType)
_IsPredicate = ((Text, TsType) -> TsType)
-> (TsType -> Maybe (Text, TsType)) -> Prism' TsType (Text, TsType)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\(Text
name, TsType
t) -> Bool -> Text -> Maybe TsType -> TsType
TypePredicate Bool
False Text
name (TsType -> Maybe TsType
forall a. a -> Maybe a
Just TsType
t))
  (\case
    TypePredicate Bool
False Text
name (Just TsType
t) -> (Text, TsType) -> Maybe (Text, TsType)
forall a. a -> Maybe a
Just (Text
name, TsType
t)
    TsType
_ -> Maybe (Text, TsType)
forall a. Maybe a
Nothing)

-- | A type.
typeNode :: TsGrammatical p => p TsType TsType
typeNode :: forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
typeNode = String -> (p TsType TsType -> p TsType TsType) -> p TsType TsType
forall bnf. BackusNaurForm bnf => String -> (bnf -> bnf) -> bnf
ruleRec String
"type" ((p TsType TsType -> p TsType TsType) -> p TsType TsType)
-> (p TsType TsType -> p TsType TsType) -> p TsType TsType
forall a b. (a -> b) -> a -> b
$ \p TsType TsType
ty -> [p TsType TsType] -> p TsType TsType
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  TsSignature
  (Identity TsSignature)
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     TsType
     (Identity TsType)
Prism' TsType TsSignature
_FunctionType (Market
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   TsSignature
   (Identity TsSignature)
 -> Market
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      TsType
      (Identity TsType))
-> (Market
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      (Identity ([TsTypeParameter], ([TsParameter], TsType)))
    -> Market
         ([TsTypeParameter], ([TsParameter], TsType))
         ([TsTypeParameter], ([TsParameter], TsType))
         TsSignature
         (Identity TsSignature))
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     (Identity ([TsTypeParameter], ([TsParameter], TsType)))
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     TsType
     (Identity TsType)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  (Identity ([TsTypeParameter], ([TsParameter], TsType)))
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     TsSignature
     (Identity TsSignature)
Prism' TsSignature ([TsTypeParameter], ([TsParameter], TsType))
_Arrow (Market
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   (Identity ([TsTypeParameter], ([TsParameter], TsType)))
 -> Market
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      TsType
      (Identity TsType))
-> p ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
-> p ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
forall a.
p ([TsTypeParameter], ([TsParameter], TsType)) a
-> p ([TsTypeParameter], ([TsParameter], TsType)) a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try p ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
functionSignature
  , Market
  (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
  (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
  (Bool, TsSignature)
  (Identity (Bool, TsSignature))
-> Market
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     TsType
     (Identity TsType)
Prism' TsType (Bool, TsSignature)
_ConstructorType (Market
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Bool, TsSignature)
   (Identity (Bool, TsSignature))
 -> Market
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      TsType
      (Identity TsType))
-> (Market
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Identity (Bool, ([TsTypeParameter], ([TsParameter], TsType))))
    -> Market
         (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
         (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
         (Bool, TsSignature)
         (Identity (Bool, TsSignature)))
-> Market
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Identity (Bool, ([TsTypeParameter], ([TsParameter], TsType))))
-> Market
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     TsType
     (Identity TsType)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Market
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   (Identity ([TsTypeParameter], ([TsParameter], TsType)))
 -> Market
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      TsSignature
      (Identity TsSignature))
-> Prism
     (Bool, TsSignature)
     (Bool, TsSignature)
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
forall s t a b e.
APrism s t a b -> Prism (e, s) (e, t) (e, a) (e, b)
aside Market
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  (Identity ([TsTypeParameter], ([TsParameter], TsType)))
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     TsSignature
     (Identity TsSignature)
Prism' TsSignature ([TsTypeParameter], ([TsParameter], TsType))
_Arrow (Market
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Identity (Bool, ([TsTypeParameter], ([TsParameter], TsType))))
 -> Market
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      TsType
      (Identity TsType))
-> p (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
  (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
constructorSignature
  , Exchange
  (TsType, Maybe (TsType, (TsType, TsType)))
  (TsType, Maybe (TsType, (TsType, TsType)))
  (TsType, Maybe (TsType, (TsType, TsType)))
  (Identity (TsType, Maybe (TsType, (TsType, TsType))))
-> Exchange
     (TsType, Maybe (TsType, (TsType, TsType)))
     (TsType, Maybe (TsType, (TsType, TsType)))
     TsType
     (Identity TsType)
Iso' TsType (TsType, Maybe (TsType, (TsType, TsType)))
_Conditional (Exchange
   (TsType, Maybe (TsType, (TsType, TsType)))
   (TsType, Maybe (TsType, (TsType, TsType)))
   (TsType, Maybe (TsType, (TsType, TsType)))
   (Identity (TsType, Maybe (TsType, (TsType, TsType))))
 -> Exchange
      (TsType, Maybe (TsType, (TsType, TsType)))
      (TsType, Maybe (TsType, (TsType, TsType)))
      TsType
      (Identity TsType))
-> p (TsType, Maybe (TsType, (TsType, TsType)))
     (TsType, Maybe (TsType, (TsType, TsType)))
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Profunctor p =>
AnIso s t a b -> p a b -> p s t
>~ p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
unionType p TsType TsType
ty p TsType TsType
-> p (Maybe (TsType, (TsType, TsType)))
     (Maybe (TsType, (TsType, TsType)))
-> p (TsType, Maybe (TsType, (TsType, TsType)))
     (TsType, Maybe (TsType, (TsType, TsType)))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p (TsType, (TsType, TsType)) (TsType, (TsType, TsType))
-> p (Maybe (TsType, (TsType, TsType)))
     (Maybe (TsType, (TsType, TsType)))
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP
      ( p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
ExtendsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p TsType TsType] -> p TsType TsType
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
          [ Market
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  TsSignature
  (Identity TsSignature)
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     TsType
     (Identity TsType)
Prism' TsType TsSignature
_FunctionType (Market
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   TsSignature
   (Identity TsSignature)
 -> Market
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      TsType
      (Identity TsType))
-> (Market
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      (Identity ([TsTypeParameter], ([TsParameter], TsType)))
    -> Market
         ([TsTypeParameter], ([TsParameter], TsType))
         ([TsTypeParameter], ([TsParameter], TsType))
         TsSignature
         (Identity TsSignature))
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     (Identity ([TsTypeParameter], ([TsParameter], TsType)))
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     TsType
     (Identity TsType)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Market
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  (Identity ([TsTypeParameter], ([TsParameter], TsType)))
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     TsSignature
     (Identity TsSignature)
Prism' TsSignature ([TsTypeParameter], ([TsParameter], TsType))
_Arrow (Market
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   (Identity ([TsTypeParameter], ([TsParameter], TsType)))
 -> Market
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      TsType
      (Identity TsType))
-> p ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
-> p ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
forall a.
p ([TsTypeParameter], ([TsParameter], TsType)) a
-> p ([TsTypeParameter], ([TsParameter], TsType)) a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try p ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
functionSignature
          , Market
  (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
  (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
  (Bool, TsSignature)
  (Identity (Bool, TsSignature))
-> Market
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     TsType
     (Identity TsType)
Prism' TsType (Bool, TsSignature)
_ConstructorType (Market
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Bool, TsSignature)
   (Identity (Bool, TsSignature))
 -> Market
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      TsType
      (Identity TsType))
-> (Market
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Identity (Bool, ([TsTypeParameter], ([TsParameter], TsType))))
    -> Market
         (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
         (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
         (Bool, TsSignature)
         (Identity (Bool, TsSignature)))
-> Market
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Identity (Bool, ([TsTypeParameter], ([TsParameter], TsType))))
-> Market
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     TsType
     (Identity TsType)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Market
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   ([TsTypeParameter], ([TsParameter], TsType))
   (Identity ([TsTypeParameter], ([TsParameter], TsType)))
 -> Market
      ([TsTypeParameter], ([TsParameter], TsType))
      ([TsTypeParameter], ([TsParameter], TsType))
      TsSignature
      (Identity TsSignature))
-> Prism
     (Bool, TsSignature)
     (Bool, TsSignature)
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
forall s t a b e.
APrism s t a b -> Prism (e, s) (e, t) (e, a) (e, b)
aside Market
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
  (Identity ([TsTypeParameter], ([TsParameter], TsType)))
-> Market
     ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
     TsSignature
     (Identity TsSignature)
Prism' TsSignature ([TsTypeParameter], ([TsParameter], TsType))
_Arrow (Market
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
   (Identity (Bool, ([TsTypeParameter], ([TsParameter], TsType))))
 -> Market
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
      TsType
      (Identity TsType))
-> p (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
  (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
constructorSignature
          , p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
unionType p TsType TsType
ty
          ]
        p TsType TsType
-> p (TsType, TsType) (TsType, TsType)
-> p (TsType, (TsType, TsType)) (TsType, (TsType, TsType))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
QuestionToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
ty
        p TsType TsType
-> p TsType TsType -> p (TsType, TsType) (TsType, TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
ty
      )
  ]
  where
    functionSignature :: p ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
functionSignature = p [TsTypeParameter] [TsTypeParameter]
forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsTypeParameter] [TsTypeParameter]
typeParameters p [TsTypeParameter] [TsTypeParameter]
-> p ([TsParameter], TsType) ([TsParameter], TsType)
-> p ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsParameter] [TsParameter]
forall (p :: * -> * -> *).
TsGrammatical p =>
p [TsParameter] [TsParameter]
parameters
      p [TsParameter] [TsParameter]
-> p TsType TsType
-> p ([TsParameter], TsType) ([TsParameter], TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
EqualsGreaterThanToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
forall (p :: * -> * -> *). TsGrammatical p => p TsType TsType
returnType
    constructorSignature :: p (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
  (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
constructorSignature = [p Bool Bool] -> p Bool Bool
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
True (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
AbstractKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      , Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
False (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      ]
      p Bool Bool
-> p ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
-> p (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
     (Bool, ([TsTypeParameter], ([TsParameter], TsType)))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
NewKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
-> p ([TsTypeParameter], ([TsParameter], TsType))
     ([TsTypeParameter], ([TsParameter], TsType))
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p ([TsTypeParameter], ([TsParameter], TsType))
  ([TsTypeParameter], ([TsParameter], TsType))
functionSignature

-- | A signature, with a return type.
_Arrow :: Prism' TsSignature ([TsTypeParameter], ([TsParameter], TsType))
_Arrow :: Prism' TsSignature ([TsTypeParameter], ([TsParameter], TsType))
_Arrow = (([TsTypeParameter], ([TsParameter], TsType)) -> TsSignature)
-> (TsSignature
    -> Maybe ([TsTypeParameter], ([TsParameter], TsType)))
-> Prism' TsSignature ([TsTypeParameter], ([TsParameter], TsType))
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\([TsTypeParameter]
tps, ([TsParameter]
ps, TsType
r)) -> [TsTypeParameter] -> [TsParameter] -> Maybe TsType -> TsSignature
TsSignature [TsTypeParameter]
tps [TsParameter]
ps (TsType -> Maybe TsType
forall a. a -> Maybe a
Just TsType
r))
  (\case
    TsSignature [TsTypeParameter]
tps [TsParameter]
ps (Just TsType
r) -> ([TsTypeParameter], ([TsParameter], TsType))
-> Maybe ([TsTypeParameter], ([TsParameter], TsType))
forall a. a -> Maybe a
Just ([TsTypeParameter]
tps, ([TsParameter]
ps, TsType
r))
    TsSignature
_ -> Maybe ([TsTypeParameter], ([TsParameter], TsType))
forall a. Maybe a
Nothing)

unionType :: TsGrammatical p => p TsType TsType -> p TsType TsType
unionType :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
unionType p TsType TsType
ty = String -> p TsType TsType -> p TsType TsType
forall bnf. BackusNaurForm bnf => String -> bnf -> bnf
rule String
"union" (p TsType TsType -> p TsType TsType)
-> p TsType TsType -> p TsType TsType
forall a b. (a -> b) -> a -> b
$ Prism' TsType [TsType] -> Iso' TsType (TsType, [TsType])
_Several p [TsType] (f [TsType]) -> p TsType (f TsType)
Prism' TsType [TsType]
_UnionType
  (Exchange
   (TsType, [TsType])
   (TsType, [TsType])
   (TsType, [TsType])
   (Identity (TsType, [TsType]))
 -> Exchange
      (TsType, [TsType]) (TsType, [TsType]) TsType (Identity TsType))
-> p (TsType, [TsType]) (TsType, [TsType]) -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Profunctor p =>
AnIso s t a b -> p a b -> p s t
>~ TsTokenCategory -> p () ()
forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p () ()
leading TsTokenCategory
BarToken p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
intersectionType p TsType TsType
ty p TsType TsType
-> p [TsType] [TsType] -> p (TsType, [TsType]) (TsType, [TsType])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p [TsType] [TsType]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP
    (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
BarToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
intersectionType p TsType TsType
ty)

intersectionType :: TsGrammatical p => p TsType TsType -> p TsType TsType
intersectionType :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
intersectionType p TsType TsType
ty = String -> p TsType TsType -> p TsType TsType
forall bnf. BackusNaurForm bnf => String -> bnf -> bnf
rule String
"intersection" (p TsType TsType -> p TsType TsType)
-> p TsType TsType -> p TsType TsType
forall a b. (a -> b) -> a -> b
$ Prism' TsType [TsType] -> Iso' TsType (TsType, [TsType])
_Several p [TsType] (f [TsType]) -> p TsType (f TsType)
Prism' TsType [TsType]
_IntersectionType
  (Exchange
   (TsType, [TsType])
   (TsType, [TsType])
   (TsType, [TsType])
   (Identity (TsType, [TsType]))
 -> Exchange
      (TsType, [TsType]) (TsType, [TsType]) TsType (Identity TsType))
-> p (TsType, [TsType]) (TsType, [TsType]) -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Profunctor p =>
AnIso s t a b -> p a b -> p s t
>~ TsTokenCategory -> p () ()
forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p () ()
leading TsTokenCategory
AmpersandToken p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
operatorType p TsType TsType
ty p TsType TsType
-> p [TsType] [TsType] -> p (TsType, [TsType]) (TsType, [TsType])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p [TsType] [TsType]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP
    (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
AmpersandToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
operatorType p TsType TsType
ty)

-- | A leading operator, which is parsed but not printed.
leading :: TsGrammatical p => TsTokenCategory -> p () ()
leading :: forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p () ()
leading TsTokenCategory
category = (() -> Maybe ())
-> (Maybe () -> ()) -> p (Maybe ()) (Maybe ()) -> p () ()
forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (Maybe () -> () -> Maybe ()
forall a b. a -> b -> a
const Maybe ()
forall a. Maybe a
Nothing) (() -> Maybe () -> ()
forall a b. a -> b -> a
const ())
  (p () () -> p (Maybe ()) (Maybe ())
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space))

operatorType :: TsGrammatical p => p TsType TsType -> p TsType TsType
operatorType :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
operatorType p TsType TsType
ty = String -> (p TsType TsType -> p TsType TsType) -> p TsType TsType
forall bnf. BackusNaurForm bnf => String -> (bnf -> bnf) -> bnf
ruleRec String
"operator" ((p TsType TsType -> p TsType TsType) -> p TsType TsType)
-> (p TsType TsType -> p TsType TsType) -> p TsType TsType
forall a b. (a -> b) -> a -> b
$ \p TsType TsType
self -> [p TsType TsType] -> p TsType TsType
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market
  (TsTokenCategory, TsType)
  (TsTokenCategory, TsType)
  (TsTokenCategory, TsType)
  (Identity (TsTokenCategory, TsType))
-> Market
     (TsTokenCategory, TsType)
     (TsTokenCategory, TsType)
     TsType
     (Identity TsType)
Prism' TsType (TsTokenCategory, TsType)
_TypeOperator (Market
   (TsTokenCategory, TsType)
   (TsTokenCategory, TsType)
   (TsTokenCategory, TsType)
   (Identity (TsTokenCategory, TsType))
 -> Market
      (TsTokenCategory, TsType)
      (TsTokenCategory, TsType)
      TsType
      (Identity TsType))
-> p (TsTokenCategory, TsType) (TsTokenCategory, TsType)
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
category (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      | TsTokenCategory
category <- [TsTokenCategory
KeyOfKeyword, TsTokenCategory
UniqueKeyword, TsTokenCategory
ReadonlyKeyword]
      ]
      p TsTokenCategory TsTokenCategory
-> p TsType TsType
-> p (TsTokenCategory, TsType) (TsTokenCategory, TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType
self
  , Market
  (Text, Maybe TsType)
  (Text, Maybe TsType)
  (Text, Maybe TsType)
  (Identity (Text, Maybe TsType))
-> Market
     (Text, Maybe TsType) (Text, Maybe TsType) TsType (Identity TsType)
Prism' TsType (Text, Maybe TsType)
_InferType (Market
   (Text, Maybe TsType)
   (Text, Maybe TsType)
   (Text, Maybe TsType)
   (Identity (Text, Maybe TsType))
 -> Market
      (Text, Maybe TsType) (Text, Maybe TsType) TsType (Identity TsType))
-> p (Text, Maybe TsType) (Text, Maybe TsType) -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
InferKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier
      p Text Text
-> p (Maybe TsType) (Maybe TsType)
-> p (Text, Maybe TsType) (Text, Maybe TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP
        (p TsType TsType -> p TsType TsType
forall a. p TsType a -> p TsType a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
ExtendsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
unionType p TsType TsType
ty))
  , p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
postfixType p TsType TsType
ty
  ]

postfixType :: TsGrammatical p => p TsType TsType -> p TsType TsType
postfixType :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
postfixType p TsType TsType
ty = String -> p TsType TsType -> p TsType TsType
forall bnf. BackusNaurForm bnf => String -> bnf -> bnf
rule String
"postfix" (p TsType TsType -> p TsType TsType)
-> p TsType TsType -> p TsType TsType
forall a b. (a -> b) -> a -> b
$ Exchange
  (TsType, [Maybe TsType])
  (TsType, [Maybe TsType])
  (TsType, [Maybe TsType])
  (Identity (TsType, [Maybe TsType]))
-> Exchange
     (TsType, [Maybe TsType])
     (TsType, [Maybe TsType])
     TsType
     (Identity TsType)
Iso' TsType (TsType, [Maybe TsType])
_Postfix
  (Exchange
   (TsType, [Maybe TsType])
   (TsType, [Maybe TsType])
   (TsType, [Maybe TsType])
   (Identity (TsType, [Maybe TsType]))
 -> Exchange
      (TsType, [Maybe TsType])
      (TsType, [Maybe TsType])
      TsType
      (Identity TsType))
-> p (TsType, [Maybe TsType]) (TsType, [Maybe TsType])
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Profunctor p =>
AnIso s t a b -> p a b -> p s t
>~ p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
primaryType p TsType TsType
ty p TsType TsType
-> p [Maybe TsType] [Maybe TsType]
-> p (TsType, [Maybe TsType]) (TsType, [Maybe TsType])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p (Maybe TsType) (Maybe TsType) -> p [Maybe TsType] [Maybe TsType]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP
    ( p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () ()
-> p (Maybe TsType) (Maybe TsType)
-> p (Maybe TsType) (Maybe TsType)
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p (Maybe TsType) (Maybe TsType)]
-> p (Maybe TsType) (Maybe TsType)
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
        [ Maybe TsType -> Prism' (Maybe TsType) ()
forall a. Eq a => a -> Prism' a ()
only Maybe TsType
forall a. Maybe a
Nothing (Market () () () (Identity ())
 -> Market () () (Maybe TsType) (Identity (Maybe TsType)))
-> p () () -> p (Maybe TsType) (Maybe TsType)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
        , Market TsType TsType TsType (Identity TsType)
-> Market TsType TsType (Maybe TsType) (Identity (Maybe TsType))
forall a b (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f b) -> p (Maybe a) (f (Maybe b))
_Just (Market TsType TsType TsType (Identity TsType)
 -> Market TsType TsType (Maybe TsType) (Identity (Maybe TsType)))
-> p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsType TsType
ty p TsType TsType -> p () () -> p TsType TsType
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
        ]
    )

-- | A type of any arrays & indexed accesses of a type.
_Postfix :: Iso' TsType (TsType, [Maybe TsType])
_Postfix :: Iso' TsType (TsType, [Maybe TsType])
_Postfix = (TsType -> (TsType, [Maybe TsType]))
-> ((TsType, [Maybe TsType]) -> TsType)
-> Iso' TsType (TsType, [Maybe TsType])
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso TsType -> (TsType, [Maybe TsType])
postfixes ((TsType -> [Maybe TsType] -> TsType)
-> (TsType, [Maybe TsType]) -> TsType
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ((TsType -> Maybe TsType -> TsType)
-> TsType -> [Maybe TsType] -> TsType
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl TsType -> Maybe TsType -> TsType
postfix))
  where
    postfixes :: TsType -> (TsType, [Maybe TsType])
postfixes = \case
      ArrayType TsType
node -> ([Maybe TsType] -> [Maybe TsType] -> [Maybe TsType]
forall a. Semigroup a => a -> a -> a
<> [Maybe TsType
forall a. Maybe a
Nothing]) ([Maybe TsType] -> [Maybe TsType])
-> (TsType, [Maybe TsType]) -> (TsType, [Maybe TsType])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TsType -> (TsType, [Maybe TsType])
postfixes TsType
node
      IndexedAccessType TsType
node TsType
key -> ([Maybe TsType] -> [Maybe TsType] -> [Maybe TsType]
forall a. Semigroup a => a -> a -> a
<> [TsType -> Maybe TsType
forall a. a -> Maybe a
Just TsType
key]) ([Maybe TsType] -> [Maybe TsType])
-> (TsType, [Maybe TsType]) -> (TsType, [Maybe TsType])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TsType -> (TsType, [Maybe TsType])
postfixes TsType
node
      TsType
node -> (TsType
node, [])
    postfix :: TsType -> Maybe TsType -> TsType
postfix TsType
node = \case
      Maybe TsType
Nothing -> TsType -> TsType
ArrayType TsType
node
      Just TsType
key -> TsType -> TsType -> TsType
IndexedAccessType TsType
node TsType
key

primaryType :: TsGrammatical p => p TsType TsType -> p TsType TsType
primaryType :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsType TsType -> p TsType TsType
primaryType p TsType TsType
ty = String -> p TsType TsType -> p TsType TsType
forall bnf. BackusNaurForm bnf => String -> bnf -> bnf
rule String
"primary" (p TsType TsType -> p TsType TsType)
-> p TsType TsType -> p TsType TsType
forall a b. (a -> b) -> a -> b
$ [p TsType TsType] -> p TsType TsType
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Market
  TsTokenCategory
  TsTokenCategory
  TsTokenCategory
  (Identity TsTokenCategory)
-> Market TsTokenCategory TsTokenCategory TsType (Identity TsType)
Prism' TsType TsTokenCategory
_KeywordType (Market
   TsTokenCategory
   TsTokenCategory
   TsTokenCategory
   (Identity TsTokenCategory)
 -> Market TsTokenCategory TsTokenCategory TsType (Identity TsType))
-> p TsTokenCategory TsTokenCategory -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? [p TsTokenCategory TsTokenCategory]
-> p TsTokenCategory TsTokenCategory
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ TsTokenCategory -> Prism' TsTokenCategory ()
forall a. Eq a => a -> Prism' a ()
only TsTokenCategory
category (Market () () () (Identity ())
 -> Market () () TsTokenCategory (Identity TsTokenCategory))
-> p () () -> p TsTokenCategory TsTokenCategory
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      | TsTokenCategory
category <-
        [ TsTokenCategory
AnyKeyword, TsTokenCategory
BigIntKeyword, TsTokenCategory
BooleanKeyword, TsTokenCategory
IntrinsicKeyword
        , TsTokenCategory
NeverKeyword, TsTokenCategory
NumberKeyword, TsTokenCategory
ObjectKeyword, TsTokenCategory
StringKeyword
        , TsTokenCategory
SymbolKeyword, TsTokenCategory
UndefinedKeyword, TsTokenCategory
UnknownKeyword, TsTokenCategory
VoidKeyword
        ]
      ]
  , TsType -> Prism' TsType ()
forall a. Eq a => a -> Prism' a ()
only TsType
ThisType (Market () () () (Identity ())
 -> Market () () TsType (Identity TsType))
-> p () () -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ThisKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , Market TsLiteral TsLiteral TsLiteral (Identity TsLiteral)
-> Market TsLiteral TsLiteral TsType (Identity TsType)
Prism' TsType TsLiteral
_LiteralType (Market TsLiteral TsLiteral TsLiteral (Identity TsLiteral)
 -> Market TsLiteral TsLiteral TsType (Identity TsType))
-> p TsLiteral TsLiteral -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsLiteral TsLiteral
forall (p :: * -> * -> *). TsGrammatical p => p TsLiteral TsLiteral
literal
  , Market Text Text Text (Identity Text)
-> Market Text Text TsType (Identity TsType)
Prism' TsType Text
_NoSubstitution (Market Text Text Text (Identity Text)
 -> Market Text Text TsType (Identity TsType))
-> p Text Text -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
NoSubstitutionTemplateLiteral
  , Market
  (Text, [(TsType, Text)])
  (Text, [(TsType, Text)])
  (Text, [(TsType, Text)])
  (Identity (Text, [(TsType, Text)]))
-> Market
     (Text, [(TsType, Text)])
     (Text, [(TsType, Text)])
     TsType
     (Identity TsType)
Prism' TsType (Text, [(TsType, Text)])
_TemplateLiteralType (Market
   (Text, [(TsType, Text)])
   (Text, [(TsType, Text)])
   (Text, [(TsType, Text)])
   (Identity (Text, [(TsType, Text)]))
 -> Market
      (Text, [(TsType, Text)])
      (Text, [(TsType, Text)])
      TsType
      (Identity TsType))
-> p (Text, [(TsType, Text)]) (Text, [(TsType, Text)])
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
TemplateHead p Text Text
-> p [(TsType, Text)] [(TsType, Text)]
-> p (Text, [(TsType, Text)]) (Text, [(TsType, Text)])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [(TsType, Text)] [(TsType, Text)]
templateSpans
  , Market
  (Text, (TsEntityName, [TsType]))
  (Text, (TsEntityName, [TsType]))
  (Text, (TsEntityName, [TsType]))
  (Identity (Text, (TsEntityName, [TsType])))
-> Market
     (Text, (TsEntityName, [TsType]))
     (Text, (TsEntityName, [TsType]))
     TsType
     (Identity TsType)
Prism' TsType (Text, (TsEntityName, [TsType]))
_TypeOfImport (Market
   (Text, (TsEntityName, [TsType]))
   (Text, (TsEntityName, [TsType]))
   (Text, (TsEntityName, [TsType]))
   (Identity (Text, (TsEntityName, [TsType])))
 -> Market
      (Text, (TsEntityName, [TsType]))
      (Text, (TsEntityName, [TsType]))
      TsType
      (Identity TsType))
-> p (Text, (TsEntityName, [TsType]))
     (Text, (TsEntityName, [TsType]))
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (Text, (TsEntityName, [TsType])) (Text, (TsEntityName, [TsType]))
-> p (Text, (TsEntityName, [TsType]))
     (Text, (TsEntityName, [TsType]))
forall a.
p (Text, (TsEntityName, [TsType])) a
-> p (Text, (TsEntityName, [TsType])) a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
      (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
TypeOfKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p (Text, (TsEntityName, [TsType]))
     (Text, (TsEntityName, [TsType]))
-> p (Text, (TsEntityName, [TsType]))
     (Text, (TsEntityName, [TsType]))
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p (Text, (TsEntityName, [TsType])) (Text, (TsEntityName, [TsType]))
importType)
  , Market
  (Text, (TsEntityName, [TsType]))
  (Text, (TsEntityName, [TsType]))
  (Text, (TsEntityName, [TsType]))
  (Identity (Text, (TsEntityName, [TsType])))
-> Market
     (Text, (TsEntityName, [TsType]))
     (Text, (TsEntityName, [TsType]))
     TsType
     (Identity TsType)
Prism' TsType (Text, (TsEntityName, [TsType]))
_TypeImport (Market
   (Text, (TsEntityName, [TsType]))
   (Text, (TsEntityName, [TsType]))
   (Text, (TsEntityName, [TsType]))
   (Identity (Text, (TsEntityName, [TsType])))
 -> Market
      (Text, (TsEntityName, [TsType]))
      (Text, (TsEntityName, [TsType]))
      TsType
      (Identity TsType))
-> p (Text, (TsEntityName, [TsType]))
     (Text, (TsEntityName, [TsType]))
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (Text, (TsEntityName, [TsType])) (Text, (TsEntityName, [TsType]))
importType
  , Market
  (TsEntityName, [TsType])
  (TsEntityName, [TsType])
  (TsEntityName, [TsType])
  (Identity (TsEntityName, [TsType]))
-> Market
     (TsEntityName, [TsType])
     (TsEntityName, [TsType])
     TsType
     (Identity TsType)
Prism' TsType (TsEntityName, [TsType])
_TypeQuery (Market
   (TsEntityName, [TsType])
   (TsEntityName, [TsType])
   (TsEntityName, [TsType])
   (Identity (TsEntityName, [TsType]))
 -> Market
      (TsEntityName, [TsType])
      (TsEntityName, [TsType])
      TsType
      (Identity TsType))
-> p (TsEntityName, [TsType]) (TsEntityName, [TsType])
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
TypeOfKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p TsEntityName TsEntityName -> p TsEntityName TsEntityName
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsEntityName TsEntityName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsEntityName TsEntityName
entityName
      p TsEntityName TsEntityName
-> p [TsType] [TsType]
-> p (TsEntityName, [TsType]) (TsEntityName, [TsType])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsType] [TsType]
forall (p :: * -> * -> *). TsGrammatical p => p [TsType] [TsType]
typeArguments
  , Market
  (TsEntityName, [TsType])
  (TsEntityName, [TsType])
  (TsEntityName, [TsType])
  (Identity (TsEntityName, [TsType]))
-> Market
     (TsEntityName, [TsType])
     (TsEntityName, [TsType])
     TsType
     (Identity TsType)
Prism' TsType (TsEntityName, [TsType])
_ReferenceType (Market
   (TsEntityName, [TsType])
   (TsEntityName, [TsType])
   (TsEntityName, [TsType])
   (Identity (TsEntityName, [TsType]))
 -> Market
      (TsEntityName, [TsType])
      (TsEntityName, [TsType])
      TsType
      (Identity TsType))
-> p (TsEntityName, [TsType]) (TsEntityName, [TsType])
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsEntityName TsEntityName
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsEntityName TsEntityName
entityName p TsEntityName TsEntityName
-> p [TsType] [TsType]
-> p (TsEntityName, [TsType]) (TsEntityName, [TsType])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsType] [TsType]
forall (p :: * -> * -> *). TsGrammatical p => p [TsType] [TsType]
typeArguments
  , Market [TsType] [TsType] [TsType] (Identity [TsType])
-> Market [TsType] [TsType] TsType (Identity TsType)
Prism' TsType [TsType]
_TupleType (Market [TsType] [TsType] [TsType] (Identity [TsType])
 -> Market [TsType] [TsType] TsType (Identity TsType))
-> p [TsType] [TsType] -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p [TsType] [TsType] -> p [TsType] [TsType]
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p [TsType] [TsType]] -> p [TsType] [TsType]
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Market () () () (Identity ())
-> Market () () [TsType] (Identity [TsType])
forall a. AsEmpty a => Prism' a ()
Prism' [TsType] ()
_Empty (Market () () () (Identity ())
 -> Market () () [TsType] (Identity [TsType]))
-> p () () -> p [TsType] [TsType]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      , p TsType TsType -> p [TsType] [TsType]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
commas1 p TsType TsType
tupleElement
          p [TsType] [TsType] -> p () () -> p [TsType] [TsType]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      ]
  , Market TsType TsType TsType (Identity TsType)
-> Market TsType TsType TsType (Identity TsType)
Prism' TsType TsType
_ParenthesizedType (Market TsType TsType TsType (Identity TsType)
 -> Market TsType TsType TsType (Identity TsType))
-> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
ty p TsType TsType -> p () () -> p TsType TsType
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , Market TsType TsType TsType (Identity TsType)
-> Market TsType TsType TsType (Identity TsType)
Prism' TsType TsType
_Braced (Market TsType TsType TsType (Identity TsType)
 -> Market TsType TsType TsType (Identity TsType))
-> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p TsType TsType] -> p TsType TsType
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ TsType -> Prism' TsType ()
forall a. Eq a => a -> Prism' a ()
only ([TsProperty] -> TsType
ObjectType []) (Market () () () (Identity ())
 -> Market () () TsType (Identity TsType))
-> p () () -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      , Market
  (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
  (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
  (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
  (Identity
     (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType))))))
-> Market
     (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
     (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
     TsType
     (Identity TsType)
Prism'
  TsType
  (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
_MappedType (Market
   (Maybe TsTokenCategory,
    (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
   (Maybe TsTokenCategory,
    (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
   (Maybe TsTokenCategory,
    (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
   (Identity
      (Maybe TsTokenCategory,
       (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType))))))
 -> Market
      (Maybe TsTokenCategory,
       (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
      (Maybe TsTokenCategory,
       (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
      TsType
      (Identity TsType))
-> p (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
     (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
  (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
-> p (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
     (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
forall a.
p (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
  a
-> p (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
     a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try p (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
  (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
mappedType
      , Market
  [TsProperty] [TsProperty] [TsProperty] (Identity [TsProperty])
-> Market [TsProperty] [TsProperty] TsType (Identity TsType)
Prism' TsType [TsProperty]
_ObjectType (Market
   [TsProperty] [TsProperty] [TsProperty] (Identity [TsProperty])
 -> Market [TsProperty] [TsProperty] TsType (Identity TsType))
-> p [TsProperty] [TsProperty] -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p [TsProperty] [TsProperty] -> p [TsProperty] [TsProperty]
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* (Market
  (TsProperty, [TsProperty])
  (TsProperty, [TsProperty])
  (TsProperty, [TsProperty])
  (Identity (TsProperty, [TsProperty]))
-> Market
     (TsProperty, [TsProperty])
     (TsProperty, [TsProperty])
     [TsProperty]
     (Identity [TsProperty])
forall s t a b. Cons s t a b => Prism s t (a, s) (b, t)
Prism
  [TsProperty]
  [TsProperty]
  (TsProperty, [TsProperty])
  (TsProperty, [TsProperty])
_Cons (Market
   (TsProperty, [TsProperty])
   (TsProperty, [TsProperty])
   (TsProperty, [TsProperty])
   (Identity (TsProperty, [TsProperty]))
 -> Market
      (TsProperty, [TsProperty])
      (TsProperty, [TsProperty])
      [TsProperty]
      (Identity [TsProperty]))
-> p (TsProperty, [TsProperty]) (TsProperty, [TsProperty])
-> p [TsProperty] [TsProperty]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsProperty TsProperty
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsProperty TsProperty
member p TsProperty TsProperty
-> p [TsProperty] [TsProperty]
-> p (TsProperty, [TsProperty]) (TsProperty, [TsProperty])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsProperty] [TsProperty]
moreMembers)
      ]
  ]
  where
    importType :: p (Text, (TsEntityName, [TsType])) (Text, (TsEntityName, [TsType]))
importType = p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ImportKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
StringLiteral
      p Text Text -> p () () -> p Text Text
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseParenToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      p Text Text
-> p (TsEntityName, [TsType]) (TsEntityName, [TsType])
-> p (Text, (TsEntityName, [TsType]))
     (Text, (TsEntityName, [TsType]))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Text Text -> p TsEntityName TsEntityName
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
DotToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifierName)
      p TsEntityName TsEntityName
-> p [TsType] [TsType]
-> p (TsEntityName, [TsType]) (TsEntityName, [TsType])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsType] [TsType]
forall (p :: * -> * -> *). TsGrammatical p => p [TsType] [TsType]
typeArguments
    templateSpans :: p [(TsType, Text)] [(TsType, Text)]
templateSpans = String
-> (p [(TsType, Text)] [(TsType, Text)]
    -> p [(TsType, Text)] [(TsType, Text)])
-> p [(TsType, Text)] [(TsType, Text)]
forall bnf. BackusNaurForm bnf => String -> (bnf -> bnf) -> bnf
ruleRec String
"spans" ((p [(TsType, Text)] [(TsType, Text)]
  -> p [(TsType, Text)] [(TsType, Text)])
 -> p [(TsType, Text)] [(TsType, Text)])
-> (p [(TsType, Text)] [(TsType, Text)]
    -> p [(TsType, Text)] [(TsType, Text)])
-> p [(TsType, Text)] [(TsType, Text)]
forall a b. (a -> b) -> a -> b
$ \p [(TsType, Text)] [(TsType, Text)]
rest -> Market
  (TsType, Either (Text, [(TsType, Text)]) Text)
  (TsType, Either (Text, [(TsType, Text)]) Text)
  (TsType, Either (Text, [(TsType, Text)]) Text)
  (Identity (TsType, Either (Text, [(TsType, Text)]) Text))
-> Market
     (TsType, Either (Text, [(TsType, Text)]) Text)
     (TsType, Either (Text, [(TsType, Text)]) Text)
     [(TsType, Text)]
     (Identity [(TsType, Text)])
Prism'
  [(TsType, Text)] (TsType, Either (Text, [(TsType, Text)]) Text)
_Spans (Market
   (TsType, Either (Text, [(TsType, Text)]) Text)
   (TsType, Either (Text, [(TsType, Text)]) Text)
   (TsType, Either (Text, [(TsType, Text)]) Text)
   (Identity (TsType, Either (Text, [(TsType, Text)]) Text))
 -> Market
      (TsType, Either (Text, [(TsType, Text)]) Text)
      (TsType, Either (Text, [(TsType, Text)]) Text)
      [(TsType, Text)]
      (Identity [(TsType, Text)]))
-> p (TsType, Either (Text, [(TsType, Text)]) Text)
     (TsType, Either (Text, [(TsType, Text)]) Text)
-> p [(TsType, Text)] [(TsType, Text)]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p TsType TsType
ty
      p TsType TsType
-> p (Either (Text, [(TsType, Text)]) Text)
     (Either (Text, [(TsType, Text)]) Text)
-> p (TsType, Either (Text, [(TsType, Text)]) Text)
     (TsType, Either (Text, [(TsType, Text)]) Text)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< (TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
TemplateMiddle p Text Text
-> p [(TsType, Text)] [(TsType, Text)]
-> p (Text, [(TsType, Text)]) (Text, [(TsType, Text)])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [(TsType, Text)] [(TsType, Text)]
rest p (Text, [(TsType, Text)]) (Text, [(TsType, Text)])
-> p Text Text
-> p (Either (Text, [(TsType, Text)]) Text)
     (Either (Text, [(TsType, Text)]) Text)
forall a b c d. p a b -> p c d -> p (Either a c) (Either b d)
forall (p :: * -> * -> *) a b c d.
CocartesianMonoidal p =>
p a b -> p c d -> p (Either a c) (Either b d)
>+< TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
TemplateTail)
    tupleElement :: p TsType TsType
tupleElement = String -> p TsType TsType -> p TsType TsType
forall bnf. BackusNaurForm bnf => String -> bnf -> bnf
rule String
"element" (p TsType TsType -> p TsType TsType)
-> p TsType TsType -> p TsType TsType
forall a b. (a -> b) -> a -> b
$ [p TsType TsType] -> p TsType TsType
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Market
  ((Bool, (Text, Bool)), TsType)
  ((Bool, (Text, Bool)), TsType)
  (Bool, (Text, (Bool, TsType)))
  (Identity (Bool, (Text, (Bool, TsType))))
-> Market
     ((Bool, (Text, Bool)), TsType)
     ((Bool, (Text, Bool)), TsType)
     TsType
     (Identity TsType)
Prism' TsType (Bool, (Text, (Bool, TsType)))
_NamedTupleMember (Market
   ((Bool, (Text, Bool)), TsType)
   ((Bool, (Text, Bool)), TsType)
   (Bool, (Text, (Bool, TsType)))
   (Identity (Bool, (Text, (Bool, TsType))))
 -> Market
      ((Bool, (Text, Bool)), TsType)
      ((Bool, (Text, Bool)), TsType)
      TsType
      (Identity TsType))
-> (Market
      ((Bool, (Text, Bool)), TsType)
      ((Bool, (Text, Bool)), TsType)
      ((Bool, (Text, Bool)), TsType)
      (Identity ((Bool, (Text, Bool)), TsType))
    -> Market
         ((Bool, (Text, Bool)), TsType)
         ((Bool, (Text, Bool)), TsType)
         (Bool, (Text, (Bool, TsType)))
         (Identity (Bool, (Text, (Bool, TsType)))))
-> Market
     ((Bool, (Text, Bool)), TsType)
     ((Bool, (Text, Bool)), TsType)
     ((Bool, (Text, Bool)), TsType)
     (Identity ((Bool, (Text, Bool)), TsType))
-> Market
     ((Bool, (Text, Bool)), TsType)
     ((Bool, (Text, Bool)), TsType)
     TsType
     (Identity TsType)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Bool, (Text, (Bool, TsType))) -> ((Bool, (Text, Bool)), TsType))
-> (((Bool, (Text, Bool)), TsType)
    -> (Bool, (Text, (Bool, TsType))))
-> Iso
     (Bool, (Text, (Bool, TsType)))
     (Bool, (Text, (Bool, TsType)))
     ((Bool, (Text, Bool)), TsType)
     ((Bool, (Text, Bool)), TsType)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(Bool
r, (Text
n, (Bool
o, TsType
t))) -> ((Bool
r, (Text
n, Bool
o)), TsType
t)) (\((Bool
r, (Text
n, Bool
o)), TsType
t) -> (Bool
r, (Text
n, (Bool
o, TsType
t)))) (Market
   ((Bool, (Text, Bool)), TsType)
   ((Bool, (Text, Bool)), TsType)
   ((Bool, (Text, Bool)), TsType)
   (Identity ((Bool, (Text, Bool)), TsType))
 -> Market
      ((Bool, (Text, Bool)), TsType)
      ((Bool, (Text, Bool)), TsType)
      TsType
      (Identity TsType))
-> p ((Bool, (Text, Bool)), TsType) ((Bool, (Text, Bool)), TsType)
-> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p (Bool, (Text, Bool)) (Bool, (Text, Bool))
-> p (Bool, (Text, Bool)) (Bool, (Text, Bool))
forall a. p (Bool, (Text, Bool)) a -> p (Bool, (Text, Bool)) a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try
          (p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
dots p Bool Bool
-> p (Text, Bool) (Text, Bool)
-> p (Bool, (Text, Bool)) (Bool, (Text, Bool))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier p Text Text -> p Bool Bool -> p (Text, Bool) (Text, Bool)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
question p Bool Bool -> p () () -> p Bool Bool
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space)
          p (Bool, (Text, Bool)) (Bool, (Text, Bool))
-> p TsType TsType
-> p ((Bool, (Text, Bool)), TsType) ((Bool, (Text, Bool)), TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType
ty
      , Market TsType TsType TsType (Identity TsType)
-> Market TsType TsType TsType (Identity TsType)
Prism' TsType TsType
_RestType (Market TsType TsType TsType (Identity TsType)
 -> Market TsType TsType TsType (Identity TsType))
-> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
DotDotDotToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
ty
      , Exchange
  (TsType, Bool)
  (TsType, Bool)
  (TsType, Bool)
  (Identity (TsType, Bool))
-> Exchange (TsType, Bool) (TsType, Bool) TsType (Identity TsType)
Iso' TsType (TsType, Bool)
_Optional (Exchange
   (TsType, Bool)
   (TsType, Bool)
   (TsType, Bool)
   (Identity (TsType, Bool))
 -> Exchange (TsType, Bool) (TsType, Bool) TsType (Identity TsType))
-> p (TsType, Bool) (TsType, Bool) -> p TsType TsType
forall (p :: * -> * -> *) s t a b.
Profunctor p =>
AnIso s t a b -> p a b -> p s t
>~ p TsType TsType
ty p TsType TsType -> p Bool Bool -> p (TsType, Bool) (TsType, Bool)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p Bool Bool
forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
question
      ]
    mappedType :: p (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
  (Maybe TsTokenCategory,
   (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
mappedType = p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () ()
-> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
-> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p (Maybe TsTokenCategory) (Maybe TsTokenCategory)]
-> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Maybe TsTokenCategory -> Prism' (Maybe TsTokenCategory) ()
forall a. Eq a => a -> Prism' a ()
only (TsTokenCategory -> Maybe TsTokenCategory
forall a. a -> Maybe a
Just TsTokenCategory
PlusToken) (Market () () () (Identity ())
 -> Market
      () () (Maybe TsTokenCategory) (Identity (Maybe TsTokenCategory)))
-> p () () -> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
PlusToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
          p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ReadonlyKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      , Maybe TsTokenCategory -> Prism' (Maybe TsTokenCategory) ()
forall a. Eq a => a -> Prism' a ()
only (TsTokenCategory -> Maybe TsTokenCategory
forall a. a -> Maybe a
Just TsTokenCategory
MinusToken) (Market () () () (Identity ())
 -> Market
      () () (Maybe TsTokenCategory) (Identity (Maybe TsTokenCategory)))
-> p () () -> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
MinusToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
          p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ReadonlyKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      , Maybe TsTokenCategory -> Prism' (Maybe TsTokenCategory) ()
forall a. Eq a => a -> Prism' a ()
only (TsTokenCategory -> Maybe TsTokenCategory
forall a. a -> Maybe a
Just TsTokenCategory
ReadonlyKeyword) (Market () () () (Identity ())
 -> Market
      () () (Maybe TsTokenCategory) (Identity (Maybe TsTokenCategory)))
-> p () () -> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ReadonlyKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space
      , Maybe TsTokenCategory -> Prism' (Maybe TsTokenCategory) ()
forall a. Eq a => a -> Prism' a ()
only Maybe TsTokenCategory
forall a. Maybe a
Nothing (Market () () () (Identity ())
 -> Market
      () () (Maybe TsTokenCategory) (Identity (Maybe TsTokenCategory)))
-> p () () -> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      ]
      p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
-> p (Text,
      (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType))))
     (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType))))
-> p (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
     (Maybe TsTokenCategory,
      (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
OpenBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier
      p Text Text
-> p (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))
     (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))
-> p (Text,
      (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType))))
     (Text, (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType))))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
InKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
ty
      p TsType TsType
-> p (Maybe TsType, (Maybe TsTokenCategory, TsType))
     (Maybe TsType, (Maybe TsTokenCategory, TsType))
-> p (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))
     (TsType, (Maybe TsType, (Maybe TsTokenCategory, TsType)))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p TsType TsType -> p (Maybe TsType) (Maybe TsType)
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
AsKeyword p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
ty)
      p (Maybe TsType) (Maybe TsType)
-> p (Maybe TsTokenCategory, TsType)
     (Maybe TsTokenCategory, TsType)
-> p (Maybe TsType, (Maybe TsTokenCategory, TsType))
     (Maybe TsType, (Maybe TsTokenCategory, TsType))
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CloseBracketToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () ()
-> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
-> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p (Maybe TsTokenCategory) (Maybe TsTokenCategory)]
-> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
        [ Maybe TsTokenCategory -> Prism' (Maybe TsTokenCategory) ()
forall a. Eq a => a -> Prism' a ()
only (TsTokenCategory -> Maybe TsTokenCategory
forall a. a -> Maybe a
Just TsTokenCategory
PlusToken) (Market () () () (Identity ())
 -> Market
      () () (Maybe TsTokenCategory) (Identity (Maybe TsTokenCategory)))
-> p () () -> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
PlusToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
            p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
QuestionToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
        , Maybe TsTokenCategory -> Prism' (Maybe TsTokenCategory) ()
forall a. Eq a => a -> Prism' a ()
only (TsTokenCategory -> Maybe TsTokenCategory
forall a. a -> Maybe a
Just TsTokenCategory
MinusToken) (Market () () () (Identity ())
 -> Market
      () () (Maybe TsTokenCategory) (Identity (Maybe TsTokenCategory)))
-> p () () -> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
MinusToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
            p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
QuestionToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
        , Maybe TsTokenCategory -> Prism' (Maybe TsTokenCategory) ()
forall a. Eq a => a -> Prism' a ()
only (TsTokenCategory -> Maybe TsTokenCategory
forall a. a -> Maybe a
Just TsTokenCategory
QuestionToken) (Market () () () (Identity ())
 -> Market
      () () (Maybe TsTokenCategory) (Identity (Maybe TsTokenCategory)))
-> p () () -> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
QuestionToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
        , Maybe TsTokenCategory -> Prism' (Maybe TsTokenCategory) ()
forall a. Eq a => a -> Prism' a ()
only Maybe TsTokenCategory
forall a. Maybe a
Nothing (Market () () () (Identity ())
 -> Market
      () () (Maybe TsTokenCategory) (Identity (Maybe TsTokenCategory)))
-> p () () -> p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
        ]
      p (Maybe TsTokenCategory) (Maybe TsTokenCategory)
-> p TsType TsType
-> p (Maybe TsTokenCategory, TsType)
     (Maybe TsTokenCategory, TsType)
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
ColonToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsType TsType -> p TsType TsType
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsType TsType
ty
      p TsType TsType -> p () () -> p TsType TsType
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< TsTokenCategory -> p () ()
forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p () ()
optionalToken TsTokenCategory
SemicolonToken
      p TsType TsType -> p () () -> p TsType TsType
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
CloseBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
    -- The members after an object type's first, on its line, separated
    -- by @;@ or @,@, or by nothing, & its closing brace.
    moreMembers :: p [TsProperty] [TsProperty]
moreMembers = String
-> (p [TsProperty] [TsProperty] -> p [TsProperty] [TsProperty])
-> p [TsProperty] [TsProperty]
forall bnf. BackusNaurForm bnf => String -> (bnf -> bnf) -> bnf
ruleRec String
"members" ((p [TsProperty] [TsProperty] -> p [TsProperty] [TsProperty])
 -> p [TsProperty] [TsProperty])
-> (p [TsProperty] [TsProperty] -> p [TsProperty] [TsProperty])
-> p [TsProperty] [TsProperty]
forall a b. (a -> b) -> a -> b
$ \p [TsProperty] [TsProperty]
rest -> [p [TsProperty] [TsProperty]] -> p [TsProperty] [TsProperty]
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Market () () () (Identity ())
-> Market () () [TsProperty] (Identity [TsProperty])
forall a. AsEmpty a => Prism' a ()
Prism' [TsProperty] ()
_Empty (Market () () () (Identity ())
 -> Market () () [TsProperty] (Identity [TsProperty]))
-> p () () -> p [TsProperty] [TsProperty]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
CloseBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      , [p () ()] -> p () ()
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
          [ p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
SemicolonToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
          , p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CommaToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
          ]
        p () ()
-> p [TsProperty] [TsProperty] -> p [TsProperty] [TsProperty]
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [p [TsProperty] [TsProperty]] -> p [TsProperty] [TsProperty]
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
          [ Market () () () (Identity ())
-> Market () () [TsProperty] (Identity [TsProperty])
forall a. AsEmpty a => Prism' a ()
Prism' [TsProperty] ()
_Empty (Market () () () (Identity ())
 -> Market () () [TsProperty] (Identity [TsProperty]))
-> p () () -> p [TsProperty] [TsProperty]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space TsTokenCategory
CloseBraceToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
          , Market
  (TsProperty, [TsProperty])
  (TsProperty, [TsProperty])
  (TsProperty, [TsProperty])
  (Identity (TsProperty, [TsProperty]))
-> Market
     (TsProperty, [TsProperty])
     (TsProperty, [TsProperty])
     [TsProperty]
     (Identity [TsProperty])
forall s t a b. Cons s t a b => Prism s t (a, s) (b, t)
Prism
  [TsProperty]
  [TsProperty]
  (TsProperty, [TsProperty])
  (TsProperty, [TsProperty])
_Cons (Market
   (TsProperty, [TsProperty])
   (TsProperty, [TsProperty])
   (TsProperty, [TsProperty])
   (Identity (TsProperty, [TsProperty]))
 -> Market
      (TsProperty, [TsProperty])
      (TsProperty, [TsProperty])
      [TsProperty]
      (Identity [TsProperty]))
-> p (TsProperty, [TsProperty]) (TsProperty, [TsProperty])
-> p [TsProperty] [TsProperty]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsProperty TsProperty -> p TsProperty TsProperty
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsProperty TsProperty
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsProperty TsProperty
member p TsProperty TsProperty
-> p [TsProperty] [TsProperty]
-> p (TsProperty, [TsProperty]) (TsProperty, [TsProperty])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsProperty] [TsProperty]
rest
          ]
      , Market
  (TsProperty, [TsProperty])
  (TsProperty, [TsProperty])
  (TsProperty, [TsProperty])
  (Identity (TsProperty, [TsProperty]))
-> Market
     (TsProperty, [TsProperty])
     (TsProperty, [TsProperty])
     [TsProperty]
     (Identity [TsProperty])
forall s t a b. Cons s t a b => Prism s t (a, s) (b, t)
Prism
  [TsProperty]
  [TsProperty]
  (TsProperty, [TsProperty])
  (TsProperty, [TsProperty])
_Cons (Market
   (TsProperty, [TsProperty])
   (TsProperty, [TsProperty])
   (TsProperty, [TsProperty])
   (Identity (TsProperty, [TsProperty]))
 -> Market
      (TsProperty, [TsProperty])
      (TsProperty, [TsProperty])
      [TsProperty]
      (Identity [TsProperty]))
-> p (TsProperty, [TsProperty]) (TsProperty, [TsProperty])
-> p [TsProperty] [TsProperty]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space p () () -> p TsProperty TsProperty -> p TsProperty TsProperty
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p TsProperty TsProperty
forall (p :: * -> * -> *).
TsGrammatical p =>
p TsProperty TsProperty
member p TsProperty TsProperty
-> p [TsProperty] [TsProperty]
-> p (TsProperty, [TsProperty]) (TsProperty, [TsProperty])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p [TsProperty] [TsProperty]
rest
      ]

-- | An import type, without its @typeof@.
_TypeImport :: Prism' TsType (Text, (TsEntityName, [TsType]))
_TypeImport :: Prism' TsType (Text, (TsEntityName, [TsType]))
_TypeImport = ((Text, (TsEntityName, [TsType])) -> TsType)
-> (TsType -> Maybe (Text, (TsEntityName, [TsType])))
-> Prism' TsType (Text, (TsEntityName, [TsType]))
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\(Text
name, (TsEntityName
qualifier, [TsType]
args)) -> Bool -> Text -> TsEntityName -> [TsType] -> TsType
ImportType Bool
False Text
name TsEntityName
qualifier [TsType]
args)
  (\case
    ImportType Bool
False Text
name TsEntityName
qualifier [TsType]
args -> (Text, (TsEntityName, [TsType]))
-> Maybe (Text, (TsEntityName, [TsType]))
forall a. a -> Maybe a
Just (Text
name, (TsEntityName
qualifier, [TsType]
args))
    TsType
_ -> Maybe (Text, (TsEntityName, [TsType]))
forall a. Maybe a
Nothing)

-- | An import type, with its @typeof@.
_TypeOfImport :: Prism' TsType (Text, (TsEntityName, [TsType]))
_TypeOfImport :: Prism' TsType (Text, (TsEntityName, [TsType]))
_TypeOfImport = ((Text, (TsEntityName, [TsType])) -> TsType)
-> (TsType -> Maybe (Text, (TsEntityName, [TsType])))
-> Prism' TsType (Text, (TsEntityName, [TsType]))
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\(Text
name, (TsEntityName
qualifier, [TsType]
args)) -> Bool -> Text -> TsEntityName -> [TsType] -> TsType
ImportType Bool
True Text
name TsEntityName
qualifier [TsType]
args)
  (\case
    ImportType Bool
True Text
name TsEntityName
qualifier [TsType]
args -> (Text, (TsEntityName, [TsType]))
-> Maybe (Text, (TsEntityName, [TsType]))
forall a. a -> Maybe a
Just (Text
name, (TsEntityName
qualifier, [TsType]
args))
    TsType
_ -> Maybe (Text, (TsEntityName, [TsType]))
forall a. Maybe a
Nothing)

-- | A literal.
literal :: TsGrammatical p => p TsLiteral TsLiteral
literal :: forall (p :: * -> * -> *). TsGrammatical p => p TsLiteral TsLiteral
literal = [p TsLiteral TsLiteral] -> p TsLiteral TsLiteral
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ TsLiteral -> Prism' TsLiteral ()
forall a. Eq a => a -> Prism' a ()
only TsLiteral
NullLiteral (Market () () () (Identity ())
 -> Market () () TsLiteral (Identity TsLiteral))
-> p () () -> p TsLiteral TsLiteral
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
NullKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , TsLiteral -> Prism' TsLiteral ()
forall a. Eq a => a -> Prism' a ()
only TsLiteral
TrueLiteral (Market () () () (Identity ())
 -> Market () () TsLiteral (Identity TsLiteral))
-> p () () -> p TsLiteral TsLiteral
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
TrueKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , TsLiteral -> Prism' TsLiteral ()
forall a. Eq a => a -> Prism' a ()
only TsLiteral
FalseLiteral (Market () () () (Identity ())
 -> Market () () TsLiteral (Identity TsLiteral))
-> p () () -> p TsLiteral TsLiteral
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
FalseKeyword p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , Market Text Text Text (Identity Text)
-> Market Text Text TsLiteral (Identity TsLiteral)
Prism' TsLiteral Text
_TextLiteral (Market Text Text Text (Identity Text)
 -> Market Text Text TsLiteral (Identity TsLiteral))
-> p Text Text -> p TsLiteral TsLiteral
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
StringLiteral
  , Market Text Text Text (Identity Text)
-> Market Text Text TsLiteral (Identity TsLiteral)
Prism' TsLiteral Text
_NumberLiteral (Market Text Text Text (Identity Text)
 -> Market Text Text TsLiteral (Identity TsLiteral))
-> p Text Text -> p TsLiteral TsLiteral
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? TsTokenCategory -> p Text Text
forall {p :: * -> * -> *}.
(DisjunctiveMonoid (p Text Text), Alternator p,
 TokenAlgebra TsToken (p TsToken TsToken),
 TerminalSymbol TsToken (p () ())) =>
TsTokenCategory -> p Text Text
signed TsTokenCategory
NumericLiteral
  , Market Text Text Text (Identity Text)
-> Market Text Text TsLiteral (Identity TsLiteral)
Prism' TsLiteral Text
_BigIntegerLiteral (Market Text Text Text (Identity Text)
 -> Market Text Text TsLiteral (Identity TsLiteral))
-> p Text Text -> p TsLiteral TsLiteral
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? TsTokenCategory -> p Text Text
forall {p :: * -> * -> *}.
(DisjunctiveMonoid (p Text Text), Alternator p,
 TokenAlgebra TsToken (p TsToken TsToken),
 TerminalSymbol TsToken (p () ())) =>
TsTokenCategory -> p Text Text
signed TsTokenCategory
BigIntLiteral
  ]
  where
    signed :: TsTokenCategory -> p Text Text
signed TsTokenCategory
category = [p Text Text] -> p Text Text
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Market Text Text Text (Identity Text)
-> Market Text Text Text (Identity Text)
Prism' Text Text
_Negative (Market Text Text Text (Identity Text)
 -> Market Text Text Text (Identity Text))
-> p Text Text -> p Text Text
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
MinusToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
category
      , TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
category
      ]

-- | A negative number, by its spelling without its sign.
_Negative :: Prism' Text Text
_Negative :: Prism' Text Text
_Negative = (Text -> Text) -> (Text -> Maybe Text) -> Prism' Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (Text
"-" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>) (Text -> Text -> Maybe Text
Text.stripPrefix Text
"-")

-- | A qualified name.
entityName :: TsGrammatical p => p TsEntityName TsEntityName
entityName :: forall (p :: * -> * -> *).
TsGrammatical p =>
p TsEntityName TsEntityName
entityName =
  p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier p Text Text
-> p TsEntityName TsEntityName -> p TsEntityName TsEntityName
forall s t a b (p :: * -> * -> *).
(Cons s t a b, Monoidal p, Choice p) =>
p a b -> p s t -> p s t
>:< p Text Text -> p TsEntityName TsEntityName
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
DotToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP p () () -> p Text Text -> p Text Text
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifierName)

-- | Comma separated items.
commas :: TsGrammatical p => p a a -> p [a] [a]
commas :: forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
commas p a a
item = [p [a] [a]] -> p [a] [a]
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP [p a a -> p [a] [a]
forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
commas1 p a a
item, Market () () () (Identity ()) -> Market () () [a] (Identity [a])
forall a. AsEmpty a => Prism' a ()
Prism' [a] ()
_Empty (Market () () () (Identity ()) -> Market () () [a] (Identity [a]))
-> p () () -> p [a] [a]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP]

-- | At least one comma separated item, & a trailing comma, if it's there.
commas1 :: TsGrammatical p => p a a -> p [a] [a]
commas1 :: forall (p :: * -> * -> *) a. TsGrammatical p => p a a -> p [a] [a]
commas1 p a a
item = Market (a, [a]) (a, [a]) (a, [a]) (Identity (a, [a]))
-> Market (a, [a]) (a, [a]) [a] (Identity [a])
forall s t a b. Cons s t a b => Prism s t (a, s) (b, t)
Prism [a] [a] (a, [a]) (a, [a])
_Cons (Market (a, [a]) (a, [a]) (a, [a]) (Identity (a, [a]))
 -> Market (a, [a]) (a, [a]) [a] (Identity [a]))
-> p (a, [a]) (a, [a]) -> p [a] [a]
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p a a
item p a a -> p [a] [a] -> p (a, [a]) (a, [a])
forall (p :: * -> * -> *) a b c d.
Monoidal p =>
p a b -> p c d -> p (a, c) (b, d)
>*< p a a -> p [a] [a]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (p a a -> p a a
forall a. p a a -> p a a
forall (m :: * -> *) a. MonadTry m => m a -> m a
try (p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () ()
comma p () () -> p a a -> p a a
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* p a a
item))
  p [a] [a] -> p () () -> p [a] [a]
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< TsTokenCategory -> p () ()
forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p () ()
optionalToken TsTokenCategory
CommaToken

comma :: TsGrammatical p => p () ()
comma :: forall (p :: * -> * -> *). TsGrammatical p => p () ()
comma = p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
CommaToken p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space

-- | @...@, or not.
dots :: TsGrammatical p => p Bool Bool
dots :: forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
dots = [p Bool Bool] -> p Bool Bool
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
True (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
DotDotDotToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
False (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]

-- | @?@, or not.
question :: TsGrammatical p => p Bool Bool
question :: forall (p :: * -> * -> *). TsGrammatical p => p Bool Bool
question = [p Bool Bool] -> p Bool Bool
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
True (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
QuestionToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  , Bool -> Prism' Bool ()
forall a. Eq a => a -> Prism' a ()
only Bool
False (Market () () () (Identity ())
 -> Market () () Bool (Identity Bool))
-> p () () -> p Bool Bool
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
  ]

-- | A @;@, which is printed, & parsed if it's there.
semicolon :: TsGrammatical p => p () ()
semicolon :: forall (p :: * -> * -> *). TsGrammatical p => p () ()
semicolon = p () () -> p () ()
forall (p :: * -> * -> *). TsGrammatical p => p () () -> p () ()
printed (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
SemicolonToken p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP)

-- | A token, which is parsed if it's there, but not printed.
optionalToken :: TsGrammatical p => TsTokenCategory -> p () ()
optionalToken :: forall (p :: * -> * -> *).
TsGrammatical p =>
TsTokenCategory -> p () ()
optionalToken TsTokenCategory
category = (() -> Maybe ())
-> (Maybe () -> ()) -> p (Maybe ()) (Maybe ()) -> p () ()
forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (Maybe () -> () -> Maybe ()
forall a b. a -> b -> a
const Maybe ()
forall a. Maybe a
Nothing) (() -> Maybe () -> ()
forall a b. a -> b -> a
const ())
  (p () () -> p (Maybe ()) (Maybe ())
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP (p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP))

-- | Syntax, which is printed, & parsed if it's there.
printed :: TsGrammatical p => p () () -> p () ()
printed :: forall (p :: * -> * -> *). TsGrammatical p => p () () -> p () ()
printed p () ()
syntax = (() -> Maybe ())
-> (Maybe () -> ()) -> p (Maybe ()) (Maybe ()) -> p () ()
forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (Maybe () -> () -> Maybe ()
forall a b. a -> b -> a
const (() -> Maybe ()
forall a. a -> Maybe a
Just ())) (() -> Maybe () -> ()
forall a b. a -> b -> a
const ()) (p () () -> p (Maybe ()) (Maybe ())
forall a b. p a b -> p (Maybe a) (Maybe b)
forall (p :: * -> * -> *) a b.
Distributor p =>
p a b -> p (Maybe a) (Maybe b)
optionalP p () ()
syntax)

-- | An identifier, or a contextual keyword, by its name.
identifier :: TsGrammatical p => p Text Text
identifier :: forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier = [p Text Text] -> p Text Text
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ TsTokenCategory -> p Text Text
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
Identifier
  , [p Text Text] -> p Text Text
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Text -> Prism' Text ()
forall a. Eq a => a -> Prism' a ()
only Text
text (Market () () () (Identity ())
 -> Market () () Text (Identity Text))
-> p () () -> p Text Text
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      | (TsTokenCategory
category, Text
text) <- [(TsTokenCategory, Text)]
contextualKeywords
      ]
  ]

-- | An identifier, or any keyword, by its name.
identifierName :: TsGrammatical p => p Text Text
identifierName :: forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifierName = [p Text Text] -> p Text Text
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
  [ p Text Text
forall (p :: * -> * -> *). TsGrammatical p => p Text Text
identifier
  , [p Text Text] -> p Text Text
forall (f :: * -> *) a.
(Foldable f, DisjunctiveMonoid a) =>
f a -> a
orP
      [ Text -> Prism' Text ()
forall a. Eq a => a -> Prism' a ()
only Text
text (Market () () () (Identity ())
 -> Market () () Text (Identity Text))
-> p () () -> p Text Text
forall (p :: * -> * -> *) s t a b.
Choice p =>
APrism s t a b -> p a b -> p s t
>? p () () -> TsTokenCategory -> p () () -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP TsTokenCategory
category p () ()
forall (p :: * -> * -> *). Monoidal p => p () ()
oneP
      | (TsTokenCategory
category, Text
text) <- [(TsTokenCategory, Text)]
reservedWords
      ]
  ]

-- | A tuple's element, or else an optional element's type.
_Optional :: Iso' TsType (TsType, Bool)
_Optional :: Iso' TsType (TsType, Bool)
_Optional = (TsType -> (TsType, Bool))
-> ((TsType, Bool) -> TsType) -> Iso' TsType (TsType, Bool)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
  (\case OptionalType TsType
node -> (TsType
node, Bool
True); TsType
node -> (TsType
node, Bool
False))
  (\case (TsType
node, Bool
True) -> TsType -> TsType
OptionalType TsType
node; (TsType
node, Bool
False) -> TsType
node)

-- | An object type or a mapped type, which are braced.
_Braced :: Prism' TsType TsType
_Braced :: Prism' TsType TsType
_Braced = (TsType -> TsType)
-> (TsType -> Maybe TsType) -> Prism' TsType TsType
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' TsType -> TsType
forall a. a -> a
id ((TsType -> Maybe TsType) -> Prism' TsType TsType)
-> (TsType -> Maybe TsType) -> Prism' TsType TsType
forall a b. (a -> b) -> a -> b
$ \case
  node :: TsType
node@(ObjectType [TsProperty]
_) -> TsType -> Maybe TsType
forall a. a -> Maybe a
Just TsType
node
  node :: TsType
node@(MappedType {}) -> TsType -> Maybe TsType
forall a. a -> Maybe a
Just TsType
node
  TsType
_ -> Maybe TsType
forall a. Maybe a
Nothing

-- | A template's spans, by the first's type & its middle or tail.
_Spans
  :: Prism' [(TsType, Text)]
      (TsType, Either (Text, [(TsType, Text)]) Text)
_Spans :: Prism'
  [(TsType, Text)] (TsType, Either (Text, [(TsType, Text)]) Text)
_Spans = ((TsType, Either (Text, [(TsType, Text)]) Text)
 -> [(TsType, Text)])
-> ([(TsType, Text)]
    -> Maybe (TsType, Either (Text, [(TsType, Text)]) Text))
-> Prism'
     [(TsType, Text)] (TsType, Either (Text, [(TsType, Text)]) Text)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
  (\case
    (TsType
node, Left (Text
middle, [(TsType, Text)]
others)) -> (TsType
node, Text
middle) (TsType, Text) -> [(TsType, Text)] -> [(TsType, Text)]
forall a. a -> [a] -> [a]
: [(TsType, Text)]
others
    (TsType
node, Right Text
tail') -> [(TsType
node, Text
tail')])
  (\case
    [(TsType
node, Text
tail')] -> (TsType, Either (Text, [(TsType, Text)]) Text)
-> Maybe (TsType, Either (Text, [(TsType, Text)]) Text)
forall a. a -> Maybe a
Just (TsType
node, Text -> Either (Text, [(TsType, Text)]) Text
forall a b. b -> Either a b
Right Text
tail')
    (TsType
node, Text
middle) : others :: [(TsType, Text)]
others@((TsType, Text)
_ : [(TsType, Text)]
_) -> (TsType, Either (Text, [(TsType, Text)]) Text)
-> Maybe (TsType, Either (Text, [(TsType, Text)]) Text)
forall a. a -> Maybe a
Just (TsType
node, (Text, [(TsType, Text)]) -> Either (Text, [(TsType, Text)]) Text
forall a b. a -> Either a b
Left (Text
middle, [(TsType, Text)]
others))
    [] -> Maybe (TsType, Either (Text, [(TsType, Text)]) Text)
forall a. Maybe a
Nothing)

-- | A template literal type without substitutions.
_NoSubstitution :: Prism' TsType Text
_NoSubstitution :: Prism' TsType Text
_NoSubstitution = (Text -> TsType) -> (TsType -> Maybe Text) -> Prism' TsType Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (Text -> [(TsType, Text)] -> TsType
`TemplateLiteralType` []) ((TsType -> Maybe Text) -> Prism' TsType Text)
-> (TsType -> Maybe Text) -> Prism' TsType Text
forall a b. (a -> b) -> a -> b
$ \case
  TemplateLiteralType Text
text [] -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
text
  TsType
_ -> Maybe Text
forall a. Maybe a
Nothing

-- | A list of at least two, or else its only one.
_Several :: Prism' TsType [TsType] -> Iso' TsType (TsType, [TsType])
_Several :: Prism' TsType [TsType] -> Iso' TsType (TsType, [TsType])
_Several Prism' TsType [TsType]
nodes = (TsType -> (TsType, [TsType]))
-> ((TsType, [TsType]) -> TsType) -> Iso' TsType (TsType, [TsType])
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
  (\TsType
node -> case TsType
node TsType
-> Getting (First [TsType]) TsType [TsType] -> Maybe [TsType]
forall s a. s -> Getting (First a) s a -> Maybe a
^? Getting (First [TsType]) TsType [TsType]
Prism' TsType [TsType]
nodes of
    Just (TsType
first : others :: [TsType]
others@(TsType
_ : [TsType]
_)) -> (TsType
first, [TsType]
others)
    Maybe [TsType]
_ -> (TsType
node, []))
  (\case
    (TsType
node, []) -> TsType
node
    (TsType
first, [TsType]
others) -> AReview TsType [TsType] -> [TsType] -> TsType
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview TsType [TsType]
Prism' TsType [TsType]
nodes (TsType
first TsType -> [TsType] -> [TsType]
forall a. a -> [a] -> [a]
: [TsType]
others))

-- | A conditional type, or else its check type.
_Conditional :: Iso' TsType (TsType, Maybe (TsType, (TsType, TsType)))
_Conditional :: Iso' TsType (TsType, Maybe (TsType, (TsType, TsType)))
_Conditional = (TsType -> (TsType, Maybe (TsType, (TsType, TsType))))
-> ((TsType, Maybe (TsType, (TsType, TsType))) -> TsType)
-> Iso' TsType (TsType, Maybe (TsType, (TsType, TsType)))
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
  (\case
    ConditionalType TsType
check TsType
extends TsType
true TsType
false ->
      (TsType
check, (TsType, (TsType, TsType)) -> Maybe (TsType, (TsType, TsType))
forall a. a -> Maybe a
Just (TsType
extends, (TsType
true, TsType
false)))
    TsType
node -> (TsType
node, Maybe (TsType, (TsType, TsType))
forall a. Maybe a
Nothing))
  (\case
    (TsType
node, Maybe (TsType, (TsType, TsType))
Nothing) -> TsType
node
    (TsType
check, Just (TsType
extends, (TsType
true, TsType
false))) ->
      TsType -> TsType -> TsType -> TsType -> TsType
ConditionalType TsType
check TsType
extends TsType
true TsType
false)

-- Trivia --

-- | Trivia, of whitespace & newlines, printed as some trivia.
trivia :: (Lexical TsToken p, Alternator p) => [TsToken] -> p () ()
trivia :: forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
[TsToken] -> p () ()
trivia [TsToken]
shown = (() -> [TsToken])
-> ([TsToken] -> ()) -> p [TsToken] [TsToken] -> p () ()
forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap ([TsToken] -> () -> [TsToken]
forall a b. a -> b -> a
const [TsToken]
shown) (() -> [TsToken] -> ()
forall a b. a -> b -> a
const ())
  (p TsToken TsToken -> p [TsToken] [TsToken]
forall a b. p a b -> p [a] [b]
forall (p :: * -> * -> *) a b. Distributor p => p a b -> p [a] [b]
manyP (forall token p. Tokenized token p => Categorize token -> p
asIn @TsToken Categorize TsToken
TsTokenCategory
WhitespaceTrivia p TsToken TsToken -> p TsToken TsToken -> p TsToken TsToken
forall a. DisjunctiveMonoid a => a -> a -> a
>|< forall token p. Tokenized token p => Categorize token -> p
asIn @TsToken Categorize TsToken
TsTokenCategory
NewLineTrivia))

space :: (Lexical TsToken p, Alternator p) => p () ()
space :: forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
space = [TsToken] -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
[TsToken] -> p () ()
trivia [TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
WhitespaceTrivia Text
" "]

newline :: (Lexical TsToken p, Alternator p) => p () ()
newline :: forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () ()
newline = [TsToken] -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
[TsToken] -> p () ()
trivia [TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
NewLineTrivia Text
"\n"]

-- | A newline, indented four spaces for each depth.
indented :: (Lexical TsToken p, Alternator p) => Int -> p () ()
indented :: forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
Int -> p () ()
indented Int
depth = [TsToken] -> p () ()
forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
[TsToken] -> p () ()
trivia ([TsToken] -> p () ()) -> [TsToken] -> p () ()
forall a b. (a -> b) -> a -> b
$ TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
NewLineTrivia Text
"\n"
  TsToken -> [TsToken] -> [TsToken]
forall a. a -> [a] -> [a]
: [TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
WhitespaceTrivia (Int -> Text -> Text
Text.replicate (Int
4 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
depth) Text
" ") | Int
depth Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0]

-- | A punctuation or keyword token, between trivia, or `oneP`.
tokenOf
  :: (Lexical TsToken p, Alternator p)
  => p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf :: forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
p () () -> TsTokenCategory -> p () () -> p () ()
tokenOf p () ()
before TsTokenCategory
category p () ()
after =
  p () ()
before p () () -> p () () -> p () ()
forall (p :: * -> * -> *) c a b.
Monoidal p =>
p () c -> p a b -> p a b
>* [TsToken] -> p () ()
forall token s. TerminalSymbol token s => [token] -> s
terminal [TsTokenCategory -> TsToken
symbol TsTokenCategory
category] p () () -> p () () -> p () ()
forall (p :: * -> * -> *) a b c.
Monoidal p =>
p a b -> p () c -> p a b
*< p () ()
after

-- | The text of a token of a category.
textOf
  :: (Lexical TsToken p, Alternator p) => TsTokenCategory -> p Text Text
textOf :: forall (p :: * -> * -> *).
(Lexical TsToken p, Alternator p) =>
TsTokenCategory -> p Text Text
textOf TsTokenCategory
category = (Text -> TsToken)
-> (TsToken -> Text) -> Iso Text Text TsToken TsToken
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (TsTokenCategory -> Text -> TsToken
TsToken TsTokenCategory
category) TsToken -> Text
tokenText (Exchange TsToken TsToken TsToken (Identity TsToken)
 -> Exchange TsToken TsToken Text (Identity Text))
-> p TsToken TsToken -> p Text Text
forall (p :: * -> * -> *) s t a b.
Profunctor p =>
AnIso s t a b -> p a b -> p s t
>~ forall token p. Tokenized token p => Categorize token -> p
asIn @TsToken Categorize TsToken
TsTokenCategory
category