BNFC3-3.0: A compiler front-end generator.
Safe HaskellNone
LanguageHaskell2010

BNFC.Backend.Agda.Utilities.Utils

Synopsis

Documentation

data ImportNumeric Source #

Import the builtin numeric types (content of some token categories)?

Constructors

YesImportNumeric

Import the numeric types.

NoImportNumeric

Don't import the numeric types.

Instances

Instances details
Eq ImportNumeric Source # 
Instance details

Defined in BNFC.Backend.Agda.Utilities.Utils

imports Source #

Arguments

:: ImportNumeric

Import also numeric types?

-> Bool

If have layout, import booleans.

-> Bool

If have position information, import natural numbers.

-> Bool

Do we need Maybe?

-> Doc () 

importPragmas Source #

Arguments

:: Bool

Do we use position information?

-> [ModuleName]

Haskell modules to import.

-> Doc () 

data ConstructorStyle Source #

How to print the types of constructors in Agda?

Constructors

UnnamedArg

Simply typed, like E → S → S → S.

NamedArg

Dependently typed, like (e : E) (s₁ s₂ : S) → S.

nameSuggestion :: Type -> String Source #

Suggest the name of a bound variable of the given category.

>>> map nameSuggestion
[ ListType (BaseType (BaseCat 'S':|"tm")), BaseType (TokenCat 'V':|"ar"), (BaseType (BaseCat 'E':|"xp") ]
["ss","x","e"]

nameFor :: String1 -> String Source #

Suggest the name of a bound variable of the given base category.

>>> map nameFor ["Stm","ABC","#String"]
["s","a","s"]

numberUniquely :: forall a. Ord a => [a] -> [(Maybe Int, a)] Source #

Number duplicate elements in a list consecutively, starting with 1.

>>> numberUniquely ["a", "b", "a", "a", "c", "b"]
[(Just 1,"a"),(Just 1,"b"),(Just 2,"a"),(Just 3,"a"),(Nothing,"c"),(Just 2,"b")]

type Frequency a = Map a Int Source #

A frequency map.

NB: this type synonym should be local to numberUniquely, but Haskell lacks local type synonyms. https://gitlab.haskell.org/ghc/ghc/issues/4020

incr :: Ord a => a -> Frequency a -> Frequency a Source #

Increase the frequency of the given key.