[silver:core] (stdlib)
Contents of [silver:core]
:
Defined in this grammar:
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 6.
true if parsing successfully produced a syntax tree. false if a parse error occurred.
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 11.
The ParseError which parseErrors is generated from.
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 16.
A string containing the parse errors reported by copper. The format is unspecified, yet.
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 21.
The parse tree, if parsing was successful.
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 26.
A list of terminals parsed.
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 33.
Parametera
The start nonterminal type.
A container type for the result of calling a parser.
abstract production parseFailed
(top::ParseResult<a> ::= e::ParseError terminals::[TerminalDescriptor]
)
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 41.
Parametere
The error string reported by the parser.
Parameterterminals
TODO
Parse failure constructor.
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 57.
Parametert
The syntax tree returned by the parser.
Parameterterminals
TODO
Parse success constructor.
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 77.
WARNING!
Deprecated!
Parameterpr
The ParseResult returned by the parser
Return
The syntax tree reported by the parser. Does not return if parsing fails.
Make parsers behave like they used to in previous versions of Silver.
Exits and prints parse errors if parsing fails, without a stack trace.
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 84.
Representation of a parser error.
abstract production syntaxError
(top::ParseError ::= diagnosticString::String location::Location expectedNames::[String] matchedNames::[String]
)
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 94.
ParameterdiagnosticString
An un-pretty but convenient way of printing out this parser error.
Parameterlocation
The location (filename, line, column, index, etc) of the parser error
ParameterexpectedNames
The display names of the expected terminals
ParametermatchedNames
The display names of what the parser matched
This production as currently designed matches up exactly with what copper raises in its syntax error exception.
Contained in grammar [silver:core]
. Defined at silver/core/ParseResult.sv line 110.
ParameterdiagnosticString
A string describing the error
Parameterfile
The filename the error occured on. No other location information is available.
This production accomodates an unknown type of parser error.
Contained in grammar [silver:core]
. Defined at silver/core/Apply.sv line 12.
Functors with an apply operation, that can be used to lift functions of two or more arguments to work on values wrapped in the type constructor f.
Instances should satisfy the following:
Associative Composition ap(ap(map(compose, f), g), h) = ap(f, ap(g, h))
Contained in grammar [silver:core]
. Defined at silver/core/Ring.sv line 11.
This is the typeclass that provides the unary and binary -
operators.
Laws:
- Left Inverse:
sub(x, x) = zero
- Right Inverse:
add(sub(zero, x), x) = zero
- Negate:
neg(x) = sub(zero, x)
Contained in grammar
[silver:core]
. Defined at silver/core/Ring.sv line 13.The function corresponding to the binary
-
operator.
Contained in grammar
[silver:core]
. Defined at silver/core/Ring.sv line 16.The function corresponding to the unary
-
operator.
Contained in grammar [silver:core]
. Defined at silver/core/Ring.sv line 62.
Converts an integer into an arbitrary ring.
Contained in grammar [silver:core]
. Defined at silver/core/Semiring.sv line 22.
Provides operator overloads for the +
and *
operators.
Laws:
- Commutative monoid under addition:
- Associativity:
add(add(x, y), z) = add(x, add(y, z))
- Left Identity:
add(zero, x) = x
- Right Identity:
add(x, zero) = x
- Commutativity:
add(x, y) = add(y, x)
- Monoid under multiplication:
- Associativity:
mul(mul(x, y), z) = mul(x, mul(y, z))
- Left Identity:
mul(one, x) = x
- Right Identity:
mul(x, one) = x
- Multiplication distributes over addition:
- Left Distributivity:
mul(x, add(y, z)) = add(mul(x, y), mul(x, z))
- Right Distributivity:
mul(add(x, y), z) = add(mul(x, z), mul(y, z))
- Left Annihilation:
mul(zero, x) = zero
- Right Annihilation:
mul(x, zero) = zero
Contained in grammar
[silver:core]
. Defined at silver/core/Semiring.sv line 24.The function corresponding to the
+
operator.
Contained in grammar
[silver:core]
. Defined at silver/core/Semiring.sv line 26.The value corresponding to the
0
constant.
Contained in grammar
[silver:core]
. Defined at silver/core/Semiring.sv line 28.The function corresponding to the
*
operator.
Contained in grammar
[silver:core]
. Defined at silver/core/Semiring.sv line 30.The value corresponding to the
1
constant.
Contained in grammar [silver:core]
. Defined at silver/core/Semiring.sv line 87.
Converts a non-negative integer into an arbitrary semiring.
Contained in grammar [silver:core]
. Defined at silver/core/Semiring.sv line 101.
Compute the sum of a list.
Contained in grammar [silver:core]
. Defined at silver/core/Semiring.sv line 104.
Compute the product of a list.
Contained in grammar [silver:core]
. Defined at silver/core/Location.sv line 8.
Data structure storing location information on tree nodes from a parse.
abstract production loc
(top::Location ::= filename::String line::Integer column::Integer endLine::Integer endColumn::Integer index::Integer endIndex::Integer
)
Contained in grammar [silver:core]
. Defined at silver/core/Location.sv line 53.
Parameterfilename
The “virtual filename”. Initially whatever the parser is given.
Parameterline
(Beginning) line number, inclusive. Lines are numbered starting with 1.
Parametercolumn
(Beginning) column number, inclusive. Columns are numbered starting with 0. (For now.)
ParameterendLine
(Ending) line number, inclusive.
ParameterendColumn
(Ending) column number, exclusive.
Parameterindex
(Beginning) character index, inclusive.
ParameterendIndex
(Ending) character index, exclusive.
The main constructor for location information.
filename, line and column can be mutated by action blocks during parsing, but character index cannot.
e.g. “Hi” as an entire file contents would have its entire location as:
(_, 1, 0, 1, 2, 0, 2)
Contained in grammar [silver:core]
. Defined at silver/core/Location.sv line 72.
Parametertext
The text to return as unparse as defined in langutil
A secondary constructor for location information, for locations not from source code
fun childParserLoc
(Location ::= parent::Location child::Location linesOffset::Integer firstLineColsOffset::Integer allLinesColsOffset::Integer indexOffset::Integer
)
Contained in grammar [silver:core]
. Defined at silver/core/Location.sv line 90.
Offset one location “inside” another. For use when e.g. parsing a doc comment grammar out of a single terminal in the host language. use linesOffset, firstLineColsOffset, allLinesColsOffset, indexOffset if some part of the terminal is munged before being passed to the child parser (e.g. the {- and -} are removed from a comment.)
Contained in grammar [silver:core]
. Defined at silver/core/Location.sv line 108.
Parametermodule
The name of the extension/modification/module defining the location
A helper constructor for location information, for built-in locations
Contained in grammar [silver:core]
. Defined at silver/core/Location.sv line 113.
A helper constructor for location information, for invalid or undefined bogus locations
Contained in grammar [silver:core]
. Defined at silver/core/Monad.sv line 13.
Monads support both lifting functions/values of arbitrary arity and sequential compostion.
Instances should satisfy the following:
Left Identity bind(pure(x), f) = f(x) Right Identity bind(x, pure) = x
Contained in grammar [silver:core]
. Defined at silver/core/Monad.sv line 36.
Monads that support failure with an error message.
Instances should satisfy the following:
Annihilation bind(fail(s), f) = fail(s)
Contained in grammar [silver:core]
. Defined at silver/core/Monad.sv line 48.
The MonadZero type class has no members of its own; it just specifies that the type has both Monad and Alternative instances.
Instances should satisfy the following:
Annihilation bind(empty, f) = empty
Contained in grammar [silver:core]
. Defined at silver/core/Monad.sv line 58.
The MonadPlus type class has no members of its own; it just extends MonadZero with an additional law.
Instances should satisfy the following:
Distributivity bind(alt(x, y), f) = alt(bind(x, f), bind(y, f))
Contained in grammar [silver:core]
. Defined at silver/core/Monad.sv line 77.
Monads having fixed points with a ‘knot-tying’ semantics.
Instances should satisfy the following:
Purity mfix(compose(pure, h)) = pure(fix(h))
Left shrinking (or Tightening) mfix(\x -> bind(a, \y -> f(x, y))) = bind(a, \y -> mfix(\x -> f(x, y)))
Sliding mfix(compose(map(h, _), f)) = map(h, (mfix(compose(f, h)))), for strict h.
Nesting mfix(\x -> mfix(\y -> f(x, y))) = mfix(\x -> f(x, x))
Contained in grammar [silver:core]
. Defined at silver/core/Monad.sv line 88.
Monad transformers lift a monadic computation into an additional monad.
Instances should satisfy the following: compose(lift, pure) = pure lift(bind(m, f)) = bind(lift(m), compose(lift, f))
Contained in grammar [silver:core]
. Defined at silver/core/Monad.sv line 95.
Can be used to extract the monadic value from a MonadTrans instance value.
Contained in grammar [silver:core]
. Defined at silver/core/Ord.sv line 29.
Ord represents ordering relationships between data.
Laws are based on Haskell’s Ord type class:
Transitivity if x <= y && y <= z = true, then x <= z = true Reflexivity x <= x = true Antisymmetry if x <= y && y <= x = true, then x == y = true
Note that the following operator interactions are expected to hold:
- x >= y = y <= x
- x < y = x <= y && x != y
- x > y = y < x
- x < y = compare x y < 0
- x > y = compare x y > 0
- x == y = compare x y == 0
- min(x, y) == if x <= y then x else y = true
- max(x, y) == if x >= y then x else y = true
Note that (7.) and (8.) do not require min and max to return either of their arguments. The result is merely required to equal one of the arguments in terms of (==).
Minimal complete definition: either compare or <=. Using compare can be more efficient for complex types.
Contained in grammar [silver:core]
. Defined at silver/core/DivisionRing.sv line 12.
A typeclass for rings that have a reciprocal operation, which gives the multiplicative inverse of non-zero elements.
Laws:
- Non-Zero Ring:
one != zero
- Non-Zero Multiplicative Left Inverse:
(a != 0) -> mul(recip(a), a) = one
- Non-Zero Multiplicative Right Inverse:
(a != 0) -> mul(a, recip(a)) = one
Contained in grammar
[silver:core]
. Defined at silver/core/DivisionRing.sv line 14.The reciprocal, i.e. the inverse for the multiplicative group.
Contained in grammar [silver:core]
. Defined at silver/core/DivisionRing.sv line 25.
Division implemented as (1/r) * l
.
Iff the type is a commutative ring, this is equivalent to rightDiv
.
Contained in grammar [silver:core]
. Defined at silver/core/DivisionRing.sv line 31.
Division implemented as l * (1/r)
.
Iff the type is a commutative ring, this is equivalent to leftDiv
.
Contained in grammar [silver:core]
. Defined at silver/core/Maybe.sv line 86.
Parameterm
The monad type to be transformed
Parametera
The optional result type
Monad transformer corresponding to Maybe.
Contained in grammar [silver:core]
. Defined at silver/core/Maybe.sv line 96.
Transform the computation inside a MaybeT.
Contained in grammar [silver:core]
. Defined at silver/core/Maybe.sv line 173.
Parameterotherwise
The element to return if ‘ifJust’ is ‘nothing’
ParameterifJust
The maybe value to scrutinize
Return
Either the contents of the Maybe (if ‘just’), or the otherwise element.
The corresponding fold for Maybes.
Contained in grammar [silver:core]
. Defined at silver/core/Maybe.sv line 183.
Parameterl
The first element
Parameterr
The second element
Return
A wrapped element, if any, favoring ‘l’
Selects the first existing element, favoring the left.
Contained in grammar [silver:core]
. Defined at silver/core/Maybe.sv line 189.
The eliminator for Maybe. Runs ifJust on the wrapped value if there is one, otherwise returns ifNothing.
Contained in grammar [silver:core]
. Defined at silver/core/Maybe.sv line 202.
Parameterh
If a value, the value to cons onto the list.
Parametert
The list to amend, if there’s a value
Return
The list, possibly with a new value at its head.
Maybe cons a value to a list, or not.
Contained in grammar [silver:core]
. Defined at silver/core/Maybe.sv line 211.
Parameterl
A list of optional values
Return
The list with all absent values removed, and present values unwrapped.
Turn a list of possible values into a list of values, skipping over any ‘nothing’s.
Contained in grammar [silver:core]
. Defined at silver/core/Maybe.sv line 216.
Finds the first value matching a predicate.
Contained in grammar [silver:core]
. Defined at silver/core/Semigroup.sv line 11.
The class of semigroups (types with an associative binary operation).
Instances should satisfy the following:
Associativity append(x, append(y, z)) = append(append(x, y), z)
WARNING!
This grammar contains only the definitions of the AST nonterminals, needed by the runtime library. The full reflection library that users should import issilver:reflect
The silver IO system is a IO-token based system.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 12.
The type representing the world-state token of an IO action.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 17.
The resulting value of an IO action.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 24.
Parametera
The type of value returned by the IO action.
A container for the results of IO actions.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 34.
Parameteri
The resulting world-state token.
Parameterv
The resulting value.
The sole constructor of IOVal results.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 44.
IOToken is the IO Token used to sequence actions.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 55.
Parameters
The string to print.
Parameteri
The “before” world-state token.
Return
The “after” world-state token.
Displays a string on standard out. Newlines are NOT automatically added.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 66.
Like printT, but adds a trailing newline automatically.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 71.
Like printT, but for stderr.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 82.
Like eprintT, but adds a trailing newline automatically.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 90.
Parameteri
The “before” world-state token.
Return
The “after” world-state token.
Read a line from standard input.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 107.
WARNING!
Never returns! Does not do any cleanup!
Parameterval
The error code to terminate with. (0 is considered “success”)
Parameteri
The “before” world-state token.
Return
Does not actually return!
Terminates with the specified error code.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 123.
Parameters
The path to create.
Parameteri
The “before” world-state token.
Return
true if completely successful. false if an error occurred along the way.
Creates a directory, including any parents that need to be created along the way. Similar to ‘mkdir -p’. If it fails, it may create only some of them.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 143.
WARNING!
Avoid using this if possible. If you need an IO action not present, request it, please.
Parameters
The string for the shell to execute.
Parameteri
The “before” world-state token.
Return
The exit value of the subprocess.
Executes a shell command. Specifically executes ‘bash -c’. So, not fully cross-platform.
Access to command’s output is not directly available, but it is run in a shell. You can redirect to a file and read that.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 159.
Parameterfile
The filename to write to.
Parametercontents
The string to write to the file.
Parameteri
The “before” world-state token.
Return
The “after” world-state token. May throw a java IO exception, which cannot be caught by Silver.
Write a string to a file, replacing whatever is there already.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 175.
Parameterfile
The filename to append to.
Parametercontents
The string to append to the file.
Parameteri
The “before” world-state token.
Return
The “after” world-state token. May throw a java IO exception, which cannot be caught by Silver.
Append a string to a file.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 191.
Parameterfile
The filename to write to.
Parametercontents
The bytearray to write to the file.
Parameteri
The “before” world-state token.
Return
The “after” world-state token. May throw a java IO exception, which cannot be caught by Silver.
Write a bytearray to a file, replacing whatever is there already.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 207.
Parameters
The file to read.
Parameteri
The “before” world-state token.
Return
The contents of the file. May throw a java IO exception, which cannot be caught by Silver.
Read the entire contents of a file. All instances of “\r\n” are replaced by “\n” for compatibility reasons.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 223.
Parameters
The file to query.
Parameteri
The “before” world-state token.
Return
The modification time of this file. Or 0 if file was not found.
The time, in seconds since 1970, when this file (or directory) was last modified.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 238.
Parameters
The file to query.
Parameteri
The “before” world-state token.
Return
true if if the file is ordinary. false otherwise.
Checks if a file is an ordinary file. (non-directory, non-special)
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 253.
Parameters
The path to query.
Parameteri
The “before” world-state token.
Return
true if if the exists and is a directory. false otherwise.
Checks if a path is a directory.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 269.
Parameters
The file to read.
Parameteri
The “before” world-state token.
Return
The contents of the file. May throw a java IO exception, which cannot be caught by Silver.
Read the entire contents of a file. All instances of “\r\n” are replaced by “\n” for compatibility reasons.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 283.
Parameteri
The “before” world-state token.
Return
The current working directory of the process.
Return the current working directory.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 298.
Parameters
The name of the environment variable to read.
Parameteri
The “before” world-state token.
Return
The variables string. Empty string if the key doesn’t exist.
Obtain the value of an environment variable.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 314.
Parameters
The path to list the contents of.
Parameteri
The “before” world-state token.
Return
All files and directories in the named directory. Or [] on error.
List the contents of a directory. Returns empty list if not a directory or other IO error.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 329.
Parameters
The path to file to delete.
Parameteri
The “before” world-state token.
Return
true if the file is deleted successfully. false otherwise.
Delete a file, or an empty directory.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 344.
Parameters
The list of paths to files to delete.
Parameteri
The “before” world-state token.
Return
true if all files are deleted successfully. false otherwise.
Delete a set of files.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 359.
Parameters
The path to the directory to empty
Parameteri
The “before” world-state token.
Return
true if contents are deleted successfully. false otherwise.
Empty a directory of all normal files (i.e. leaving subdirectories alone)
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 374.
Parameters
The path to the directory to delete
Parameteri
The “before” world-state token.
Return
The IOToken token. Errors (other than non-existence of the path) are fatal.
Delete a non-empty directory and all subdirectories and files.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 390.
Parametersrc
The path of the file to copy.
Parameterdst
The path of the file to write, or the directory to copy the file to.
Parameteri
The “before” world-state token.
Return
the IOToken token. Errors are fatal.
Copy a file from src to dst.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 405.
Parameterfile
The file to update the modification time of.
Parameteri
The IOToken token.
Return
The IOToken token. Errors are suppressed.
Update a file’s modification time to the current time.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 420.
Parameterfiles
The list of files to update the modification time of.
Parameteri
The IOToken token.
Return
The IOToken token. Errors are suppressed.
Update a set of files’ modification time to the current time.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 436.
Return
A fake world-state token.
Create a bogus world-state token, for use with unsafeTrace at silver:core/IOToken.sv#453.
Contained in grammar [silver:core]
. Defined at silver/core/IOToken.sv line 453.
WARNING!
see unsafeIO at silver:core/IOToken.sv#436
Parameterval
The value to evaluate to, after the IO action is performed.
Parameteract
The world-state token to demand and consume.
Return
val, unchanged.
Execute an IO action when a value is demanded by the Silver runtime. When this gets executed may be unpredictable.
Contained in grammar [silver:core]
. Defined at silver/core/HackyUnParse.sv line 9.
WARNING!
This is deprecated. Use silver:langutil:pp:show instead, or genericShow in polymorphic contexts/generated code.
hackUnparse takes any value, and produce a string that represents that value. It is mainly useful for debugging.
Contained in grammar [silver:core]
. Defined at silver/core/HackyUnParse.sv line 25.
Take any value, and return a human-readable string representation. This attempts to make use of the pp or unparse attributes, if a term/tree with either of those is provided. Intended for debugging purposes or for error handling in generated code; prefer silver:langutil:pp:show when possible.
Implementation note: this function makes use of silver:langutil:reflect:genericPP if that library is available, else falling back to the less-sophisticated hackUnparse implementation in the runtime.
Contained in grammar [silver:core]
. Defined at silver/core/HeytingAlgebra.sv line 30.
This is the typeclass that provides the true
and false
constants, as
well as the &&
, ||
, and !
operators.
Laws:
- Associativity:
conj(x, conj(y, z)) = conj(conj(x, y), z)
disj(x, disj(y, z)) = disj(disj(x, y), z)
- Commutativity:
conj(x, y) = conj(y, x)
disj(x, y) = disj(y, x)
- Absorption:
conj(x, disj(x, y)) = x
disj(x, conj(x, y)) = x
- Idempotence:
conj(x, x) = x
disj(x, x) = x
- Identity:
conj(x, true) = x
disj(x, false) = x
- Implication:
implies(x, x) = true
conj(x, implies(x, y)) = conj(x, y)
conj(y, implies(x, y)) = y
implies(x, conj(y, z)) = conj(implies(x, y), implies(x, z))
- Complement:
not(x) = implies(x, false)
Contained in grammar
[silver:core]
. Defined at silver/core/HeytingAlgebra.sv line 33.The false constant.
Contained in grammar
[silver:core]
. Defined at silver/core/HeytingAlgebra.sv line 36.The true constant.
Contained in grammar
[silver:core]
. Defined at silver/core/HeytingAlgebra.sv line 43.Implication.
Note that it is not the case that
implies(x, y) = disj(not(p), q)
for all Heyting algebras. If you require this property, you want aBooleanAlgebra
.
Contained in grammar
[silver:core]
. Defined at silver/core/HeytingAlgebra.sv line 45.Conjunction. This function corresponds to the
&&
operator.
Contained in grammar
[silver:core]
. Defined at silver/core/HeytingAlgebra.sv line 47.Disjunction. This function corresponds to the
||
operator.
Contained in grammar
[silver:core]
. Defined at silver/core/HeytingAlgebra.sv line 53.Complement. This function corresponds to the
!
operator.Note that it is not the case that
not(not(x)) = x
for all Heyting algebras. If you require this property, you want aBooleanAlgebra
.
The miscellaneous IO functions.
Contained in grammar [silver:core]
. Defined at silver/core/IOMisc.sv line 20.
WARNING!
Does not return! Does not do any cleanup!
Parametermsg
The path to list the contents of.
Return
Does not return.
Die with the stated error message and a stack trace. Note that Silver stacks may be hard to read (it’s a lazy language.)
Contained in grammar [silver:core]
. Defined at silver/core/IOMisc.sv line 34.
Return
An integer unique to this process.
Generate an integer unique to this run of this process. Starts from 0 and just counts up each call.
Contained in grammar [silver:core]
. Defined at silver/core/IOMisc.sv line 45.
Generates a random number between [0, 1)
Contained in grammar [silver:core]
. Defined at silver/core/IOMisc.sv line 62.
WARNING!
see unsafeIO at silver:core/IOToken.sv#436
Parameterval
The value to evaluate to, after the IO action is performed.
Parameterstr
The string to print.
Return
val, unchanged.
Print string when a value is demanded by the Silver runtime. When this gets executed may be unpredictable.
Contained in grammar [silver:core]
. Defined at silver/core/IOMisc.sv line 72.
WARNING!
see unsafeIO at silver:core/IOToken.sv#436
Parameterval
The value to evaluate to, printed when evaluated.
Return
val, unchanged.
Print a stringification of a value when it is demanded by the Silver runtime. When this gets executed may be unpredictable.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 85.
Types with a notion of length.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 98.
Applies a function to each element of a list, and returns a list containing all the results that are just. The same as Haskell’s ‘mapMaybe’ and Rust’s filter_map.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 115.
Parameterf
The operator to apply
Parameteri
The “end element” to use in place of ‘nil’
Parameterl
The list to fold
Return
The result of the function applied right-associatively to the list.
Applies an operator right-associatively over a list. (i.e. replaces cons with ‘f’, nil with ‘i’ in the list)
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 127.
Parameterf
The operator to apply
Parameteri
The value to “start with”
Parameterl
The list to fold
Return
The result of the function applied left-associatively to the list.
Applies an operator left-associatively over a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 135.
Right-fold, assuming there is always one element, and leaving that element unchanged for single element lists. See foldr at silver:core/List.sv#115.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 147.
Parameterf
The fold function for combining an element and your accumulator
Parameteri
The last element function to apply to the last single element in your list
Parameterl
The list being folded over.
Return
An element that is the result of your combining functions applied to the list elements. Right-Fold, assuming there is always at least one element, and also takes in a function a->b to apply to the last element of a list, and applies that function to the last element.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 159.
Left-fold, assuming there is always one element, and leaving that element unchanged for single element lists. See foldl at silver:core/List.sv#127.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 171.
Parameterf
The filter function
Parameterlst
The input list to filter
Return
Only those elements of ‘lst’ that ‘f’ returns true for, in the same order as they appeared in ‘lst’
Filter out elements of a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 186.
Parameterf
The filter function
Parameterlst
The input list to filter
Return
Only those elements of ‘lst’ that ‘f’ returns true for, in the same order as they appeared in ‘lst’
Monadic (actually Applicative) version of filter
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 205.
Parameterf
Decision function
Parameterlst
The list to partition
Return
A pair of all elements returning true, and all elements returning false.
Partition a list in two
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 226.
Parametereq
The equality function to use
Parameterelem
The element to search for
Parameterlst
The list to search
Return
True if the equality function returns true for some element of the list, false otherwise.
Determine if an element appears in a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 236.
Parameterelem
The element to search for
Parameterlst
The list to search
Return
True if == is true for some element of the list, false otherwise.
Determine if an element appears in a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 245.
Parametereq
The equality function to use
Parameterxs
The list to remove duplicates from
Return
A list containing no duplicates, according to the equality function.
Removes all duplicates from a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 255.
Parameterxs
The list to remove duplicates from
Return
A list containing no duplicates, according to ==.
Removes all duplicates from a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 265.
Parametereq
The equality function to use
Parameterx
The element to remove
Parameterxs
The list to remove the element from
Return
A list with no remaining instances of ‘x’ according to ‘eq’
Removes all instances of an element from a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 276.
Parameterx
The element to remove
Parameterxs
The list to remove the element from
Return
A list with no remaining instances of ‘x’ according to ==
Removes all instances of an element from a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 286.
Parametereq
The equality function to use
Parameterys
The list of elements to remove
Parameterxs
The list to remove elements from
Return
A list with no remaining instances in ‘ys’ according to ‘eq’
Removes all instances of several elements from a list: xs - ys
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 297.
Parameterys
The list of elements to remove
Parameterxs
The list to remove elements from
Return
A list with no remaining instances in ‘ys’ according to ‘eq’
Removes all instances of several elements from a list: xs - ys
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 305.
Parameterlst
The list to examine
Return
The initial elements of ‘lst’. If ‘lst’ is empty, crash.
Returns the initial elements of a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 316.
Parameterlst
The list to examine
Return
The last element of ‘lst’. If ‘lst’ is empty, crash.
Returns the last element of a list.
Contained in grammar [silver:core]
. Defined at silver/core/List.sv line 456.
Inserts the separator in between all elements of the list.
Contained in grammar [silver:core]
. Defined at silver/core/Field.sv line 14.
See Wikipedia.
All types that are both a DivisionRing
and a CommutativeRing
are
automatically Field
s: the EuclideanRing
instance can choose leftDiv
or rightDiv
as its div
, const 0
as its mod
, and const 1
as its
degree
. (TODO: This and EuclideanRing
should be derivable based on that.)
Laws:
- Non-Zero Multiplicative Inverse:
mod(a, b) = zero
Contained in grammar [silver:core]
. Defined at silver/core/Group.sv line 10.
They’re from math. Yeah. See Wikipedia.
Laws:
- Left Cancellation:
append(invert(x), x) = mempty
- Right Cancellation:
append(x, invert(x)) = mempty
Contained in grammar [silver:core]
. Defined at silver/core/Group.sv line 17.
Computes the integer exponent of some group (treating the semigroup as multiplication, as is standard in algebra).
Contained in grammar [silver:core]
. Defined at silver/core/IO.sv line 11.
Representation of a monadic IO action.
The stateIn/stateOut threading exists to ensure that IO actions happen in the proper order, thus the invariant that stateOut should be demanded before stateVal. Note that unsafeInterleaveIO intentionally violates this, causing IO actions to be evaluated when their value is demanded.
Contained in grammar [silver:core]
. Defined at silver/core/IO.sv line 39.
Parameterfn
A function creating an IO action from its own result.
Create a self-referential IO action. Note that fn should be lazy in its argument, to avoid infinite recursion. This can be achieved using unsafeInterleaveIO.
Contained in grammar [silver:core]
. Defined at silver/core/IO.sv line 104.
Parameteri
An IO action to defer.
Defer an IO action to be lazily evaluated when its result value is demanded.
Contained in grammar [silver:core]
. Defined at silver/core/BooleanAlgebra.sv line 12.
This typeclass guarantees that a Heyting algebra behaves exactly like the booleans. It doesn’t provide any operators, but may be useful for algorithms.
Laws:
- Excluded Middle:
disj(x, not(x)) = true
- Inverse Excluded Middle:
conj(x, not(x)) = false
- Double Negation Elimination:
not(not(x)) = x
Contained in grammar [silver:core]
. Defined at silver/core/Alternative.sv line 15.
The Alt type class identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *, like Maybe or [], rather than concrete types String or [a].
Instances should satisfy the following:
Associativity alt(alt(x, y), z) == alt(x, alt(y, z)) Distributivity map(f, alt(x, y)) == alt(map(f, x), map(f, y))
Contained in grammar [silver:core]
. Defined at silver/core/Alternative.sv line 35.
The Plus type class extends the Alt type class with a value that should be the left and right identity for (<|>).
It is similar to Monoid, except that it applies to types of kind * -> *, like Array or List, rather than concrete types like String or Number.
Instances should satisfy the following laws:
Left identity alt(empty, x) == x Right identity alt(x, empty) == x Annihilation map(f, empty) == empty
Contained in grammar [silver:core]
. Defined at silver/core/Alternative.sv line 48.
The Alternative class is for members of Plus that are also Applicative functors, and specifies some additional laws:
Distributivity ap(alt(f, g), x) == alt(ap(f, x), ap(g, x)) Annihilation ap(empty, x) = empty
Contained in grammar [silver:core]
. Defined at silver/core/Alternative.sv line 53.
Conditional failure of Alternative computations.
Contained in grammar [silver:core]
. Defined at silver/core/ConvertablePrim.sv line 8.
Primitive types that can be converted into other primitive types.
This class provides the overloaded toString, toInteger, toFloat and toBoolean functions.
Contained in grammar
[silver:core]
. Defined at silver/core/ConvertablePrim.sv line 10.Convert a value into a String
Contained in grammar
[silver:core]
. Defined at silver/core/ConvertablePrim.sv line 13.Convert a value into an Integer
Contained in grammar
[silver:core]
. Defined at silver/core/ConvertablePrim.sv line 16.Convert a value into a Float
Contained in grammar
[silver:core]
. Defined at silver/core/ConvertablePrim.sv line 19.Convert a value into a Boolean
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 13.
Parameters
The string to compute the length of.
Return
The length of the string.
Compute the length of a string.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 28.
Parametersep
The separator to place between each string.
Parameterlst
The list of string to collapse.
Return
The combined string.
Fold a list of strings into one string, by interspersing a separator.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 43.
Parametersep
The separator between each of the resulting strings.
Parameterstr
The original string.
Return
The list of strings separated by sep in the original string.
Split a string into a list of strings by a separator. If the separtor is the empty string then the string is split into single character strings.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 71.
Parameterneedle
The string to find.
Parameterhaystack
The string to find it in.
Return
The index the string occurs at, or -1 if not found.
Find the index of a needle in the haystack. (Indices are 0-based.)
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 86.
Parameterneedle
The string to find.
Parameterhaystack
The string to find it in.
Return
The index the string occurs at, or -1 if not found.
Find the LAST index of a needle in the haystack. (Indices are 0-based.)
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 102.
Parameterstart
The 0-based index to start at. Inclusive.
Parameterendl
The 0-based index to end before. (Exclusive.)
Parameterstr
The original string.
Return
The resulting substring.
Return a substring of the original. Indices are 0-based.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 117.
Parameterpre
The prefix.
Parameters
The string to check the prefix of.
Return
true if pre is a prefix of s. false otherwise.
Tests if one string is a prefix of another
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 132.
Parameterpost
The postfix.
Parameters
The string to check the postfix of.
Return
true if post is a postfix of s. false otherwise.
Tests if one string is a postfix of another
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 148.
Parametersearch
The string to replace
Parameterreplace
The string to substitute in
Parameterstr
The string to operate on
Return
The modified form of ‘str’
Replaces all instances of ‘search’ with ‘replace’ in ‘str’
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 163.
Parametern
The number of times to repeat the string
Parameters
The string to repeat
Return
The string with ‘n’ copies of ’s'
Return a string with ’s' repeated ‘n’ times.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 178.
Parameterstr
The string to check
Return
true if all characters are digits. false otherwise.
Tests if all characters of a string are digits. Partially unicode aware. See java’s Character.isDigit(char).
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 193.
Parameterstr
The string to check
Return
true if all characters are letters. false otherwise.
Tests if all characters of a string are letters. Partially unicode aware. See java’s Character.isLetter(char).
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 210.
Parameterstr
The string to check
Return
true if all characters are whitespace. false otherwise.
Tests if all characters of a string are whitespace. Partially unicode aware. See java’s Character.isWhitespace(char).
Includes space, tab, newline, carriage return, and more.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 225.
Parameterstr
The string to check
Return
true if all characters are lower case. false otherwise.
Tests if all characters of a string are lower case. Partially unicode aware. See java’s Character.isLowerCase(char).
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 240.
Parameterstr
The string to check
Return
true if all characters are upper case. false otherwise.
Tests if all characters of a string are upper case. Partially unicode aware. See java’s Character.isUpperCase(char).
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 255.
Parameterstr
The string to convert
Return
The converted integer wrapped in just, or nothing if the conversion failed (e.g. not a number, or the number was too large)
Safely converts a string to an integer.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 266.
String append. Use overloaded append or ++ instead.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 279.
Converts a list of code points to a string. Note that due to Java’s use of UCS-2, code points greater than 0xFFFF (i.e. and characters outside the Basic Multilingual Plane) aren’t supported.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 292.
Converts a string to a list of its UCS-2 characters. Note that this means that surrogate pairs are (probably?) not supported, and characters outside the Basic Multilingual Plane aren’t as a consequence.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 303.
Replace all special characters in a string with their escape sequences.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 314.
Replace all escape sequences in a string with corresponding special characters.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 325.
Strips extra leading and trailing whitespace from a string.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 362.
Strips all whitespace from a string.
Contained in grammar [silver:core]
. Defined at silver/core/String.sv line 380.
Adds line numbers to a string
Contained in grammar [silver:core]
. Defined at silver/core/Functor.sv line 13.
A type f is a Functor if it provides a function map which, given any types a and b lets you apply any function from (a -> b) to turn an f into an f, preserving the structure of f. Furthermore f needs to adhere to the following:
Identity map(id, x) == x Composition map(compose(f, g), x) == map(f, map(g, x))
Contained in grammar [silver:core]
. Defined at silver/core/Either.sv line 19.
The basic sum type, counterpart to Pair.
Occasionally used as a poor-quality “result or error” type.
By convention, the error type is the FIRST type, and the
expected return value is the second.
e.g. Either<String Tree>
Inspect it’s state with isLeft::Boolean and isRight::Boolean, and access it’s state with fromLeft::a, fromRight::b (which panic if incorrect)
Contained in grammar [silver:core]
. Defined at silver/core/Either.sv line 25.
Left case for Either.
Contained in grammar [silver:core]
. Defined at silver/core/Either.sv line 37.
Right case for Either.
Contained in grammar [silver:core]
. Defined at silver/core/Either.sv line 111.
Parametere
The “error” result type, corresponding to the left constructor
Parameterm
The monad type to be transformed
Parametera
The “success” result type, corresponding to the right constructor
Monad transformer corresponding to Either.
Note that the type arguments are in this order because Silver type
constructors are curried and must be partially applied in order, and we need to have
instance Functor MaybeT
Contained in grammar [silver:core]
. Defined at silver/core/Either.sv line 121.
Transform the computation inside an EitherT.
Contained in grammar [silver:core]
. Defined at silver/core/Either.sv line 149.
Return an “error” result. This is analagous to left for Either, as pure is analagous to right for Either.
Contained in grammar [silver:core]
. Defined at silver/core/Either.sv line 191.
Order preserving partitioning of a list of eithers into a pair of lists of the two different results.
Contained in grammar [silver:core]
. Defined at silver/core/Either.sv line 209.
Parametere
The either being discriminated
Parametero
The fallback value
Returns the left value, or the default if there is no left value.
Contained in grammar [silver:core]
. Defined at silver/core/Either.sv line 221.
Parametere
The either being discriminated
Parametero
The fallback value
Returns the right value, or the default if there is no right value.
Contained in grammar [silver:core]
. Defined at silver/core/Applicative.sv line 19.
Applicative functors extend Apply with a means to lift a value of type a into an f; thus together with the apply operation, it is possible to lift a function of artibrary arity to work on values wrapped in the type constructor f.
Instances should satisfy the following:
Identity ap(pure(id), x) = x Composition ap(ap(ap(pure(compose), f), g), h) = ap(ap(f, g), h) Homomorphism ap(pure(f), pure(x)) = pure(f(x)) Interchange ap(u, pure(y)) = ap(pure(\f -> f(y)), u)
Contained in grammar [silver:core]
. Defined at silver/core/Applicative.sv line 27.
Prefer map
to this function. However, it can be useful to get a Functor
instance for free, given an existing Applicative
instance.
Contained in grammar [silver:core]
. Defined at silver/core/Undecorate.sv line 9.
Parameterx
The reference to undecorate.
Return
A new, undecorated term coresponding to x.
Undecorate a reference.
Contained in grammar [silver:core]
. Defined at silver/core/Undecorate.sv line 22.
Parameterx
The reference to undecorate.
Return
A new, undecorated term coresponding to x.
Undecorate a unique reference.
Contained in grammar [silver:core]
. Defined at silver/core/Undecorate.sv line 35.
Parameterx
The reference to cast.
Return
x, with a type that has a different reference set.
Type-safe cast of one decorated type into one with a smaller reference set.
Contained in grammar [silver:core]
. Defined at silver/core/Undecorate.sv line 52.
Parameterx
The reference to undecorate.
Return
The term that was decorated to produce x.
Given a decorated tree, return the underlying term that was decorated to create it, without copying or applying any transformations. This is unsafe as it constitutes a hole in the uniqueness analysis, and should not be used outside of debugging and internally within Silver in the implementation of annotation accesses; use new if you want to undecorate a term.
Contained in grammar [silver:core]
. Defined at silver/core/Monoid.sv line 17.
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:
Right identity append(x, mempty) = x Left identity append(mempty, x) = x Associativity append(x, append(y, z)) = append(append(x, y), z) (Semigroup law) Concatenation concat = foldr(append, mempty, _)
Minimal complete definition: mempty
Contained in grammar [silver:core]
. Defined at silver/core/Monoid.sv line 46.
Parameterf
A function to apply to each element of a list, returning a monoid.
Parameterlst
A list
Return
The combined list
Map a function over a list, and then concatenates the results together.
Contained in grammar [silver:core]
. Defined at silver/core/Monoid.sv line 54.
Computes the integer exponent of some monoid (treating the semigroup as multiplication, as is standard in algebra).
Note that for negative n
, this errors out. If your type is a Group
, use
power
instead.
Contained in grammar [silver:core]
. Defined at silver/core/Bind.sv line 12.
Extends the Apply type class with a “bind” operation that composes computations in sequence, using the return value of one computation to determine the next computation.
Instances should satisfy the following:
Associativity bind(bind(x, f), g) = bind(x, \k -> bind(f(k), g))
Contained in grammar [silver:core]
. Defined at silver/core/CommutativeRing.sv line 9.
A typeclass for types where multiplication is guaranteed to be commutative.
Laws:
- Commutativity of Multiplication:
mul(x, y) = mul(y, x)
Contained in grammar [silver:core]
. Defined at silver/core/EuclideanRing.sv line 15.
Provides the /
and %
operators.
Laws:
- Integral Domain (TODO: are these equivalent?):
one != zero
(a != zero && b != zero) -> mul(a, b) != zero
- Non-negativity of
degree
:degree(x) >= 0
- Quotient:
(b != zero) -> (add(mul(div(a, b), b), mod(a, b)) = a)
degree
-mod
interaction:(b != zero) -> (mod(a, b) = 0 || degree(mod(a, b)) < degree(b))
degree
-mul
interaction:(a != zero && b != zero) -> (degree(a) <= degree(mul(a, b)))
Contained in grammar [silver:core]
. Defined at silver/core/EuclideanRing.sv line 58.
Computes the greatest common divisor of two numbers.
Contained in grammar [silver:core]
. Defined at silver/core/EuclideanRing.sv line 65.
Computes the least common multiple of two numbers.
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 12.
Origin info types
Single instances of the following are constructed once in OriginsUtil.java in the runtime and used to indicate when the origin information was computed.
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 14.Information was computed at the site of invoking a constructor (this is “normal”)
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 16.Result of calling new(x) on a tracked nonterminal (including children of x that were also new-ed)
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 23.Result of forwarding to a nonterminal. This is a little weird because there’s an extra indirection. The attached origin info has an origin pointing to the value that was computed for the production to forward to. At forwarding time (in evalForward) it’s copied and has an origin attached of this type. This is so that it’s possible to tell something was forwarded to.
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 25.Result of doing foo.bar (this is “normal”)
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 27.The origin was set when constructing a concrete production in the parser (will be a parsedOriginInfo)
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 29.The origin was set in something constructed in a parser action block
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 34.This is a catchall for stuff constructed in java (really only used in the SilverComparator and in the XML lib) where the java library dosen’t keep track of origins info meaningfully
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 36.This originates from something via a call to
reflect
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 38.This originates from it’s reflective representation via a call to
reify
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 43.This was constructed in
main
or in a function called frommain
without passing through a context with a meaningful nonterminal to use instead
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 45.This is a global
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 68.
OriginInfo represent the origin information contained in nodes/values.
originOriginInfo and originAndRedexOriginInfo are the same modulo if a redex is set or not
origin
is the node that this node originated from, originNotes
are
notes set on the control-flow path to where the origin was set.
redex
is the node that catalyzed the movement of this node to where it
is now (i.e. where a foo.bar
happaned that ‘moved’ the bar
in the new
tree. redexNotes
are similarly the notes set on the control-flow path to
where the tree motion that set the redex occurred.
newlyConstructed
is er
from the paper, and represents if the node
is not the result of a basically no-op transformation.
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 70.‘catchall’ for origins that don’t encode other info
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 72.The production originated from a sequence of tokens at
source
in Copper
Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 75.See above
abstract production originAndRedexOriginInfo
(OriginInfo ::= origin::a redex::b redexNotes::[OriginNote] newlyConstructed::Boolean
)Contained in grammar
[silver:core]
. Defined at silver/core/Origins.sv line 77.See above
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 96.
OriginNotes are various pieces of information associated with the origin of a term. A notepp can optionally be supplied, if the note should be displayed in stack traces and other diagnostic messages.
abstract production ruleLocNote
(top::OriginNote ::= attributeName::String sourceGrammar::String prod::String nt::String sourceLocation::Location
)
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 138.
Can be attached automatically by the compiler to show the control-flow path leading to where an origin was set. Actually pretty useful for debugging client code too.
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 146.
Compute the ‘chain’ of origins leading back to whatever the first thing without an origin (really without
an origin that has an origin
field.)
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 158.
Low level accessor for getting OriginInfo (maybe) from a node.
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 161.
Walk back to the first thing with an origin in the history of a
.
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 168.
Try to walk back to a parsedOriginInfo and extract the location the node came from in the source
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 205.
Dump out two objects in a format for svdraw2 to consume and draw their
structure and the origins links that connect them (and any intermediate
objects. The only difference between start
and stop
is that they will
be specially colored in the visualization diagram.)
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 242.
Useful for accessing the “ambient” origin, i.e., what origin does a created node get? Create one and find out!
Contained in grammar [silver:core]
. Defined at silver/core/Origins.sv line 249.
Call fn in a context where notes have been added to the origins context
Contained in grammar [silver:core]
. Defined at silver/core/Eq.sv line 21.
Eq represents equality/inequality relationships between data.
Laws are based on Haskell’s Eq type class:
Reflexivity x == x = true Symmetry x == y = y == x Transitivity if x == y && y == z = true, then x == z = true Substitutivity if x == y = true and f is a “public” function whose return type is an instance of Eq, then f x == f y = true Negation x != y = !(x == y)
Minimal complete definition: either == or !=.
Contained in grammar [silver:core]
. Defined at silver/core/Eq.sv line 161.
Compute the fixed point of a function by repeatedly applying it until its result remains constant.
Contained in grammar [silver:core]
. Defined at silver/core/Pair.sv line 9.
The basic product type, counterpart to Either.
Contained in grammar [silver:core]
. Defined at silver/core/Pair.sv line 26.
Parametereqf
The function to use to test for equality
Parameterelem
The element to look up
Parameterlst
The list of assocation pairs
Return
The first association pair found in the list, where the element equaled the first element of the pair.
Look up an element in an association list, using the specified equality function.
Contained in grammar [silver:core]
. Defined at silver/core/Pair.sv line 41.
Parameterelem
The element to look up
Parameterlst
The list of assocation pairs
Return
The first association pair found in the list, where the element equaled the first element of the pair.
Look up an element in an association list, using ==.
Contained in grammar [silver:core]
. Defined at silver/core/Pair.sv line 59.
Parameterlst
A list to decompose into two lists.
Decomposes a list of pairs into a pair of lists.
unzipPairs(zip(lst)) == lst