# The standard library¶

The DAML standard library is a collection of DAML modules that can be used to implement concrete applications.

## Usage¶

The standard library is included in the DAML compiler so it can be used straight out of the box. You can import modules from the standard library just like your own, for example:

```
import DA.Optional
import DA.Time
```

### Module Prelude¶

#### Typeclasses¶

**class Functor f where**A

`Functor`

is a typeclass for things that can be mapped over (using its`fmap`

function. Examples include`Optional`

,`[]`

and`Update`

).**fmap**: (a -> b) -> f a -> f b

`fmap`

takes a function of type`a -> b`

, and turns it into a function of type`f a -> f a`

, where`f`

is the type which is an instance of`Functor`

.For example,

`map`

is an`fmap`

that only works on lists. It takes a function`a -> b`

and a`[a]`

, and returns a`[b]`

.

**(<$)**: a -> f b -> f a

Replace all locations in the input

`f b`

with the same value`a`

. The default definition is`fmap . const`

, but you can override this with a more efficient version.

**class Bounded a where**Use the

`Bounded`

class to name the upper and lower limits of a type.You can derive an instance of the

`Bounded`

class for any enumeration type.`minBound`

is the first constructor listed in the`data`

declaration and`maxBound`

is the last.You can also derive an instance of

`Bounded`

for single-constructor data types whose constituent types are in`Bounded`

.`Ord`

is not a superclass of`Bounded`

because types that are not totally ordered can still have upper and lower bounds.**minBound**- : a

**maxBound**- : a

**class Enum a where**Use the

`Enum`

class to define operations on sequentially ordered types: that is, types that can be enumerated.`Enum`

members have defined successors and predecessors, which you can get with the`succ`

and`pred`

functions.Types that are an instance of class

`Bounded`

as well as`Enum`

should respect the following laws:- Both
`succ maxBound`

and`pred minBound`

should result in a runtime error. `fromEnum`

and`toEnum`

should give a runtime error if the result value is not representable in the result type. For example,`toEnum 7 : Bool`

is an error.`enumFrom`

and`enumFromThen`

should be defined with an implicit bound, like this:

enumFrom x = enumFromTo x maxBound enumFromThen x y = enumFromThenTo x y bound where bound | fromEnum y >= fromEnum x = maxBound | otherwise = minBound

**succ**: a -> a

Returns the successor of the given value. For example, for numeric types,

`succ`

adds 1.If the type is also an instance of

`Bounded`

,`succ maxBound`

results in a runtime error.

**pred**: a -> a

Returns the predecessor of the given value. For example, for numeric types,

`pred`

subtracts 1.If the type is also an instance of

`Bounded`

,`pred minBound`

results in a runtime error.

**toEnum**: Int -> a

Convert a value from an

`Int`

to an`Enum`

value: ie,`toEnum i`

returns the item at the`i`

th position of (the instance of)`Enum`

**enumFrom**: a -> [a]

Return a list of the

`Enum`

values starting at the`Int`

position. For example:`enumFrom 6 : [Int] = [6,7,8,9,...,maxBound : Int]`

**enumFromThen**: a -> a -> [a]

Returns a list of the

`Enum`

values with the first value at the first`Int`

position, the second value at the second`Int`

position, and further values with the same distance between them.For example:

`enumFromThen 4 6 : [Int] = [4,6,8,10...]`

`enumFromThen 6 2 : [Int] = [6,2,-2,-6,...,minBound :: Int]`

**enumFromTo**: a -> a -> [a]

Returns a list of the

`Enum`

values with the first value at the first`Int`

position, and the last value at the last`Int`

position.This is what’s behind the language feature that lets you write

`[n,m..]`

.For example:

`enumFromTo 6 10 : [Int] = [6,7,8,9,10]`

**enumFromThenTo**: a -> a -> a -> [a]

Returns a list of the

`Enum`

values with the first value at the first`Int`

position, the second value at the second`Int`

position, and further values with the same distance between them, with the final value at the final`Int`

position.This is what’s behind the language feature that lets you write

`[n,n'..m]`

.For example:

`enumFromThenTo 4 2 -6 : [Int] = [4,2,0,-2,-4,-6]`

`enumFromThenTo 6 8 2 : [Int] = []`

- Both

**class Additive a where**Use the

`Additive`

class for types that can be added. Instances have to respect the following laws:`(+)`

must be associative, ie:`(x + y) + z`

=`x + (y + z)`

`(+)`

must be commutative, ie:`x + y`

=`y + x`

`x + aunit`

=`x`

`negate`

gives the additive inverse, ie:`x + negate x`

=`aunit`

**(+)**: a -> a -> a

Add the two arguments together

**aunit**: a

The additive identity for the type. For example, for numbers, this is 0.

**(-)**: a -> a -> a

Subtract the second argument from the first argument, ie.

`x - y`

=`x + negate y`

**negate**: a -> a

Negate the argument:

`x + negate x`

=`aunit`

**class Multiplicative a where**Use the

`Multiplicative`

class for types that can be multiplied. Instances have to respect the following laws:`(*)`

is associative, ie:`(x * y) * z`

=`x * (y * z)`

`(*)`

is commutative, ie:`x * y`

=`y * x`

`x * munit`

=`x`

**(*)**: a -> a -> a

Multipy the arguments together

**munit**: a

The multiplicative identity for the type. For example, for numbers, this is 1.

**(^)**: a -> Int -> a

`x ^ n`

raises`x`

to the power of`n`

.

**class (Additive a, Multiplicative a) => Number a where**`Number`

is a class for numerical types. As well as the rules for`Additive`

and`Multiplicative`

, instances also have to respect the following laws:`(*)`

is distributive with respect to`(+)`

, ie:`a * (b + c)`

=`(a * b) + (a * c)`

and`(b + c) * a`

=`(b * a) + (c * a)`

**class Signed a where**The

`Signed`

is for the sign of a number.**signum**: a -> a

Sign of a number. For real numbers, the ‘signum’ is either

`-1`

(negative),`0`

(zero) or`1`

(positive).

**abs**: a -> a

The absolute value: that is, the value without the sign.

**class (Multiplicative a) => Fractional a where**Use the

`Fractional`

class for types that can be divided. Instances have to respect the following laws:- When
`recip x`

is defined, it must be the inverse of`x`

wrt`*`

, that is,`x * recip = munit`

- When
`recip y`

is defined, then`x / y = x * recip y`

**(/)**: a -> a -> a

`x / y`

divides`x`

by`y`

.

**recip**: a -> a

Calculates the reciprocal:

`recip x`

is`1/x`

.

- When

**class Show a where**Use the

`Show`

class for values that can be converted to a readable`Text`

value.Derived instances of

`Show`

have the following properties:- The result of
`show`

is a syntactically correct expression that only contains constants (given the fixity declarations in force at the point where the type is declared). It only contains the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
`showsPrec`

produces infix applications of the constructor. - If the precedence of the top-level constructor in
`x`

is less than`d`

(associativity is ignored), the representation will be enclosed in parentheses. For example, if`d`

is`0`

then the result is never surrounded in parentheses; if`d`

is`11`

it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
`show`

will produce the record-syntax form, with the fields given in the same order as the original declaration.

**showsPrec**: Int -> a -> ShowS

Convert a value to a readable

`Text`

value. Unlike`show`

,`showsPrec`

should satisfy the rule`showsPrec d x r ++ s == showsPrec d x (r ++ s)`

**show**: a -> Text

Convert a value to a readable

`Text`

value.

**showList**: [a] -> ShowS

Allows you to show lists of values.

- The result of

**class HasTime m where**The

`HasTime`

class is for where the time is available:`Scenario`

and`Update`

.**getTime**: m Time

Get the current time.

**class (Action m) => CanAbort m where**The

`CanAbort`

class is for`Action`

s that can be aborted.**abort**: Text -> m a

Abort the current action with a message.

**class (Functor f) => Applicative f where**

pure: a -> f a

Lift a value.

(<*>): f (a -> b) -> f a -> f b

Sequential application.

A few functors support an implementation of

`<*>`

that is more efficient than the default one.

liftA2: (a -> b -> c) -> f a -> f b -> f c

Lift a binary function to actions.

Some functors support an implementation of

`liftA2`

that is more efficient than the default one. In particular, if`fmap`

is an expensive operation, it is likely better to use`liftA2`

than to`fmap`

over the structure and then use`<*>`

.

(*>): f a -> f b -> f b

Sequence actions, discarding the value of the first argument.

(<*): f a -> f b -> f a

Sequence actions, discarding the value of the second argument.

**class (Applicative m) => Action m where**

(>>=): m a -> (a -> m b) -> m b

Sequentially compose two actions, passing any value produced by the first as an argument to the second.

**class (Action m) => ActionFail m where**

fail: Text -> m a

Fail with an error message.

**class Semigroup a where**The class of semigroups (types with an associative binary operation).

**(<>)**: a -> a -> a

An associative operation.

**class (Semigroup a) => Monoid a where**The class of monoids (types with an associative binary operation that has an identity).

**mempty**: a

Identity of

`(<>)`

**mconcat**: [a] -> a

Fold a list using the monoid. For example using

`mconcat`

on a list of strings would concatenate all strings to one lone string.

**class Template c where**

ensure: c -> Bool

Predicate that must hold for the succesful creation of the contract.

signatory: c -> [Party]

The signatories of a contract.

observer: c -> [Party]

The observers of a contract.

agreement: c -> Text

The agreement text of a contract.

**class (Template c) => Choice c e r where**

choiceController- : c -> e -> [Party]

choice- : c -> ContractId c -> e -> Update r

**class IsParties a where**Accepted ways to specify a list of parties: either a single party, or a list of parties.

**toParties**: a -> [Party]

Convert to list of parties.

**class (Template c) => TemplateKey c k where**

key: c -> k

The key of a contract.

maintainer: k -> [Party]

The maintainers of the contract key.

#### Data types¶

- type
**ShowS** - = Text -> Text
`showS`

should represent some text, and applying it to some argument should prepend the argument to the represented text.

data **[] a**

Documentation for lists

[]

::a [a]

data **Bool**

False

True

data **Constraint**

The kind of constraints, like`Show a`

data **Decimal**

data **Int**

A 64-bit integer.

data **Ordering**

Information about ordering

LT

EQ

GT

data **Symbol**

(Kind) This is the kind of type-level symbols. Declared here because class IP needs it

data **Text**

data **ContractId a**

The

`ContractId a`

type represents an id for a contract made from template`a`

. The id can be used to fetch the contract, among other things.

ContractIdOpaque

data **Date**

The

`Date`

type represents a date.

DateOpaque

data **Party**

The

`Party`

type represents a party to a contract.

PartyOpaque

data **Scenario a**

The

`Scenario`

type is used to simulate multi-party ledger interactions. The type`Scenario a`

describes a set of actions taken by various parties during the simulated scenario, before returning a value of type`a`

.

ScenarioOpaque

data **TextMap a**

The`TextMap a`

type represents an associative array from keys of type`Text`

to values of type`a`

.

data **Time**

The

`Time`

type represents a specific datetime in UTC, i.e. a date and a time in UTC.

TimeOpaque

data **Update a**

The

`Update a`

type represents an action to update or query the ledger, before returning a value of type`a`

.

UpdateOpaque

data **Down a**

The

`Down`

type can be used for reversing sorting order. For example,`sortOn (\x -> Down x.field)`

would sort by descending`field`

.

Downa

data **Optional a**

The

`Optional`

type encapsulates an optional value. A value of type`Optional a`

either contains a value of type`a`

(represented as`Some a`

), or it is empty (represented as`None`

). Using`Optional`

is a good way to deal with errors or exceptional cases without resorting to drastic measures such as`error`

.The

`Optional`

type is also a monad. It is a simple kind of error monad, where all errors are represented by`None`

. A richer error monad can be built using the`Data.Either.Either`

type.

None

Somea

data **Archive**

Archive

data **Consuming**

PreConsuming

PostConsuming

NonConsuming

#### Functions¶

**otherwise**- : Bool

**getTag**- : a -> Int#

**(++)**- : Text -> Text -> Text

**map**- : (a -> b) -> [a] -> [b]

**foldr**- : (a -> b -> b) -> b -> [a] -> b

**(.)**: (b -> c) -> (a -> b) -> a -> c

Function composition.

**const**: a -> b -> a

`const x`

is a unary function which evaluates to`x`

for all inputs.>>> const 42 "hello" 42

>>> map (const 42) [0..3] [42,42,42,42]

**eftInt**- : Int -> Int -> [Int]

**efdInt**- : Int -> Int -> [Int]

**efdtInt**- : Int -> Int -> Int -> [Int]

**efdtIntUp**- : Int -> Int -> Int -> [Int]

**go_up**- : Int -> Int -> Int -> [Int]

**efdtIntDn**- : Int -> Int -> Int -> [Int]

**go_dn**- : Int -> Int -> Int -> [Int]

**error**- : Text -> a

**(%)**: Int -> Int -> Int

`x % y`

calculates the remainder of`x`

by`y`

**showList__**- : (a -> ShowS) -> [a] -> ShowS

**showl**- : (a -> ShowS) -> [a] -> ShowS

**showParen**: Bool -> ShowS -> ShowS

utility function that surrounds the inner show function with parentheses when the ‘Bool’ parameter is ‘True’.

**showString**: Text -> ShowS

utility function converting a ‘String’ to a show function that simply prepends the string unchanged.

**showSpace**- : ShowS

**showCommaSpace**- : ShowS

**assert**: (CanAbort m) => Bool -> m ()

Check whether a condition is true, and otherwise abort.

**assertMsg**: (CanAbort m) => Text -> Bool -> m ()

Check whether a condition is true, and otherwise abort with a message.

**assertAfter**: (CanAbort m, HasTime m) => Time -> m ()

Check whether the given time is in the future, and otherwise abort.

**assertBefore**: (CanAbort m, HasTime m) => Time -> m ()

Check whether the given time is in the past, and otherwise abort.

**daysSinceEpochToDate**: Int -> Date

Convert number of days since epoc (i.e. the number of days since January 1, 1970) to a date.

**dateToDaysSinceEpoch**: Date -> Int

Convert a date to number of days epoch (i.e. the number of days since January 1, 1970).

**partyToText**: Party -> Text

Convert the

`Party`

to`Text`

, giving back what you passed to`getParty`

. Most users should stick to`show`

of the party instead, which also wraps the party in`'ticks'`

making it clear it was a`Party`

originally.

**partyFromText**: Text -> Optional Party

Converts a

`Text`

to`Party`

. It returns`None`

if the provided text contains any forbidden characters. See DAML-LF spec for a specification on which characters are allowed in parties. Note that this function accepts text*without*single quotes.Also note that this function does not perform any check on whether the provided text correspond to a party that “exists” on a given ledger: it merely converts the given

`Text`

to a`Party`

. The only way to guarantee that a given`Party`

exists on a given ledger is to involve it in a contract.This function, together with

`partyToText`

, forms an isomorphism between valid party strings and and parties. In other words, the following equations hold:∀ p. partyFromText (partyToText p) = Some p ∀ txt p. partyFromText txt = Some p ==> partyToText p = txt

This function will crash at runtime if you compile DAML to DAML-LF < 1.2.

**getParty**: Text -> Scenario Party

Get the party with the given name. Party names must be non-empty and only contain alphanumeric charaters, space,

`-`

(dash) or`_`

(underscore).

**submit**: Party -> Update a -> Scenario a

`submit p u`

describes the scenario in which party`p`

attempts to update the ledger with update action`u`

, and returns the value returned by the underlying update action. This scenario is considered a failure if the underlying update action fails.

**submitMustFail**: Party -> Update a -> Scenario ()

`submitMustFail`

describes the scenario in which party`p`

attempts to update the ledger with update action`u`

, but is expected to fail. This scenario is considered a failure if the underlying update action succeeds.

**scenario**: Scenario a -> Scenario a

Declare you are building a scenario.

**($)**- : (a -> b) -> a -> b

**curry**: ((a, b) -> c) -> a -> b -> c

Turn a function that takes a pair into a function that takes two arguments.

**uncurry**: (a -> b -> c) -> (a, b) -> c

Turn a function that takes two arguments into a function that takes a pair.

**(>>)**: (Applicative m) => m a -> m b -> m b

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.

**ap**: (Applicative f) => f (a -> b) -> f a -> f b

Synonym for

`<*>`

.

**return**: (Applicative m) => a -> m a

Inject a value into the monadic type.

**join**: (Action m) => m (m a) -> m a

Collapses nested actions into a single action.

**identity**: a -> a

The identity function.

**guard**- : (ActionFail m) => Bool -> m ()

**foldl**: (b -> a -> b) -> b -> [a] -> b

`foldl f i xs`

performs a left fold over`xs`

using`f`

with the starting value`i`

.Examples——–

>>> foldl (+) 0 [1,2,3] 6 >>> foldl (^) 10 [2,3] 1000000

**find**: (a -> Bool) -> [a] -> Optional a

`find p xs`

finds the first element of`xs`

where the predicate`p`

holds.

**length**: [a] -> Int

Calculate the length of a list.

**any**: (a -> Bool) -> [a] -> Bool

`any p xs`

is`True`

if`p`

holds for at least one element of`xs`

.

**all**: (a -> Bool) -> [a] -> Bool

`all p xs`

is`True`

if`p`

holds for every element of`xs`

.

**or**: [Bool] -> Bool

`or bs`

is`True`

if at least one element of`bs`

is`True`

.

**and**: [Bool] -> Bool

`and bs`

is`True`

if every element of`bs`

is`True`

.

**elem**: (Eq a) => a -> [a] -> Bool

`elem x xs`

is`True`

if`x`

is an element of the list`xs`

.

**notElem**: (Eq a) => a -> [a] -> Bool

Negation of

`elem`

.

**(<$>)**: (Functor f) => (a -> b) -> f a -> f b

Synonym for

`fmap`

.

**optional**: b -> (a -> b) -> Optional a -> b

The

`optional`

function takes a default value, a function, and a`Optional`

value. If the`Optional`

value is`None`

, the function returns the default value. Otherwise, it applies the function to the value inside the`Some`

and returns the result.Examples——–

Basic usage:

>>> optional False odd (Some 3) True

>>> optional False odd None False

Read an Int from a string using

`readOptional`

. If we succeed, return twice the Int; that is, apply`(*2)`

to it. If instead we fail to parse an Int, return`0`

by default:>>> import Text.Read ( readOptional ) >>> optional 0 (*2) (readOptional "5") 10 >>> optional 0 (*2) (readOptional "") 0

Apply

`show`

to a`Optional Int`

. If we have`Some n`

, we want to show the underlying`Int`

,`n`

. But if we have`None`

, we return the empty string instead of (for example)`None`

:>>> optional "" show (Some 5) "5" >>> optional "" show None ""

**either**: (a -> c) -> (b -> c) -> Either a b -> c

Case analysis for the

`Either`

type. If the value is`Left a`

, apply the first function to`a`

; if it is`Right b`

, apply the second function to`b`

.Examples——–

We create two values of type

`Either String Int`

, one using the`Left`

constructor and another using the`Right`

constructor. Then we apply “either” the`length`

function (if we have a`String`

) or the “times-two” function (if we have an`Int`

):>>> let s = Left "foo" :: Either String Int >>> let n = Right 3 :: Either String Int >>> either length (*2) s 3 >>> either length (*2) n 6

**concat**- : [[a]] -> [a]

**(++)**: [a] -> [a] -> [a]

Concatenate two lists.

**flip**: (a -> b -> c) -> b -> a -> c

Flip the order of the arguments of a two argument function.

**reverse**: [a] -> [a]

Reverse a list.

**mapA**: (Applicative m) => (a -> m b) -> [a] -> m [b]

Apply an applicative function to each element of a list.

**forA**: (Applicative m) => [a] -> (a -> m b) -> m [b]

`forA`

is`mapA`

with its arguments flipped.

**sequence**: (Applicative m) => [m a] -> m [a]

Perform a list of actions in sequence and collect the results.

**(=<<)**: (Action m) => (a -> m b) -> m a -> m b

`=<<`

is`>>=`

with its arguments flipped.

**concatMap**: (a -> [b]) -> [a] -> [b]

Map a function over each element of a list, and concatenate all the results.

**replicate**: Int -> a -> [a]

`replicate i x`

is the list`[x, x, x, ..., x]`

with`i`

copies of`x`

.

**take**: Int -> [a] -> [a]

Take the first

`n`

elements of a list.

**drop**: Int -> [a] -> [a]

Drop the first

`n`

elements of a list.

**splitAt**: Int -> [a] -> ([a], [a])

Split a list at a given index.

**takeWhile**: (a -> Bool) -> [a] -> [a]

Take elements from a list while the predicate holds.

**dropWhile**: (a -> Bool) -> [a] -> [a]

Drop elements from a list while the predicate holds.

**span**: (a -> Bool) -> [a] -> ([a], [a])

`span p xs`

is equivalent to`(takeWhile p xs, dropWhile p xs)`

.

**break**: (a -> Bool) -> [a] -> ([a], [a])

Break a list into two, just before the first element where the predicate holds.

`break p xs`

is equivalent to`span (not . p) xs`

.

**lookup**: (Eq a) => a -> [(a, b)] -> Optional b

Look up the first element with a matching key.

**enumerate**: (Enum a, Bounded a) => [a]

Generate a list containing all values of a given enumeration.

**zip**: [a] -> [b] -> [(a, b)]

`zip`

takes two lists and returns a list of corresponding pairs. If one list is shorter, the excess elements of the longer list are discarded.

**zip3**: [a] -> [b] -> [c] -> [(a, b, c)]

`zip3`

takes three lists and returns a list of triples, analogous to`zip`

.

**zipWith**: (a -> b -> c) -> [a] -> [b] -> [c]

`zipWith`

generalises`zip`

by combining elements using the function, instead of making pairs. If one list is shorter, the excess elements of the longer list are discarded.

**zipWith3**: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]

`zipWith3`

generalises`zip3`

by combining elements using the function, instead of making pairs.

**unzip**: [(a, b)] -> ([a], [b])

Turn a list of pairs into a pair of lists.

**unzip3**: [(a, b, c)] -> ([a], [b], [c])

Turn a list of triples into a triple of lists.

**traceRaw**: Text -> a -> a

`traceRaw msg a`

prints`msg`

and returns`a`

, for debugging purposes.

**trace**: (Show b) => b -> a -> a

`trace b a`

prints`b`

and returns`a`

, for debugging purposes.

**traceId**: (Show b) => b -> b

`traceId a`

prints`a`

and returns`a`

, for debugging purposes.

**debug**: (Show b, Applicative m) => b -> m ()

`debug x`

prints`x`

for debugging purposes.

**fst**: (a, b) -> a

Return the first element of a pair.

**snd**: (a, b) -> b

Return the second element of a pair.

**truncate**: Decimal -> Int

`truncate x`

rounds`x`

toward zero.

**intToDecimal**: Int -> Decimal

Convert an

`Int`

to a`Decimal`

.

**roundBankers**: Int -> Decimal -> Decimal

Bankers’ Rounding:

`roundBankers dp x`

rounds`x`

to`dp`

decimal places, where a`.5`

is rounded to the nearest even digit.

**roundCommercial**: Int -> Decimal -> Decimal

Commercial Rounding:

`roundCommercial dp x`

rounds`x`

to`dp`

decimal places, where a`.5`

is rounded away from zero.

**round**: Decimal -> Int

Round to nearest integer, where a

`.5`

is rounded away from zero.

**floor**: Decimal -> Int

Round down to nearest integer.

**ceiling**: Decimal -> Int

Round up to nearest integer.

**null**: [a] -> Bool

`null xs`

is true if`xs`

is the empty list.

**filter**: (a -> Bool) -> [a] -> [a]

Keep only the elements where the predicate holds.

**sum**: (Additive a) => [a] -> a

Calculate the sum over all elements

**product**: (Multiplicative a) => [a] -> a

Calculate the product over all elements

**create**: (Template c) => c -> Update (ContractId c)

Create a contract based on a template.

**exercise**: ContractId c -> e -> Update r

Exercise a contract choice.

**fetch**: (Template c) => ContractId c -> Update c

Fetch the contract data associated with the given contract id. This fails and aborts the entire transaction if the

`ContractId c`

supplied is not the contract ID of an active contract.

**archive**: (Template c) => ContractId c -> Update ()

Archive the contract.

**stakeholder**: (Template c) => c -> [Party]

The stakeholders of a contract, i.e. its signatories and observers.

**lookupByKey**: k -> Update (Optional (ContractId c))

Look up the contract id associated with a given contract key.

The

`c`

needs to be passed using an explicit type application. For instance, if you want to look up a contract of template`Account`

by its key`k`

, you must call`lookupByKey @Account k`

.

**fetchByKey**: k -> Update (ContractId c, c)

Fetch the contract id and contract data associated with a given contract key.

The

`c`

needs to be passed using an explicit type application. For instance, if you want to fetch a contract of template`Account`

by its key`k`

, you must call`fetchByKey @Account k`

.

**exerciseByKey**: k -> e -> Update r

Exercise a choice on a contract given by its key.

The

`c`

needs to be passed using an explicit type application. For instance, if you want to exercise a choice`Withdraw`

on a contract of template`Account`

given by its key`k`

, you must call`exerciseByKey @Account k Withdraw`

.

### Module Control.Exception.Base¶

#### Functions¶

**recSelError**- : Text -> r

**absentSumFieldError**- : a

**untangle**- : Text -> Text -> Text

**append**- : Text -> Text -> Text

**break**- : (a -> Bool) -> [a] -> ([a], [a])

### Module DA.Action¶

Action

#### Functions¶

**when**: (Applicative f) => Bool -> f () -> f ()

Conditional execution of

`Action`

expressions. For example,when final (archive contractId)

will archive the contract

`contractId`

if the Boolean value`final`

is`True`

, and otherwise do nothing.This function has short-circuiting semantics, i.e., when both arguments are present and the first arguments evaluates to

`False`

, the second argument is not evaluated at all.

**unless**: (Applicative f) => Bool -> f () -> f ()

The reverse of

`when`

.This function has short-circuiting semantics, i.e., when both arguments are present and the first arguments evaluates to

`False`

, the second argument is not evaluated at all.

**foldrA**: (Action m) => (a -> b -> m b) -> b -> [a] -> m b

The

`foldrA`

is analogous to`foldr`

, except that its result is encapsulated in an action. Note that`foldrA`

works from right-to-left over the list arguments.

**foldr1A**: (Action m) => (a -> a -> m a) -> [a] -> m a

`foldr1A`

is like`foldrA`

but raises an error when presented with an empty list argument.

**foldlA**: (Action m) => (b -> a -> m b) -> b -> [a] -> m b

`foldlA`

is analogous to`foldl`

, except that its result is encapsulated in an action. Note that`foldlA`

works from left-to-right over the list arguments.

**foldl1A**: (Action m) => (a -> a -> m a) -> [a] -> m a

The

`foldl1A`

is like`foldlA`

but raises an errors when presented with an empty list argument.

**replicateA**: (Applicative m) => Int -> m a -> m [a]

`replicateA n act`

performs the action`n`

times, gathering the results.

### Module DA.Assert¶

Assert

#### Functions¶

**(===)**: (CanAbort m, Show a, Eq a) => a -> a -> m ()

Check two values for equivalence and fail with a message if they are not.

**assertAfterMsg**: (CanAbort m, HasTime m) => Text -> Time -> m ()

Check whether the given time is in the future, and otherwise abort with a message.

**assertBeforeMsg**: (CanAbort m, HasTime m) => Text -> Time -> m ()

Check whether the given time is in the past, and otherwise abort with a message.

### Module DA.Bifunctor¶

#### Typeclasses¶

**class Bifunctor p where**A bifunctor is a type constructor that takes two type arguments and is a functor in /both/ arguments. That is, unlike with ‘Functor’, a type constructor such as ‘Either’ does not need to be partially applied for a ‘Bifunctor’ instance, and the methods in this class permit mapping functions over the ‘Left’ value or the ‘Right’ value, or both at the same time.

Intuitively it is a bifunctor where both the first and second arguments are covariant.

You can define a ‘Bifunctor’ by either defining ‘bimap’ or by defining both ‘first’ and ‘second’.

If you supply ‘bimap’, you should ensure that:

@’bimap’ ‘identity’ ‘identity’ ≡ ‘identity’@

If you supply ‘first’ and ‘second’, ensure:

@ ‘first’ ‘identity’ ≡ ‘identity’ ‘second’ ‘identity’ ≡ ‘identity’ @

If you supply both, you should also ensure:

@’bimap’ f g ≡ ‘first’ f ‘.’ ‘second’ g@

These ensure by parametricity:

@ ‘bimap’ (f ‘.’ g) (h ‘.’ i) ≡ ‘bimap’ f h ‘.’ ‘bimap’ g i ‘first’ (f ‘.’ g) ≡ ‘first’ f ‘.’ ‘first’ g ‘second’ (f ‘.’ g) ≡ ‘second’ f ‘.’ ‘second’ g @

@since 4.8.0.0

**bimap**: (a -> b) -> (c -> d) -> p a c -> p b d

Map over both arguments at the same time.

@’bimap’ f g ≡ ‘first’ f ‘.’ ‘second’ g@

====

**Examples**> > > bimap toUpper (+1) (‘j’, 3) > > > (‘J’,4)

> > > bimap toUpper (+1) (Left ‘j’) > > > Left ‘J’

> > > bimap toUpper (+1) (Right 3) > > > Right 4

**first**: (a -> b) -> p a c -> p b c

Map covariantly over the first argument.

@’first’ f ≡ ‘bimap’ f ‘identity’@

====

**Examples**> > > first toUpper (‘j’, 3) > > > (‘J’,3)

> > > first toUpper (Left ‘j’) > > > Left ‘J’

**second**: (b -> c) -> p a b -> p a c

Map covariantly over the second argument.

@’second’ ≡ ‘bimap’ ‘identity’@

====

**Examples**> > > second (+1) (‘j’, 3) > > > (‘j’,4)

> > > second (+1) (Right 3) > > > Right 4

### Module DA.Date¶

#### Data types¶

data **DayOfWeek**

The

`DayOfWeek`

type represents one the seven days of the week.

Monday

Tuesday

Wednesday

Thursday

Friday

Saturday

Sunday

data **Month**

The

`Month`

type represents a month in the Gregorian calendar.

Jan

Feb

Mar

Apr

May

Jun

Jul

Aug

Sep

Oct

Nov

Dec

#### Functions¶

**addDays**: Date -> Int -> Date

Adjusts a date with given number of days.

**subDate**: Date -> Date -> Int

Returns number of days between two given dates.

**dayOfWeek**: Date -> DayOfWeek

Returns the day of week for given date

**fromGregorian**: (Int, Month, Int) -> Date

Constructs a

`Date`

from the triplet`(year, month, days)`

.

**toGregorian**: Date -> (Int, Month, Int)

Turn

`Date`

value into (year, month, day) triple, according to Gregorian calendar.

**date**: Int -> Month -> Int -> Date

`date (y, m, d)`

turns given year`y`

, month`m`

, and day`d`

into a`Date`

value.

**isLeapYear**: Int -> Bool

Calculate whethe the given year is a leap year.

**fromMonth**: Month -> Int

Get the number corresponding to given month. For example,

`Jan`

corresponds to`1`

,`Feb`

corresponds to`2`

, and so on.

**monthDayCount**: Int -> Month -> Int

Get number of days in month on given year, according to Gregorian calendar. This does not take historical calendar changes into account (for example, the moves from Julian to Gregorian calendar), but does count leap years.

**datetime**: Int -> Month -> Int -> Int -> Int -> Int -> Time

Constructs an instant using

`year`

,`month`

,`day`

,`hours`

,`minutes`

,`seconds`

.

**toDateUTC**: Time -> Date

Extracts UTC Date from UTC Time This function will truncate Time to Date, but in many cases it will not return the date you really want. The reason for this is that usually the source of Time would be getTime, and getTime returns UTC, and most likely the date you want is something local to a location or an exchange. Consequently the date retrieved this way would be yesterday if retrieved when the market opens in say Singapore.

**passToDate**: Date -> Scenario Time

Pass simulated scenario to given date.

### Module DA.Either¶

The Either type represents values with two possibilities.

It is sometimes used to represent a value which is either correct or an error; by convention the Left constructor is used to hold an error value and the Right constructor is used to hold a correct value (mnemonic: “right” also means correct).

#### Functions¶

**lefts**: [Either a b] -> [a]

Extracts all the

`Left`

elements.

**rights**: [Either a b] -> [b]

Extracts all the

`Right`

elements.

**partitionEithers**: [Either a b] -> ([a], [b])

Partitions a list of

`Either`

into two lists, the`Left`

and`Right`

elements respectively. Order is maintained.

**isLeft**: Either a b -> Bool

Return

`True`

if the given value is a`Left`

-value,`False`

otherwise.

**isRight**: Either a b -> Bool

Return

`True`

if the given value is a`Right`

-value,`False`

otherwise.

**fromLeft**: a -> Either a b -> a

Return the contents of a

`Left`

-value or a default value otherwise.

**fromRight**: b -> Either a b -> b

Return the contents of a

`Right`

-value or a default value otherwise.

**optionalToEither**: a -> Optional b -> Either a b

Convert a

`Optional`

value to an`Either`

value, using the supplied parameter as the`Left`

value if the`Optional`

is`None`

.

**eitherToOptional**: Either a b -> Optional b

Convert an

`Either`

value to a`Optional`

, dropping any value in`Left`

.

**maybeToEither**- : a -> Optional b -> Either a b

**eitherToMaybe**- : Either a b -> Optional b

### Module DA.Foldable¶

Class of data structures that can be folded to a summary value.
You typically would want to import this module qualified to avoid clashes with
functions defined in Prelude. Ie.:
```
`
import DA.Foldable qualified as F
`
```

#### Typeclasses¶

**class Foldable t where**Class of data structures that can be folded to a summary value.

**fold**: (Monoid m) => t m -> m

Combine the elements of a structure using a monoid.

**foldMap**: (Monoid m) => (a -> m) -> t a -> m

Combine the elements of a structure using a monoid.

**foldr**: (a -> b -> b) -> b -> t a -> b

Right-associative fold of a structure.

**foldl**: (b -> a -> b) -> b -> t a -> b

Left-associative fold of a structure.

**foldr1**: (a -> a -> a) -> t a -> a

A variant of foldr that has no base case, and thus should only be applied to non-empty structures.

**foldl1**: (a -> a -> a) -> t a -> a

A variant of foldl that has no base case, and thus should only be applied to non-empty structures.

**toList**: t a -> [a]

List of elements of a structure, from left to right.

**null**: t a -> Bool

Test whether the structure is empty. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.

**length**: t a -> Int

Returns the size/length of a finite structure as an

`Int`

. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.

**elem**: (Eq a) => a -> t a -> Bool

Does the element occur in the structure?

**sum**: (Additive a) => t a -> a

The sum function computes the sum of the numbers of a structure.

**product**: (Multiplicative a) => t a -> a

The product function computes the product of the numbers of a structure.

**minimum**: (Ord a) => t a -> a

The least element of a non-empty structure.

**maximum**: (Ord a) => t a -> a

The largest element of a non-empty structure.

#### Functions¶

**concat**: (Foldable t) => t [a] -> [a]

The concatenation of all the elements of a container of lists.

**and**: (Foldable t) => t Bool -> Bool

`and`

returns the conjunction of a container of Bools. For the result to be`True`

, the container must be finite;`False`

, however, results from a`False`

value finitely far from the left end.

**or**: (Foldable t) => t Bool -> Bool

`or`

returns the disjunction of a container of Bools. For the result to be`False`

, the container must be finite;`True`

, however, results from a`True`

value finitely far from the left end.

**any**: (Foldable t) => (a -> Bool) -> t a -> Bool

Determines whether any element of the structure satisfies the predicate.

**all**: (Foldable t) => (a -> Bool) -> t a -> Bool

Determines whether all elements of the structure satisfy the predicate.

### Module DA.Functor¶

The Functor class is used for types that can be mapped over.

#### Functions¶

**($>)**: (Functor f) => f a -> b -> f b

Replace all locations in the input (on the left) with the given value (on the right).

**(<&>)**: (Functor f) => f a -> (a -> b) -> f b

Map a function over a functor. Given a value

`as`

and a function`f`

,`as <&> f`

is`f <$> as`

. That is,`<&>`

is like`<$>`

but the arguments are in reverse order.

**void**: (Functor f) => f a -> f ()

Replace all the locations in the input with

`()`

.

### Module DA.Generics¶

Module : GHC.Generics Copyright : (c) Universiteit Utrecht 2010-2011, University of Oxford 2012-2014 License : see libraries/base/LICENSE

Maintainer : libraries@haskell.org Stability : internal Portability : non-portable

@since 4.6.0.0

If you’re using @GHC.Generics@, you should consider using the <http://hackage.haskell.org/package/generic-deriving> package, which contains many useful generic functions.

#### Typeclasses¶

**class Generic a rep where**Representable types of kind @*@. This class is derivable in DAML with the @DeriveGeneric@ flag on.

A ‘Generic’ instance must satisfy the following laws:

@ ‘from’ . ‘to’ ≡ ‘Prelude.id’ ‘to’ . ‘from’ ≡ ‘Prelude.id’ @ [DA] we replaced the type family @Rep a@ with a second type parameter of the class @rep@.

**from**: a -> rep x

Generic representation type type Rep a : Type -> Type – | Convert from the datatype to its representation from : a -> (Rep a) x – | Convert from the representation to the datatype to : (Rep a) x -> a Convert from the datatype to its representation

**to**: rep x -> a

Convert from the representation to the datatype

**class Generic1 f rep where**Representable types of kind

`* -> *`

(or kind`k -> *`

, when @PolyKinds@ is enabled). This class is derivable in GHC with the @DeriveGeneric@ flag on.A ‘Generic1’ instance must satisfy the following laws:

@ ‘from1’ . ‘to1’ ≡ ‘Prelude.id’ ‘to1’ . ‘from1’ ≡ ‘Prelude.id’ @ [DA] we replaced the type family @Rep1 f@ with a second type paremeter of the class @rep@.

**from1**: f a -> rep a

Generic representation type type Rep1 f : k -> Type – | Convert from the datatype to its representation from1 : f a -> (Rep1 f) a – | Convert from the representation to the datatype to1 : (Rep1 f) a -> f a | Convert from the datatype to its representation

**to1**: rep a -> f a

Convert from the representation to the datatype

#### Data types¶

data **:*: f g p**

P1

Field Type Description prodL1 f p prodR1 g p

data **:+: f g p**

L1f p

R1g p

data **:.: f g p**

Comp1

Field Type Description unComp1 f (g p)

data **Associativity**

Datatype to represent the associativity of a constructor

LeftAssociative

RightAssociative

NotAssociative

data **C**

Tag for M1: constructor

- type
**C1** - = M1 C
Type synonym for encoding meta-information for constructors

data **D**

Tag for M1: datatype

- type
**D1** - = M1 D
Type synonym for encoding meta-information for datatypes

data **DecidedStrictness**

The strictness that GHC infers for a field during compilation. Whereas there are nine different combinations of ‘SourceUnpackedness’ and ‘SourceStrictness’, the strictness that GHC decides will ultimately be one of lazy, strict, or unpacked. What GHC decides is affected both by what the user writes in the source code and by GHC flags. As an example, consider this data type:

@ data E = ExampleConstructor {-# UNPACK #-} !Int !Int Int @

- If compiled without optimization or other language extensions, then the fields of @ExampleConstructor@ will have ‘DecidedStrict’, ‘DecidedStrict’, and ‘DecidedLazy’, respectively.
- If compiled with @-XStrictData@ enabled, then the fields will have ‘DecidedStrict’, ‘DecidedStrict’, and ‘DecidedStrict’, respectively.
- If compiled with @-O2@ enabled, then the fields will have ‘DecidedUnpack’, ‘DecidedStrict’, and ‘DecidedLazy’, respectively.
@since 4.9.0.0

DecidedLazy

DecidedStrict

DecidedUnpack

data **Fixity**

Datatype to represent the fixity of a constructor. An infix | declaration directly corresponds to an application of ‘Infix’.

Prefix

InfixInfix0

data **FixityI**

This variant of ‘Fixity’ appears at the type level.

@since 4.9.0.0

PrefixI

InfixIInfixI0

data **Infix0**

Infix0

Field Type Description associativity Associativity fixity Int

data **InfixI0**

InfixI0

Field Type Description associativity Associativity fixity Nat

data **K1 i c p**

@since 4.9.0.0 deriving instance Applicative f => Applicative (Rec1 f)

—| @since 4.9.0.0 deriving instance Alternative f => Alternative (Rec1 f)

– | @since 4.9.0.0 instance Monad f => Monad (Rec1 f) where Rec1 x >>= f = Rec1 (x >>= a -> unRec1 (f a))

—| @since 4.9.0.0 deriving instance MonadPlus f => MonadPlus (Rec1 f)

– | @since 4.12.0.0 deriving instance Semigroup (f p) => Semigroup (Rec1 f p)

—| @since 4.12.0.0 deriving instance Monoid (f p) => Monoid (Rec1 f p) Constants, additional parameters and recursion of kind @*@

K1

Field Type Description unK1 c

data **M1 i c f p**

@since 4.12.0.0 instance Monoid c => Applicative (K1 i c) where pure _ = K1 mempty liftA2 = _ -> coerce (mappend :: c -> c -> c) (<*>) = coerce (mappend :: c -> c -> c) Meta-information (constructor names, etc.)

M1

Field Type Description unM1 f p

data **Meta**

Datatype to represent metadata associated with a datatype (@MetaData@), constructor (@MetaCons@), or field selector (@MetaSel@).

- In @MetaData n m p nt@, @n@ is the datatype’s name, @m@ is the module in which the datatype is defined, @p@ is the package in which the datatype is defined, and @nt@ is @’True@ if the datatype is a @newtype@.
- In @MetaCons n f s@, @n@ is the constructor’s name, @f@ is its fixity, and @s@ is @’True@ if the constructor contains record selectors.
- In @MetaSel mn su ss ds@, if the field uses record syntax, then @mn@ is ‘Just’ the record name. Otherwise, @mn@ is ‘Nothing’. @su@ and @ss@ are the field’s unpackedness and strictness annotations, and @ds@ is the strictness that GHC infers for the field.
@since 4.9.0.0

MetaDataMetaData0

MetaConsMetaCons0

MetaSelMetaSel0

data **MetaCons0**

MetaCons0

Field Type Description name Symbol fixity FixityI hasRecordSelectors Bool

data **MetaData0**

MetaData0

Field Type Description name Symbol module_ Symbol package Symbol isNewType Bool

data **MetaSel0**

MetaSel0

Field Type Description mbRecordName Optional Symbol sourceUnpackedness SourceUnpackedness sourceStrictness SourceStrictness

data **Nat**

data **Par1 p**

@since 4.9.0.0 instance Functor U1 where fmap _ _ = U1

—| @since 4.9.0.0 instance Applicative U1 where pure _ = U1 _ <*> _ = U1 liftA2 _ _ _ = U1 @since 4.9.0.0 instance Alternative U1 where empty = U1 _ <|> _ = U1

– | @since 4.9.0.0 instance Monad U1 where _ >>= _ = U1

—| @since 4.9.0.0 instance MonadPlus U1

– | @since 4.12.0.0 instance Semigroup (U1 p) where _ <> _ = U1

—| @since 4.12.0.0 instance Monoid (U1 p) where mempty = U1 Used for marking occurrences of the parameter

Par1

Field Type Description unPar1 p

data **R**

@since 4.9.0.0 instance (Applicative f, Applicative g) => Applicative (f :.: g) where pure x = Comp1 (pure (pure x)) Comp1 f <*> Comp1 x = Comp1 (liftA2 (<*>) f x) liftA2 f (Comp1 x) (Comp1 y) = Comp1 (liftA2 (liftA2 f) x y)

—| @since 4.9.0.0 instance (Alternative f, Applicative g) => Alternative (f :.: g) where empty = Comp1 empty (<|>) = coerce ((<|>) : f (g a) -> f (g a) -> f (g a)) : forall a . (f :.: g) a -> (f :.: g) a -> (f :.: g) a

– | @since 4.12.0.0 deriving instance Semigroup (f (g p)) => Semigroup ((f :.: g) p)

—| @since 4.12.0.0 deriving instance Monoid (f (g p)) => Monoid ((f :.: g) p) Constants of unlifted kinds

@since 4.9.0.0 data family URec (a : Type) (p : k) Used for marking occurrences of ‘Addr#’

@since 4.9.0.0 data instance URec (Ptr ()) (p : k) = UAddr { uAddr# : Addr# } deriving ( Eq – ^ @since 4.9.0.0 , Ord – ^ @since 4.9.0.0 , Functor – ^ @since 4.9.0.0 , Generic – ^ @since 4.9.0.0 , Generic1 – ^ @since 4.9.0.0 ) Used for marking occurrences of ‘Char#’

@since 4.9.0.0 data instance URec Char (p : k) = UChar { uChar# : Char# } deriving ( Eq – ^ @since 4.9.0.0 , Ord – ^ @since 4.9.0.0 , Show – ^ @since 4.9.0.0 , Functor – ^ @since 4.9.0.0 , Generic – ^ @since 4.9.0.0 , Generic1 – ^ @since 4.9.0.0 ) Used for marking occurrences of ‘Double#’

@since 4.9.0.0 data instance URec Double (p : k) = UDouble { uDouble# : Double# } deriving ( Eq – ^ @since 4.9.0.0 , Ord – ^ @since 4.9.0.0 , Show – ^ @since 4.9.0.0 , Functor – ^ @since 4.9.0.0 , Generic – ^ @since 4.9.0.0 , Generic1 – ^ @since 4.9.0.0 ) Used for marking occurrences of ‘Float#’

@since 4.9.0.0 data instance URec Float (p : k) = UFloat { uFloat# : Float# } deriving ( Eq, Ord, Show , Functor – ^ @since 4.9.0.0 , Generic , Generic1 – ^ @since 4.9.0.0 ) Used for marking occurrences of ‘Int#’

@since 4.9.0.0 data instance URec Int (p : k) = UInt { uInt# : Int# } deriving ( Eq – ^ @since 4.9.0.0 , Ord – ^ @since 4.9.0.0 , Show – ^ @since 4.9.0.0 , Functor – ^ @since 4.9.0.0 , Generic – ^ @since 4.9.0.0 , Generic1 – ^ @since 4.9.0.0 ) Used for marking occurrences of ‘Word#’

@since 4.9.0.0 data instance URec Word (p : k) = UWord { uWord# : Word# } deriving ( Eq – ^ @since 4.9.0.0 , Ord – ^ @since 4.9.0.0 , Show – ^ @since 4.9.0.0 , Functor – ^ @since 4.9.0.0 , Generic – ^ @since 4.9.0.0 , Generic1 – ^ @since 4.9.0.0 ) Type synonym for @’URec’ ‘Addr#’@

@since 4.9.0.0 type UAddr = URec (Ptr ()) | Type synonym for @’URec’ ‘Char#’@

@since 4.9.0.0 type UChar = URec Char Type synonym for @’URec’ ‘Double#’@

@since 4.9.0.0 type UDouble = URec Double Type synonym for @’URec’ ‘Float#’@

@since 4.9.0.0 type UFloat = URec Float Type synonym for @’URec’ ‘Int#’@

@since 4.9.0.0 type UInt = URec Int Type synonym for @’URec’ ‘Word#’@

@since 4.9.0.0 type UWord = URec Word Tag for K1: recursion (of kind @Type@)

- type
**Rec0** - = K1 R
Type synonym for encoding recursion (of kind @Type@)

data **Rec1 f p**

@since 4.9.0.0 instance Applicative Par1 where pure = Par1 (<*>) = coerce liftA2 = coerce @since 4.9.0.0 instance Monad Par1 where Par1 x >>= f = f x

—| @since 4.12.0.0 deriving instance Semigroup p => Semigroup (Par1 p)

– | @since 4.12.0.0 deriving instance Monoid p => Monoid (Par1 p) Recursive calls of kind

`* -> *`

(or kind`k -> *`

, when @PolyKinds@ is enabled)

Rec1

Field Type Description unRec1 f p

data **S**

Tag for M1: record selector

- type
**S1** - = M1 S
Type synonym for encoding meta-information for record selectors

data **SourceStrictness**

The strictness of a field as the user wrote it in the source code. For example, in the following data type:

@ data E = ExampleConstructor Int ~Int !Int @

The fields of @ExampleConstructor@ have ‘NoSourceStrictness’, ‘SourceLazy’, and ‘SourceStrict’, respectively.

@since 4.9.0.0

NoSourceStrictness

SourceLazy

SourceStrict

data **SourceUnpackedness**

The unpackedness of a field as the user wrote it in the source code. For example, in the following data type:

@ data E = ExampleConstructor Int {-# NOUNPACK #-} Int {-# UNPACK #-} Int @

The fields of @ExampleConstructor@ have ‘NoSourceUnpackedness’, ‘SourceNoUnpack’, and ‘SourceUnpack’, respectively.

@since 4.9.0.0

NoSourceUnpackedness

SourceNoUnpack

SourceUnpack

- type
**Type** - = *
The kind of types with values. For example @Int :: Type@. [DA] copied from ghc-prim/GHC/Types.hs. Usually set to type Type = TYPE ‘LiftedRep, but we only have one representation.

data **U1 p**

@since 4.12.0.0 instance Semigroup (V1 p) where v <> _ = v Unit: used for constructors without arguments

U1

data **V1 p**

Void: used for datatypes without constructors

#### Functions¶

**prec**: Fixity -> Int

Get the precedence of a fixity value.

### Module DA.Internal.Compatible¶

Our Prelude, extending WiredIn with things that don’t need special treatment.

#### Data types¶

- type
**Datetime** - = Time

- type
**Integer** - = Int

- type
**List a** - = [a]

- type
**Maybe** - = Optional

- type
**Monad** - = Action

- type
**MonadFail** - = ActionFail

- type
**Num** - = Number

- type
**String** - = Text

- type
**Tuple a b** - = (a, b)

- type
**Tuple3 a b c** - = (a, b, c)

#### Functions¶

**tuple**- : a -> b -> (a, b)

**tuple3**- : a -> b -> c -> (a, b, c)

**nil**- : [a]

**cons**- : a -> [a] -> [a]

**does**- : Party -> Update a -> Update a

**toText**- : (Show a) => a -> Text

**toInteger**- : Decimal -> Int

**mapU**- : (Applicative m) => (a -> m b) -> [a] -> m [b]

**forU**- : (Applicative m) => [a] -> (a -> m b) -> m [b]

**mapM**- : (Applicative m) => (a -> m b) -> [a] -> m [b]

**forM**- : (Applicative m) => [a] -> (a -> m b) -> m [b]

**commits**- : Party -> Update a -> Scenario a

**fails**- : Party -> Update a -> Scenario ()

**test**- : Scenario a -> Scenario a

**maybe**- : b -> (a -> b) -> Maybe a -> b

### Module DA.Internal.Desugar¶

Automatically imported qualified in every module.

### Module DA.Internal.RebindableSyntax¶

Automatically imported unqualified in every module.

### Module DA.Internal.Record¶

### Module DA.List¶

List

#### Functions¶

**sort**: (Ord a) => [a] -> [a]

The

`sort`

function implements a stable sorting algorithm. It is a special case of`sortBy`

, which allows the programmer to supply their own comparison function.Elements are arranged from lowest to highest, keeping duplicates in the order they appeared in the input (a stable sort).

**sortBy**: (a -> a -> Ordering) -> [a] -> [a]

The

`sortBy`

function is the non-overloaded version of`sort`

.

**sortOn**: (Ord k) => (a -> k) -> [a] -> [a]

Sort a list by comparing the results of a key function applied to each element.

`sortOn f`

is equivalent to`sortBy (comparing f)`

, but has the performance advantage of only evaluating`f`

once for each element in the input list. This is sometimes called the decorate-sort-undecorate paradigm.Elements are arranged from from lowest to highest, keeping duplicates in the order they appeared in the input.

**mergeBy**: (a -> a -> Ordering) -> [a] -> [a] -> [a]

Merge two sorted lists using into a single, sorted whole, allowing the programmer to specify the comparison function.

**combinePairs**: (a -> a -> a) -> [a] -> [a]

Combine elements pairwise by means of a programmer supplied function from two list inputs into a single list.

**foldBalanced1**: (a -> a -> a) -> [a] -> a

Fold a non-empty list in a balanced way. Balanced means that each element has approximately the same depth in the operator tree. Approximately the same depth means that the difference between maximum and minimum depth is at most 1. The accumulation operation must be associative and commutative in order to get the same result as

`foldl1`

or`foldr1`

.

**group**: (Eq a) => [a] -> [[a]]

The ‘group’ function groups equal elements into sublists such that the concatenation of the result is equal to the argument.

**groupBy**: (a -> a -> Bool) -> [a] -> [[a]]

The ‘groupBy’ function is the non-overloaded version of ‘group’.

**groupOn**: (Eq k) => (a -> k) -> [a] -> [[a]]

Similar to ‘group’, except that the equality is done on an extracted value.

**dedup**: (Ord a) => [a] -> [a]

`dedup l`

removes duplicate elements from a list. In particular, it keeps only the first occurence of each element. It is a special case of`dedupBy`

, which allows the programmer to supply their own equality test.`dedup`

is called`nub`

in Haskell.

**dedupBy**: (a -> a -> Ordering) -> [a] -> [a]

A version of

`dedup`

with a custom predicate.

**dedupOn**: (Ord k) => (a -> k) -> [a] -> [a]

A version of

`dedup`

where deduplication is done after applyng function. Example use:`dedupOn (.employeeNo) employees`

**dedupSort**: (Ord a) => [a] -> [a]

The

`dedupSort`

function sorts and removes duplicate elements from a list. In particular, it keeps only the first occurrence of each element.

**dedupSortBy**: (a -> a -> Ordering) -> [a] -> [a]

A version of

`dedupSort`

with a custom predicate.

**unique**: (Ord a) => [a] -> Bool

Returns True if and only if there are no duplicate elements in the given list.

**uniqueBy**: (a -> a -> Ordering) -> [a] -> Bool

A version of

`unique`

with a custom predicate.

**uniqueOn**: (Ord k) => (a -> k) -> [a] -> Bool

Returns True if and only if there are no duplicate elements in the given list after applyng function. Example use:

`assert $ uniqueOn (.employeeNo) employees`

**replace**: (Eq a) => [a] -> [a] -> [a] -> [a]

Given a list and a replacement list, replaces each occurance of the search list with the replacement list in the operation list.

**dropPrefix**: (Eq a) => [a] -> [a] -> [a]

Drops the given prefix from a list. It returns the original sequence if the sequence doesn’t start with the given prefix.

**dropSuffix**: (Eq a) => [a] -> [a] -> [a]

Drops the given suffix from a list. It returns the original sequence if the sequence doesn’t end with the given suffix.

**stripPrefix**: (Eq a) => [a] -> [a] -> Optional [a]

The

`stripPrefix`

function drops the given prefix from a list. It returns`None`

if the list did not start with the prefix given, or`Some`

the list after the prefix, if it does.

**stripSuffix**: (Eq a) => [a] -> [a] -> Optional [a]

Return the prefix of the second list if its suffix matches the entire first list.

**isPrefixOf**: (Eq a) => [a] -> [a] -> Bool

The

`isPrefixOf`

function takes two lists and returns`True`

if and only if the first is a prefix of the second.

**isSuffixOf**: (Eq a) => [a] -> [a] -> Bool

The

`isSuffixOf`

function takes two lists and returns`True`

if and only if the first list is a suffix of the second.

**isInfixOf**: (Eq a) => [a] -> [a] -> Bool

The

`isInfixOf`

function takes two lists and returns`True`

if and only if the first list is contained anywhere within the second.

**mapAccumL**: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])

The

`mapAccumL`

function combines the behaviours of`map`

and`foldl`

; it applies a function to each element of a list, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new list.

**inits**: [a] -> [[a]]

The

`inits`

function returns all initial segments of the argument, shortest first.

**intersperse**: a -> [a] -> [a]

The

`intersperse`

function takes an element and a list and “intersperses” that element between the elements of the list.

**intercalate**: [a] -> [[a]] -> [a]

`intercalate`

inserts the list`xs`

in between the lists in`xss`

and concatenates the result.

**tails**: [a] -> [[a]]

The

`tails`

function returns all final segments of the argument, longest first.

**dropWhileEnd**: (a -> Bool) -> [a] -> [a]

A version of

`dropWhile`

operating from the end.

**takeWhileEnd**: (a -> Bool) -> [a] -> [a]

A version of

`takeWhile`

operating from the end.

**transpose**: [[a]] -> [[a]]

The

`transpose`

function transposes the rows and columns of its argument.

**breakEnd**: (a -> Bool) -> [a] -> ([a], [a])

Break, but from the end.

**breakOn**: (Eq a) => [a] -> [a] -> ([a], [a])

Find the first instance of

`needle`

in`haystack`

. The first element of the returned tuple is the prefix of`haystack`

before`needle`

is matched. The second is the remainder of`haystack`

, starting with the match. If you want the remainder*without*the match, use`stripInfix`

.

**breakOnEnd**: (Eq a) => [a] -> [a] -> ([a], [a])

Similar to

`breakOn`

, but searches from the end of the string.The first element of the returned tuple is the prefix of

`haystack`

up to and including the last match of`needle`

. The second is the remainder of`haystack`

, following the match.

**linesBy**: (a -> Bool) -> [a] -> [[a]]

A variant of

`lines`

with a custom test. In particular, if there is a trailing separator it will be discarded.

**wordsBy**: (a -> Bool) -> [a] -> [[a]]

A variant of

`words`

with a custom test. In particular, adjacent separators are discarded, as are leading or trailing separators.

**head**: [a] -> a

Extract the first element of a list, which must be non-empty.

**tail**: [a] -> [a]

Extract the elements after the head of a list, which must be non-empty.

**last**: [a] -> a

Extract the last element of a list, which must be finite and non-empty.

**init**: [a] -> [a]

Return all the elements of a list except the last one. The list must be non-empty.

**foldl1**: (a -> a -> a) -> [a] -> a

Left associative fold of a list that must be non-empty.

**foldr1**: (a -> a -> a) -> [a] -> a

Right associative fold of a list that must be non-empty.

**repeatedly**: ([a] -> (b, [a])) -> [a] -> [b]

Apply some operation repeatedly, producing an element of output and the remainder of the list.

**delete**: (Eq a) => a -> [a] -> [a]

`delete x`

removes the first occurrence of`x`

from its list argument. For example,> delete "a" ["b","a","n","a","n","a"] ["b","n","a","n","a"]

It is a special case of ‘deleteBy’, which allows the programmer to supply their own equality test.

**deleteBy**: (a -> a -> Bool) -> a -> [a] -> [a]

The ‘deleteBy’ function behaves like ‘delete’, but takes a user-supplied equality predicate.

> deleteBy (<=) 4 [1..10] [1,2,3,5,6,7,8,9,10]

**(\)**: (Eq a) => [a] -> [a] -> [a]

The

`\\`

function is list difference (non-associative). In the result of`xs \\ ys`

, the first occurrence of each element of`ys`

in turn (if any) has been removed from`xs`

. Thus(xs ++ ys) \\ xs == ys

Note this function is

*O(n*m)*given lists of size*n*and*m*.

**(!!)**: [a] -> Int -> a

List index (subscript) operator, starting from 0. For example,

`xs !! 2`

returns the third element in`xs`

. Raises an error if the index is not suitable for the given list. The function has complexity*O(n)*where*n*is the index given, unlike in languages such as Java where array indexing is*O(1)*.

**elemIndex**: (Eq a) => a -> [a] -> Optional Int

Find index of element in given list. Will return

`None`

if not found.

**findIndex**: (a -> Bool) -> [a] -> Optional Int

Find index, given predicate, of first matching element. Will return

`None`

if not found.

**findIndex_**- : Int -> (a -> Bool) -> [a] -> Optional Int

### Module DA.List.Total¶

#### Functions¶

**head**- : (ActionFail m) => [a] -> m a

**tail**- : (ActionFail m) => [a] -> m [a]

**last**- : (ActionFail m) => [a] -> m a

**init**- : (ActionFail m) => [a] -> m [a]

**(!!)**- : (ActionFail m) => [a] -> Int -> m a

**foldl1**- : (ActionFail m) => (a -> a -> a) -> [a] -> m a

**foldr1**- : (ActionFail m) => (a -> a -> a) -> [a] -> m a

**foldBalanced1**- : (ActionFail m) => (a -> a -> a) -> [a] -> m a

### Module DA.Logic¶

Logic - Propositional calculus.

#### Data types¶

data **Formula t**

A

`Formula t`

is a formula in propositional calculus with propositions of type t.

Propositiont

`Proposition p`

is the formula p

NegationFormula tFor a formula f,

`Negation f`

is ¬f

Conjunction[Formula t]For formulas f1, …, fn,

`Conjunction [f1, ..., fn]`

is f1 ∧ … ∧ fn

Disjunction[Formula t]For formulas f1, …, fn,

`Disjunction [f1, ..., fn]`

is f1 ∧ … ∧ fn

#### Functions¶

**(&&&)**: Formula t -> Formula t -> Formula t

`&&&`

is the ∧ operation of the boolean algebra of formulas, to be read as “and”

**(|||)**: Formula t -> Formula t -> Formula t

`|||`

is the ∨ operation of the boolean algebra of formulas, to be read as “or”

**true**: Formula t

`true`

is the 1 element of the boolean algebra of formulas, represented as an empty conjunction.

**false**: Formula t

`false`

is the 0 element of the boolean algebra of formulas, represented as an empty disjunction.

**neg**: Formula t -> Formula t

`neg`

is the ¬ (negation) operation of the boolean algebra of formulas.

**conj**: [Formula t] -> Formula t

`conj`

is a list version of`&&&`

, enabled by the associativity of ∧.

**disj**: [Formula t] -> Formula t

`disj`

is a list version of`|||`

, enabled by the associativity of ∧.

**fromBool**: Bool -> Formula t

`fromBool`

converts`True`

to`true`

and`False`

to`false`

.

**toNNF**: Formula t -> Formula t

`toNNF`

transforms a formula to negation normal form (see https://en.wikipedia.org/wiki/Negation_normal_form).

**toDNF**: Formula t -> Formula t

`toDNF`

turns a formula into disjunctive normal form. (see https://en.wikipedia.org/wiki/Disjunctive_normal_form).

**traverse**: (Applicative f) => (t -> f s) -> Formula t -> f (Formula s)

An implementation of

`traverse`

in the usual sense.

**zipFormulas**: Formula t -> Formula s -> Formula (t, s)

`zipFormulas`

takes to formulas of same shape, meaning only propositions are different and zips them up.

**substitute**: (t -> Optional Bool) -> Formula t -> Formula t

`substitute`

takes a truth assignment and substitutes`True`

or`False`

into the respective places in a formula.

**reduce**: Formula t -> Formula t

`reduce`

reduces a formula as far as possible by:- Removing any occurrences of
`true`

and`false`

; - Removing directly nested Conjunctions and Disjunctions;
- Going to negation normal form.

- Removing any occurrences of

**isBool**: Formula t -> Optional Bool

`isBool`

attempts to convert a formula to a bool. It satisfies`isBool true == Right True`

and`toBool false == Right False`

. Otherwise, it returns`Left x`

, where`x`

is the input.

**interpret**: (t -> Optional Bool) -> Formula t -> Either (Formula t) Bool

`interpret`

is a version of`toBool`

that first substitutes using a truth function and then reduces as far as possible.

**substituteA**: (Applicative f) => (t -> f (Optional Bool)) -> Formula t -> f (Formula t)

`substituteA`

is a version of`substitute`

that allows for truth values to be obtained from an action.

**interpretA**: (Applicative f) => (t -> f (Optional Bool)) -> Formula t -> f (Either (Formula t) Bool)

`interpretA`

is a version of`interpret`

that allows for truth values to be obtained form an action.

### Module DA.Map¶

Map - A map is an associative array data type composed of a collection of key/value pairs such that, each possible key appears at most once in the collection.

#### Data types¶

data **Map k v**

The type of a

`Map`

from keys of type`k`

to values of type`v`

.

Map_internal[(k, v)]

#### Functions¶

**fromList**: (Ord k) => [(k, a)] -> Map k a

Create a map from a list of key/value pairs.

**fromListWith**: (Ord k) => (a -> a -> a) -> [(k, a)] -> Map k a

Create a map from a list of key/value pairs with a combining function. Examples:

fromListWith (<>) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "ab"), (5, "cba")] fromListWith (<>) [] == (empty : Map Int Text)

**fromListWithKey**: (Ord k) => (k -> a -> a -> a) -> [(k, a)] -> Map k a

Build a map from a list of key/value pairs with a combining function. Example:

let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")] fromListWithKey f [] == empty

**toList**: Map k v -> [(k, v)]

Convert the map to a list of key/value pairs where the keys are in ascending order.

**empty**: Map k v

The empty map.

**size**: Map k v -> Int

Number of elements in the map.

**null**: Map k v -> Bool

Is the map empty?

**lookup**: (Eq k, Ord k) => k -> Map k v -> Optional v

Lookup the value at a key in the map.

**member**: (Eq k, Ord k) => k -> Map k v -> Bool

Is the key a member of the map?

**filter**: (Eq k) => (k -> v -> Bool) -> Map k v -> Map k v

DEPRECATED: Use

`filterWithKey`

instead.

**filterWithKey**: (Eq k) => (k -> v -> Bool) -> Map k v -> Map k v

Filter all values that satisfy some predicate.

**delete**: (Eq k) => k -> Map k v -> Map k v

Delete a key and its value from the map. When the key is not a member of the map, the original map is returned.

**insert**: (Ord k) => k -> v -> Map k v -> Map k v

Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value.

**merge**: (Ord k) => (k -> a -> Optional c) -> (k -> b -> Optional c) -> (k -> a -> b -> Optional c) -> Map k a -> Map k b -> Map k c

Merge two maps.

**union**: (Ord k) => Map k a -> Map k a -> Map k a

The union of two maps, preferring the first map when equal keys are encountered.

### Module DA.Math¶

Math - Utility Math functions for Decimal The this library is designed to give good precision, typically giving 9 correct decimal places. The numerical algorithms run with many iterations to achieve that precision and are interpreted by the DAML runtime so they are not performant. Their use is not advised in performance critical contexts.

#### Data types¶

- type
**Sci** - = (Decimal, Int)
`Sci`

represents a number in scientific notation.`(x, n)`

is to be read as`x * 10^n`

.

#### Functions¶

**(**)**: Decimal -> Decimal -> Decimal

Take a power of a number Example:

`2.0 ** 2.0 == 4.0`

.

**exp**: Decimal -> Decimal

The exponential function. Example:

`exp 0.0 == 1.0`

**log**: Decimal -> Decimal

The natural logarithm. Example:

`log 10.0 == 2.30258509299`

**logBase**: Decimal -> Decimal -> Decimal

The logarithm of a number to a given base. Example:

`log 10.0 100.0 == 2.0`

**logt10k**: Decimal -> Decimal

`logt10k x`

calculates 10000.0 * ln(x). The reason for doing this is to preserve four additional decimal points for precision. The additive nature of`ln`

is used to decompose ln(x) == ln(10^m * 2^n * y) == m * ln(10) + n * ln(2) + ln(y) where 0.5 < y < 1.5.

**logt10kInner**: Int -> Decimal -> Decimal

`log10kInner n x`

approximates 10000 * ln(x) using n terms of the power series expansion of ln(x) = 2 * artanh((x - 1) / (x + 1))

**e10**: Decimal -> Int -> Decimal

`e10`

is used to shift the decimal point in decimal notation.`e10 x n == x * intToDecimal (10 ^ n)`

.

**to36dig**: Sci -> Sci

`to36dig`

tries to put a number in scientific notation in a form where the`x`

has order of magnitude 10^26. Given the fixed point NUMBER(38,10) format of`Decimal`

in DAML, this gives good precision with a little bit of room to multiply with numbers less than 100.

**expInner**: Decimal -> Decimal -> Decimal -> Sci

`expInner`

calculates the expansion 1 + x/n * (1 + x/(n+1) * (1 + x/(n+2) * …)) to a depth where t * x^k * n! / k! < 10^-10. The sole purpose is to calculate`exp = expInner 1.0 1.0`

In the most precision-preserving way.

**sin**: Decimal -> Decimal

`sin`

is the sine function

**cos**: Decimal -> Decimal

`cos`

is the cosine function

**tan**: Decimal -> Decimal

`tan`

is the tangent function

**pi**- : The number Pi

**cordic**: Int -> Decimal -> (Decimal, Decimal)

`cordic`

is an implementation of the CORDIC algorithm. See https://en.wikipedia.org/wiki/CORDIC`cordic n r == (sin(r), cos(r))`

computed to n iterations

**cordicInner**: Int -> Decimal -> (Decimal, Decimal) -> Decimal -> [Decimal] -> (Decimal, Decimal)

`cordicInner`

implements the inner loop of the CORDIC algorithm

### Module DA.Maybe.Total¶

#### Functions¶

**fromJust**- : (ActionFail m) => Optional a -> m a

**fromJustNote**- : (ActionFail m) => Text -> Optional a -> m a

### Module DA.Monoid¶

#### Data types¶

data **All**

Boolean monoid under conjunction (&&)

All

Field Type Description getAll Bool

data **Any**

Boolean Monoid under disjunction (||)

Any

Field Type Description getAny Bool

data **Endo a**

The monoid of endomorphisms under composition.

Endo

Field Type Description appEndo a -> a

### Module DA.Next.Map¶

Map - A Map is an associative array data type composed of a collection of key/value pairs such that each possible key appears at most once in the collection.

#### Typeclasses¶

**class (Eq k) => MapKey k where**A class for types that can be used as keys for the

`Map`

type. All keys`k`

must satisfy`keyFromText (keyToText k) == k`

.**keyToText**: k -> Text

Turn a key into its textual representation. This function must be injective.

**keyFromText**: Text -> k

Recover a key from its textual representation.

`keyFromText x`

is allowed to fail whenever there is*no*key`k`

with`keyToText k == x`

. Whenever such a`k`

does exist, then it must satisfy`keyFromText x == k`

.

#### Data types¶

data **Map k v**

A

`Map k v`

is an associative array data type composed of a collection of key/value pairs of key type`k`

and value type`v`

such that each possible key appears at most once in the collection.

Map

Field Type Description textMap TextMap v

#### Functions¶

**fromList**: (MapKey k) => [(k, v)] -> Map k v

Create a map from a list of key/value pairs.

**fromListWith**: (MapKey k) => (v -> v -> v) -> [(k, v)] -> Map k v

Create a map from a list of key/value pairs with a combining function. Examples:

fromListWith (<>) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "ba"), (5, "abc")] fromListWith (<>) [] == (empty : Map Int Text)

**toList**: (MapKey k) => Map k v -> [(k, v)]

Convert the map to a list of key/value pairs where the keys are in ascending order of their textual representation.

**fromTextMap**: TextMap v -> Map Text v

Create a

`Map`

from a`TextMap`

.

**toTextMap**: (MapKey k) => Map k v -> TextMap v

Convert a

`Map`

into a`TextMap`

.

**empty**: Map k v

The empty map.

**size**: Map k v -> Int

Number of elements in the map.

**null**: Map k v -> Bool

Is the map empty?

**lookup**: (MapKey k) => k -> Map k v -> Optional v

Lookup the value at a key in the map.

**member**: (MapKey k) => k -> Map k v -> Bool

Is the key a member of the map?

**filterWithKey**: (MapKey k) => (k -> v -> Bool) -> Map k v -> Map k v

Filter all values that satisfy some predicate.

**delete**: (MapKey k) => k -> Map k v -> Map k v

Delete a key and its value from the map. When the key is not a member of the map, the original map is returned.

**insert**: (MapKey k) => k -> v -> Map k v -> Map k v

Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value.

**union**: (MapKey k) => Map k v -> Map k v -> Map k v

The union of two maps, preferring the first map when equal keys are encountered.

**merge**: (MapKey k) => (k -> a -> Optional c) -> (k -> b -> Optional c) -> (k -> a -> b -> Optional c) -> Map k a -> Map k b -> Map k c

Merge two maps.

`merge f g h x y`

applies`f`

to all key/value pairs whose key only appears in`x`

,`g`

to all pairs whose key only appears in`y`

and`h`

to all pairs whose key appears in both`x`

and`y`

. In the end, all pairs yielding`Some`

are collected as the result.

### Module DA.Next.Set¶

Set - The Set a type represents a set of elements of type a. Most operations require that a be an instance of the MapKey type class.

#### Functions¶

**empty**: Set a

The empty set.

**size**: Set a -> Int

The number of elements in the set.

**toList**: (MapKey a) => Set a -> [a]

Convert the set to a list of elements.

**fromList**: (MapKey a) => [a] -> Set a

Create a set from a list of elements.

**toTextMap**: Set Text -> TextMap ()

Convert a

`Set`

into a`TextMap`

.

**fromTextMap**: TextMap () -> Set Text

Create a

`Set`

from a`TextMap`

.

**member**: (MapKey a) => a -> Set a -> Bool

Is the element in the set?

**null**: Set a -> Bool

Is this the empty set?

**insert**: (MapKey a) => a -> Set a -> Set a

Insert an element in a set. If the set already contains an element equal to the given value, it is replaced with the new value.

**filter**: (MapKey a) => (a -> Bool) -> Set a -> Set a

Filter all elements that satisfy the predicate.

**delete**: (MapKey a) => a -> Set a -> Set a

Delete an element from a set.

**singleton**: (MapKey a) => a -> Set a

Create a singleton set.

**union**: (MapKey a) => Set a -> Set a -> Set a

The union of two sets, preferring the first set when equal elements are encountered.

**intersection**: (MapKey a) => Set a -> Set a -> Set a

The intersection of two sets. Elements of the result come from the first set.

**difference**: (MapKey a) => Set a -> Set a -> Set a

Difference of two sets.

### Module DA.NonEmpty¶

Type and functions for non-empty lists. This module re-exports many functions with the same name as prelude list functions, so it is expected to import the module qualified. For example, with the following import list you will have access to the NonEmpty type and any functions on non-empty lists will be qualified, for example as NE.append, NE.map, NE.foldl:

```
`
import DA.NonEmpty (NonEmpty)
import qualified DA.NonEmpty as NE
`
```

#### Data types¶

data **NonEmpty a**

`NonEmpty`

is the type of non-empty lists. In other words, it is the type of lists that always contain at least one element. If`x`

is a non-empty list, you can obtain the first element with`x.hd`

and the rest of the list with`x.tl`

.

NonEmpty

Field Type Description hd a tl [a]

#### Functions¶

**append**: NonEmpty a -> NonEmpty a -> NonEmpty a

Append or concatenate two non-empty lists.

**map**: (a -> b) -> NonEmpty a -> NonEmpty b

Apply a function over each element in the non-empty list.

**nonEmpty**: [a] -> Optional (NonEmpty a)

Turn a list into a non-empty list, if possible. Returns

`None`

if the input list is empty, and`Some`

otherwise.

**singleton**: a -> NonEmpty a

A non-empty list with a single element.

**toList**: NonEmpty a -> [a]

Turn a non-empty list into a list (by forgetting that it is not empty).

**reverse**: NonEmpty a -> NonEmpty a

Reverse a non-empty list.

**foldl1**: (a -> a -> a) -> NonEmpty a -> a

Apply a function repeatedly to pairs of elements from a non-empty list, from the left. For example,

`foldl1 (+) (NonEmpty 1 [2,3,4]) = ((1 + 2) + 3) + 4`

.

**foldr1**: (a -> a -> a) -> NonEmpty a -> a

Apply a function repeatedly to pairs of elements from a non-empty list, from the right. For example,

`foldr1 (+) (NonEmpty 1 [2,3,4]) = 1 + (2 + (3 + 4))`

.

**foldr**: (a -> b -> b) -> b -> NonEmpty a -> b

Apply a function repeatedly to pairs of elements from a non-empty list, from the right, with a given initial value. For example,

`foldr (+) 0 (NonEmpty 1 [2,3,4]) = 1 + (2 + (3 + (4 + 0)))`

.

**foldrA**: (Action m) => (a -> b -> m b) -> b -> NonEmpty a -> m b

The same as

`foldr`

but running an action each time.

**foldr1A**: (Action m) => (a -> a -> m a) -> NonEmpty a -> m a

The same as

`foldr1`

but running an action each time.

**foldl**: (b -> a -> b) -> b -> NonEmpty a -> b

Apply a function repeatedly to pairs of elements from a non-empty list, from the left, with a given initial value. For example,

`foldl (+) 0 (NonEmpty 1 [2,3,4]) = (((0 + 1) + 2) + 3) + 4`

.

**foldlA**: (Action m) => (b -> a -> m b) -> b -> NonEmpty a -> m b

The same as

`foldl`

but running an action each time.

**foldl1A**: (Action m) => (a -> a -> m a) -> NonEmpty a -> m a

The same as

`foldl1`

but running an action each time.

### Module DA.Optional¶

The Optional type encapsulates an optional value. A value of type Optional a either contains a value of type a (represented as Some a), or it is empty (represented as None). Using Optional is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error.

The Optional type is also an action. It is a simple kind of error action, where all errors are represented by None. A richer error action can be built using the Either type.

#### Functions¶

**fromSome**: Optional a -> a

The

`fromSome`

function extracts the element out of a`Some`

and throws an error if its argument is`None`

.

**fromSomeNote**- : Text -> Optional a -> a

**catOptionals**: [Optional a] -> [a]

The

`catOptionals`

function takes a list of`Optionals`

and returns a list of all the`Some`

values.

**listToOptional**: [a] -> Optional a

The

`listToOptional`

function returns`None`

on an empty list or`Some`

a where a is the first element of the list.

**optionalToList**: Optional a -> [a]

The

`optionalToList`

function returns an empty list when given`None`

or a singleton list when not given`None`

.

**fromOptional**: a -> Optional a -> a

The

`fromOptional`

function takes a default value and a`Optional`

value. If the`Optional`

is`None`

, it returns the default values otherwise, it returns the value contained in the`Optional`

.

**isSome**: Optional a -> Bool

The

`isSome`

function returns`True`

iff its argument is of the form`Some _`

.

**isNone**: Optional a -> Bool

The

`isNone`

function returns`True`

iff its argument is`None`

.

**mapOptional**: (a -> Optional b) -> [a] -> [b]

The

`mapOptional`

function is a version of`map`

which can throw out elements. In particular, the functional argument returns something of type`Optional b`

. If this is`None`

, no element is added on to the result list. If it is`Some b`

, then`b`

is included in the result list.

**whenSome**: (Applicative m) => Optional a -> (a -> m ()) -> m ()

Perform some operation on

`Some`

, given the field inside the`Some`

.

### Module DA.Optional.Total¶

#### Functions¶

**fromSome**- : (ActionFail m) => Optional a -> m a

**fromSomeNote**- : (ActionFail m) => Text -> Optional a -> m a

### Module DA.Record¶

Exports the record machinery necessary to allow one to annotate code that is polymorphic in the underlying record type.

### Module DA.Set¶

Set - The Set e type represents a set of elements of type e. Most operations require that e be an instance of the Ord class.

#### Functions¶

**empty**: Set a

The empty set.

**size**: Set a -> Int

The number of elements in the set.

**toList**: Set a -> [a]

Convert the set to a list of elements.

**fromList**: (Ord a) => [a] -> Set a

Create a set from a list of elements.

**member**: (Ord a) => a -> Set a -> Bool

Is the element in the set?

**null**: Set a -> Bool

Is this the empty set?

**insert**: (Ord a) => a -> Set a -> Set a

Insert an element in a set. If the set already contains an element equal to the given value, it is replaced with the new value.

**filter**: (Eq a) => (a -> Bool) -> Set a -> Set a

Filter all elements that satisfy the predicate.

**delete**: (Eq a) => a -> Set a -> Set a

Delete an element from a set.

**singleton**: (Ord a) => a -> Set a

Create a singleton set.

**union**: (Ord a) => Set a -> Set a -> Set a

The union of two sets, preferring the first set when equal elements are encountered.

**intersection**: (Ord a) => Set a -> Set a -> Set a

The intersection of two sets. Elements of the result come from the first set.

**difference**: (Ord a) => Set a -> Set a -> Set a

Difference of two sets.

### Module DA.Text¶

Functions for working with Text.

#### Functions¶

**explode**- : Text -> [Text]

**implode**- : [Text] -> Text

**isEmpty**: Text -> Bool

Test for emptiness.

**length**: Text -> Int

Compute the number of symbols in the text.

**trim**: Text -> Text

Remove spaces from either side of the given text.

**replace**: Text -> Text -> Text -> Text

Replace a subsequence everywhere it occurs. The first argument must not be empty.

**lines**: Text -> [Text]

Breaks a

`Text`

value up into a list of`Text`

’s at newline symbols. The resulting texts do not contain newline symbols.

**unlines**: [Text] -> Text

Joins lines, after appending a terminating newline to each.

**words**: Text -> [Text]

Breaks a ‘Text’ up into a list of words, delimited by symbols representing white space.

**unwords**: [Text] -> Text

Joins words using single space symbols.

**linesBy**: (Text -> Bool) -> Text -> [Text]

A variant of

`lines`

with a custom test. In particular, if there is a trailing separator it will be discarded.

**wordsBy**: (Text -> Bool) -> Text -> [Text]

A variant of

`words`

with a custom test. In particular, adjacent separators are discarded, as are leading or trailing separators.

**intercalate**: Text -> [Text] -> Text

`intercalate`

inserts the text argument`t`

in between the items in`ts`

and concatenates the result.

**dropPrefix**: Text -> Text -> Text

`dropPrefix`

drops the given prefix from the argument. It returns the original text if the text doesn’t start with the given prefix.

**dropSuffix**: Text -> Text -> Text

Drops the given suffix from the argument. It returns the original text if the text doesn’t end with the given suffix. Examples:

dropSuffix "!" "Hello World!" == "Hello World" dropSuffix "!" "Hello World!!" == "Hello World!" dropSuffix "!" "Hello World." == "Hello World."

**stripSuffix**: Text -> Text -> Optional Text

Return the prefix of the second text if its suffix matches the entire first text. Examples:

stripSuffix "bar" "foobar" == Some "foo" stripSuffix "" "baz" == Some "baz" stripSuffix "foo" "quux" == None

**stripPrefix**: Text -> Text -> Optional Text

The

`stripPrefix`

function drops the given prefix from the argument text. It returns`None`

if the text did not start with the prefix.

**isPrefixOf**: Text -> Text -> Bool

The

`isPrefixOf`

function takes two text arguments and returns`True`

if and only if the first is a prefix of the second.

**isSuffixOf**: Text -> Text -> Bool

The

`isSuffixOf`

function takes two text arguments and returns`True`

if and only if the first is a suffix of the second.

**isInfixOf**: Text -> Text -> Bool

The

`isInfixOf`

function takes two text arguments and returns`True`

if and only if the first is contained, wholly and intact, anywhere within the second.

**takeWhile**: (Text -> Bool) -> Text -> Text

The function

`takeWhile`

, applied to a predicate`p`

and a text, returns the longest prefix (possibly empty) of symbols that satisfy`p`

.

**takeWhileEnd**: (Text -> Bool) -> Text -> Text

The function ‘takeWhileEnd’, applied to a predicate

`p`

and a ‘Text’, returns the longest suffix (possibly empty) of elements that satisfy`p`

.

**dropWhile**: (Text -> Bool) -> Text -> Text

`dropWhile p t`

returns the suffix remaining after`takeWhile p t`

.

**dropWhileEnd**: (Text -> Bool) -> Text -> Text

`dropWhileEnd p t`

returns the prefix remaining after dropping symbols that satisfy the predicate`p`

from the end of`t`

.

**splitOn**: Text -> Text -> [Text]

Break a text into pieces separated by the first text argument (which cannot be empty), consuming the delimiter.

**splitAt**: Int -> Text -> (Text, Text)

Split a text before a given position so that for

`0 <= n <= length t`

,`length (fst (splitAt n t)) == n`

.

**take**: Int -> Text -> Text

`take n`

, applied to a text`t`

, returns the prefix of`t`

of length`n`

, or`t`

itself if`n`

is greater than the length of`t`

.

**drop**: Int -> Text -> Text

`drop n`

, applied to a text`t`

, returns the suffix of`t`

after the first`n`

characters, or the empty`Text`

if`n`

is greater than the length of`t`

.

**substring**: Int -> Int -> Text -> Text

Compute the sequence of symbols of length

`l`

in the argument text starting at`s`

.

**isPred**: (Text -> Bool) -> Text -> Bool

`isPred f t`

returns`True`

if`t`

is not empty and`f`

is`True`

for all symbols in`t`

.

**isSpace**: Text -> Bool

`isSpace t`

is`True`

if`t`

is not empty and consists only of spaces.

**isNewLine**: Text -> Bool

`isSpace t`

is`True`

if`t`

is not empty and consists only of newlines.

**isUpper**: Text -> Bool

`isUpper t`

is`True`

if`t`

is not empty and consists only of uppercase symbols.

**isLower**: Text -> Bool

`isLower t`

is`True`

if`t`

is not empty and consists only of lowercase symbols.

**isDigit**: Text -> Bool

`isDigit t`

is`True`

if`t`

is not empty and consists only of digit symbols.

**isAlpha**: Text -> Bool

`isAlpha t`

is`True`

if`t`

is not empty and consists only of alphabet symbols.

**isAlphaNum**: Text -> Bool

`isAlphaNum t`

is`True`

if`t`

is not empty and consists only of alphanumeric symbols.

**legacyParseInt_**- : (Number a) => (Int -> a) -> [Text] -> a -> Optional a

**parseInt**: Text -> Optional Int

Attempt to parse an

`Int`

value from a given`Text`

.

**legacyParsePositiveDecimal**- : [Text] -> Optional Decimal

**parseDecimal**: Text -> Optional Decimal

Attempt to parse a

`Decimal`

value from a given`Text`

. To get`Some`

value, the text must follow the regex`(-|\+)?[0-9]+(\.[0-9]+)?`

In particular, the shorthands`".12"`

and`"12."`

do not work, but the value can be prefixed with`+`

. Leading and trailing zeros are fine, however spaces are not. Examples:parseDecimal "3.14" == Some 3.14 parseDecimal "+12.0" == Some 12

**sha256**: Text -> Text

Computes the SHA256 of the UTF8 bytes of the

`Text`

, and returns it in its hex-encoded form. The hex encoding uses lowercase letters.This function will crash at runtime if you compile DAML to DAML-LF < 1.2.

**reverse**: Text -> Text

Reverse some

`Text`

.reverse "DAML" == "LMAD"

**toCodePoints**: Text -> [Int]

Convert a

`Text`

into a sequence of unicode code points.

**fromCodePoints**: [Int] -> Text

Convert a sequence of unicode code points into a

`Text`

. Raises an exception if any of the code points is invalid.

### Module DA.TextMap¶

TextMap - A map is an associative array data type composed of a collection of key/value pairs such that, each possible key appears at most once in the collection.

#### Functions¶

**fromList**: [(Text, a)] -> TextMap a

Create a map from a list of key/value pairs.

**fromListWith**: (a -> a -> a) -> [(Text, a)] -> TextMap a

Create a map from a list of key/value pairs with a combining function. Examples:

fromListWith (++) [("A", [1]), ("A", [2]), ("B", [2]), ("B", [1]), ("A", [3])] == fromList [("A", [1, 2, 3]), ("B", [2, 1])] fromListWith (++) [] == (empty : TextMap [Int])

**toList**: TextMap a -> [(Text, a)]

Convert the map to a list of key/value pairs where the keys are in ascending order.

**empty**: TextMap a

The empty map.

**size**: TextMap a -> Int

Number of elements in the map.

**null**: TextMap v -> Bool

Is the map empty?

**lookup**: Text -> TextMap a -> Optional a

Lookup the value at a key in the map.

**member**: Text -> TextMap v -> Bool

Is the key a member of the map?

**filter**: (Text -> v -> Bool) -> TextMap v -> TextMap v

DEPRECATED: Use

`filterWithKey`

instead.

**filterWithKey**: (Text -> v -> Bool) -> TextMap v -> TextMap v

Filter all values that satisfy some predicate.

**delete**: Text -> TextMap a -> TextMap a

Delete a key and its value from the map. When the key is not a member of the map, the original map is returned.

**insert**: Text -> a -> TextMap a -> TextMap a

Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value.

**union**: TextMap a -> TextMap a -> TextMap a

The union of two maps, preferring the first map when equal keys are encountered.

**merge**: (Text -> a -> Optional c) -> (Text -> b -> Optional c) -> (Text -> a -> b -> Optional c) -> TextMap a -> TextMap b -> TextMap c

Merge two maps.

`merge f g h x y`

applies`f`

to all key/value pairs whose key only appears in`x`

,`g`

to all pairs whose key only appears in`y`

and`h`

to all pairs whose key appears in both`x`

and`y`

. In the end, all pairs yielding`Some`

are collected as the result.

### Module DA.Time¶

#### Data types¶

data **RelTime**

The

`RelTime`

type describes a time offset, i.e. relative time.

RelTime

Field Type Description microseconds Int

#### Functions¶

**time**: Date -> Int -> Int -> Int -> Time

`time d h m s`

turns given UTC date`d`

and the UTC time (given in hours, minutes, seconds) into a UTC timestamp (`Time`

). Does not handle leap seconds.

**pass**: RelTime -> Scenario Time

Pass simulated scenario time by argument

**addRelTime**: Time -> RelTime -> Time

Adjusts

`Time`

with given time offset.

**subTime**: Time -> Time -> RelTime

Returns time offset between two given instants.

**wholeDays**: RelTime -> Int

Returns the number of whole days in a time offset. Fraction of time is rounded towards zero.

**days**: Int -> RelTime

A number of days in relative time.

**hours**: Int -> RelTime

A number of hours in relative time.

**minutes**: Int -> RelTime

A number of minutes in relative time.

**seconds**- : Int -> RelTime

**convertRelTimeToMicroseconds**: RelTime -> Int

Convert RelTime to microseconds Use higher level functions instead of the internal microseconds

**convertMicrosecondsToRelTime**: Int -> RelTime

Convert microseconds to RelTime Use higher level functions instead of the internal microseconds

### Module DA.Traversable¶

Class of data structures that can be traversed from left to right, performing an action on each element.
You typically would want to import this module qualified to avoid clashes with
functions defined in Prelude. Ie.:
```
`
import DA.Traversable qualified as F
`
```

#### Typeclasses¶

**class (Functor t, Foldable t) => Traversable t where**Functors representing data structures that can be traversed from left to right.

**mapA**: (Applicative f) => (a -> f b) -> t a -> f (t b)

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

**sequence**: (Applicative f) => t (f a) -> f (t a)

Evaluate each action in the structure from left to right, and collect the results.

#### Functions¶

**forA**: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)

`forA`

is`mapA`

with its arguments flipped.

### Module DA.Tuple¶

Tuple - Ubiquitous functions of tuples.

#### Functions¶

**first**: (a -> a’) -> (a, b) -> (a’, b)

The pair obtained from a pair by application of a programmer supplied function to the argument pair’s first field.

**second**: (b -> b’) -> (a, b) -> (a, b’)

The pair obtained from a pair by application of a programmer supplied function to the argument pair’s second field.

**both**: (a -> b) -> (a, a) -> (b, b)

The pair obtained from a pair by application of a programmer supplied function to both the argument pair’s first and second fields.

**swap**: (a, b) -> (b, a)

The pair obtained from a pair by permuting the order of the argument pair’s first and second fields.

**dupe**: a -> (a, a)

Duplicate a single value into a pair.

> dupe 12 == (12, 12)

**fst3**: (a, b, c) -> a

Extract the ‘fst’ of a triple.

**snd3**: (a, b, c) -> b

Extract the ‘snd’ of a triple.

**thd3**: (a, b, c) -> c

Extract the final element of a triple.

**curry3**: ((a, b, c) -> d) -> a -> b -> c -> d

Converts an uncurried function to a curried function.

**uncurry3**: (a -> b -> c -> d) -> (a, b, c) -> d

Converts a curried function to a function on a triple.

### Module DA.Types¶

A module containing all the standard types from the base libraries, so they have nice names when used from Java or similar.

#### Data types¶

data **Either a b**

The

`Either`

type represents values with two possibilities: a value of type`Either a b`

is either`Left a`

or`Right b`

.The

`Either`

type is sometimes used to represent a value which is either correct or an error; by convention, the`Left`

constructor is used to hold an error value and the`Right`

constructor is used to hold a correct value (mnemonic: “right” also means “correct”).

Lefta

Rightb

data **Tuple10 a b c d e f g h i j**

Tuple10

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j

data **Tuple11 a b c d e f g h i j k**

Tuple11

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k

data **Tuple12 a b c d e f g h i j k l**

Tuple12

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k _12 l

data **Tuple13 a b c d e f g h i j k l m**

Tuple13

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k _12 l _13 m

data **Tuple14 a b c d e f g h i j k l m n**

Tuple14

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k _12 l _13 m _14 n

data **Tuple15 a b c d e f g h i j k l m n o**

Tuple15

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k _12 l _13 m _14 n _15 o

data **Tuple16 a b c d e f g h i j k l m n o p**

Tuple16

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k _12 l _13 m _14 n _15 o _16 p

data **Tuple17 a b c d e f g h i j k l m n o p q**

Tuple17

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k _12 l _13 m _14 n _15 o _16 p _17 q

data **Tuple18 a b c d e f g h i j k l m n o p q r**

Tuple18

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k _12 l _13 m _14 n _15 o _16 p _17 q _18 r

data **Tuple19 a b c d e f g h i j k l m n o p q r s**

Tuple19

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k _12 l _13 m _14 n _15 o _16 p _17 q _18 r _19 s

data **Tuple2 a b**

Tuple2

Field Type Description _1 a _2 b

data **Tuple20 a b c d e f g h i j k l m n o p q r s t**

Tuple20

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i _10 j _11 k _12 l _13 m _14 n _15 o _16 p _17 q _18 r _19 s _20 t

data **Tuple3 a b c**

Tuple3

Field Type Description _1 a _2 b _3 c

data **Tuple4 a b c d**

Tuple4

Field Type Description _1 a _2 b _3 c _4 d

data **Tuple5 a b c d e**

Tuple5

Field Type Description _1 a _2 b _3 c _4 d _5 e

data **Tuple6 a b c d e f**

Tuple6

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f

data **Tuple7 a b c d e f g**

Tuple7

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g

data **Tuple8 a b c d e f g h**

Tuple8

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h

data **Tuple9 a b c d e f g h i**

Tuple9

Field Type Description _1 a _2 b _3 c _4 d _5 e _6 f _7 g _8 h _9 i

### Module DA.Upgrade¶

#### Typeclasses¶

**class Conv a b where**Generic representations that are isomorphic and have the same meta-data up to package id.

**cv**- : a x -> b x

**class MetaEquiv m1 m2 where**- This class describes meta-data that is equal up to package id.

**class Iso a b where**

isom- : a x -> b x

#### Functions¶

**conv**: (Generic a repA, Generic b repB, Conv repA repB) => a -> b

Convert data types that are isomorphic and have the same meta-data up to package id.

**iso**- : (Generic a repA, Generic b repB, Iso repA repB) => a -> b

### Module DA.Validation¶

Validation type and associated functions.

#### Data types¶

data **Validation err a**

A

`Validation`

represents eithor a non-empty list of errors, or a successful value. This generalizes`Either`

to allow more than one error to be collected.

ErrorsNonEmpty err

Successa

#### Functions¶

**invalid**: err -> Validation err a

Fail for the given reason.

**ok**: a -> Validation err a

Succeed with the given value.

**validate**: Either err a -> Validation err a

Turn an

`Either`

into a`Validation`

.

**run**: Validation err a -> Either (NonEmpty err) a

Convert a

`Validation err a`

value into an`Either`

, taking the non-empty list of errors as the left value.

**run1**: Validation err a -> Either err a

Convert a

`Validation err a`

value into an`Either`

, taking just the first error as the left value.

**runWithDefault**: a -> Validation err a -> a

Run a

`Validation err a`

with a default value in case of errors.

**(<?>)**: (ActionFail m) => Optional b -> Text -> m b

Convert an

`Optional t`

into a`Validation Text t`

, or more generally into an`m t`

for any`ActionFail`

type`m`

.