Agda-2.8.0: A dependently typed functional programming language and proof assistant

Safe Haskell | None
Language | Haskell2010

Agda.Compiler.JS.Pretty

Synopsis

- data JSModuleStyle
  - = JSES6
  - | JSCJS
  - | JSAMD
- data Doc
  - = Doc String
  - | Indent Int Doc
  - | Group Doc
  - | Beside Doc Doc
  - | Above Doc Doc
  - | Enclose Doc Doc Doc
  - | Space
  - | Empty
- minifiedCodeLinesLength :: Int
- render :: Bool -> Doc -> String
- ($+$) :: Doc -> Doc -> Doc
- ($++$) :: Doc -> Doc -> Doc
- (<+>) :: Doc -> Doc -> Doc
- text :: String -> Doc
- group :: Doc -> Doc
- indentBy :: Int -> Doc -> Doc
- enclose :: Doc -> Doc -> Doc -> Doc
- space :: Doc
- indent :: Doc -> Doc
- hcat :: [Doc] -> Doc
- vcat :: [Doc] -> Doc
- vsep :: [Doc] -> Doc
- punctuate :: Doc -> [Doc] -> Doc
- parens :: Doc -> Doc
- brackets :: Doc -> Doc
- braces :: Doc -> Doc
- mparens :: Bool -> Doc -> Doc
- unescape :: Char -> String
- unescapes :: String -> Doc
- class Pretty a where
  - pretty :: (Nat, Bool, JSModuleStyle) -> a -> Doc
  - prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> a -> Doc
- prettyShow :: Pretty a => Bool -> JSModuleStyle -> a -> String
- class Pretties a where
  - pretties :: (Nat, Bool, JSModuleStyle) -> a -> [Doc]
- block :: (Nat, Bool, JSModuleStyle) -> Exp -> Doc
- modname :: GlobalId -> Doc
- exports :: (Nat, Bool, JSModuleStyle) -> Set JSQName -> [Export] -> Doc
- variableName :: String -> String
- isValidJSIdent :: String -> Bool

# Documentation

data JSModuleStyle Source #

Constructors

JSES6 |
JSCJS |
JSAMD |

#### Instances

Instances details

NFData JSModuleStyle Source # |
Instance details Defined in Agda.Compiler.JS.Compiler Methods rnf :: JSModuleStyle -> () Source #
Generic JSModuleStyle Source # |

Instance details

Defined in Agda.Compiler.JS.Pretty

Associated Types

type Rep JSModuleStyle |
Instance details Defined in Agda.Compiler.JS.Pretty type Rep JSModuleStyle = D1 ('MetaData "JSModuleStyle" "Agda.Compiler.JS.Pretty" "Agda-2.8.0-DJrTbcOFazJDzri4fKrI2F" 'False) (C1 ('MetaCons "JSES6" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "JSCJS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "JSAMD" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: JSModuleStyle -> Rep JSModuleStyle x Source #

to :: Rep JSModuleStyle x -> JSModuleStyle Source #

type Rep JSModuleStyle Source # |
Instance details Defined in Agda.Compiler.JS.Pretty type Rep JSModuleStyle = D1 ('MetaData "JSModuleStyle" "Agda.Compiler.JS.Pretty" "Agda-2.8.0-DJrTbcOFazJDzri4fKrI2F" 'False) (C1 ('MetaCons "JSES6" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "JSCJS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "JSAMD" 'PrefixI 'False) (U1 :: Type -> Type)))

data Doc Source #

Constructors

Doc String |
Indent Int Doc |
Group Doc |
Beside Doc Doc |
Above Doc Doc |
Enclose Doc Doc Doc |
Space |
Empty |

#### Instances

Instances details

Monoid Doc Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods mempty :: Doc Source # mappend :: Doc -> Doc -> Doc Source # mconcat :: [Doc] -> Doc Source #
Semigroup Doc Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods (<>) :: Doc -> Doc -> Doc Source # sconcat :: NonEmpty Doc -> Doc Source # stimes :: Integral b => b -> Doc -> Doc Source #
IsString Doc Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods fromString :: String -> Doc Source #

minifiedCodeLinesLength :: Int Source #

render :: Bool -> Doc -> String Source #

($+$) :: Doc -> Doc -> Doc infixr 5 Source #

($++$) :: Doc -> Doc -> Doc infixr 5 Source #

Separate by blank line.

(<+>) :: Doc -> Doc -> Doc infixr 6 Source #

Separate by space that will be removed by minify.

For non-removable space, use `d <> " " <> d'`.

text :: String -> Doc Source #

group :: Doc -> Doc Source #

indentBy :: Int -> Doc -> Doc Source #

enclose :: Doc -> Doc -> Doc -> Doc Source #

space :: Doc Source #

indent :: Doc -> Doc Source #

hcat :: [Doc] -> Doc Source #

vcat :: [Doc] -> Doc Source #

vsep :: [Doc] -> Doc Source #

Concatenate vertically, separated by blank lines.

punctuate :: Doc -> [Doc] -> Doc Source #

parens :: Doc -> Doc Source #

brackets :: Doc -> Doc Source #

braces :: Doc -> Doc Source #

mparens :: Bool -> Doc -> Doc Source #

Apply `parens` to `Doc` if boolean is true.

unescape :: Char -> String Source #

unescapes :: String -> Doc Source #

class Pretty a where Source #

Minimal complete definition

pretty | prettyPrec

Methods

pretty :: (Nat, Bool, JSModuleStyle) -> a -> Doc Source #

prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> a -> Doc Source #

#### Instances

Instances details

Pretty Comment Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretty :: (Nat, Bool, JSModuleStyle) -> Comment -> Doc Source # prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> Comment -> Doc Source #
Pretty Exp Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretty :: (Nat, Bool, JSModuleStyle) -> Exp -> Doc Source # prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> Exp -> Doc Source #
Pretty GlobalId Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretty :: (Nat, Bool, JSModuleStyle) -> GlobalId -> Doc Source # prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> GlobalId -> Doc Source #
Pretty LocalId Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretty :: (Nat, Bool, JSModuleStyle) -> LocalId -> Doc Source # prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> LocalId -> Doc Source #
Pretty MemberId Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretty :: (Nat, Bool, JSModuleStyle) -> MemberId -> Doc Source # prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> MemberId -> Doc Source #
Pretty Module Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretty :: (Nat, Bool, JSModuleStyle) -> Module -> Doc Source # prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> Module -> Doc Source #
Pretty a => Pretty (Maybe a) Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretty :: (Nat, Bool, JSModuleStyle) -> Maybe a -> Doc Source # prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> Maybe a -> Doc Source #
Pretty [(GlobalId, Export)] Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretty :: (Nat, Bool, JSModuleStyle) -> [(GlobalId, Export)] -> Doc Source # prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> [(GlobalId, Export)] -> Doc Source #
(Pretty a, Pretty b) => Pretty (a, b) Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretty :: (Nat, Bool, JSModuleStyle) -> (a, b) -> Doc Source # prettyPrec :: Int -> (Nat, Bool, JSModuleStyle) -> (a, b) -> Doc Source #

prettyShow :: Pretty a => Bool -> JSModuleStyle -> a -> String Source #

class Pretties a where Source #

Methods

pretties :: (Nat, Bool, JSModuleStyle) -> a -> [Doc] Source #

#### Instances

Instances details

Pretty a => Pretties (List1 a) Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretties :: (Nat, Bool, JSModuleStyle) -> List1 a -> [Doc] Source #
Pretty a => Pretties [a] Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretties :: (Nat, Bool, JSModuleStyle) -> [a] -> [Doc] Source #
(Pretty a, Pretty b) => Pretties (Map a b) Source # |
Instance details Defined in Agda.Compiler.JS.Pretty Methods pretties :: (Nat, Bool, JSModuleStyle) -> Map a b -> [Doc] Source #

block :: (Nat, Bool, JSModuleStyle) -> Exp -> Doc Source #

modname :: GlobalId -> Doc Source #

exports :: (Nat, Bool, JSModuleStyle) -> Set JSQName -> [Export] -> Doc Source #

variableName :: String -> String Source #

isValidJSIdent :: String -> Bool Source #

Check if a string is a valid JS identifier. The check ignores keywords as we prepend z_ to our identifiers. The check is conservative and may not admit all valid JS identifiers.