Built In
Literals & Entities
type
Entity.
==
,
==.Entity.
: Entity. -> Entity. -> Boolean.
Equal.
/=
,
/=.Entity.
: Entity. -> Entity. -> Boolean.
Not equal.
order.Entity.
: Entity. -> Entity. -> Ordering.
An arbitrary order on
Entity
.
anchor.Entity.
: Entity. -> Text.
The anchor of an entity, as text.
type storable
Literal.
subtype Literal. <: Entity.
Showable
type
Showable.
Something that can be represented as
Text
.
Mk.Showable.
: Text. -> Showable.
show.
,
show.Showable.
: Showable. -> Text.
Show something as
Text
Unit
type storable
Unit.
subtype Unit. <: Literal.
subtype Unit. <: Showable.
<>.Unit.
: Unit. -> Unit. -> Unit.
concat1.Unit.
: List1.List. Unit. -> Unit.
empty.Unit.
: Unit.
concat.Unit.
: List. Unit. -> Unit.
==.Unit.
: Unit. -> Unit. -> Boolean.
Equal.
/=.Unit.
: Unit. -> Unit. -> Boolean.
Not equal.
Boolean
type storable
Boolean.
True.
,
True.Boolean.
: Boolean.
Boolean TRUE.
False.
,
False.Boolean.
: Boolean.
Boolean FALSE.
subtype Boolean. <: Literal.
subtype Boolean. <: Showable.
==.Boolean.
: Boolean. -> Boolean. -> Boolean.
Equal.
/=.Boolean.
: Boolean. -> Boolean. -> Boolean.
Not equal.
&&
,
&&.Boolean.
: Boolean. -> Boolean. -> Boolean.
Boolean AND.
||
,
||.Boolean.
: Boolean. -> Boolean. -> Boolean.
Boolean OR.
not.
,
not.Boolean.
: Boolean. -> Boolean.
Boolean NOT.
Ordering
type storable
Ordering.
LT.
,
LT.Ordering.
: Ordering.
Less than.
EQ.
,
EQ.Ordering.
: Ordering.
Equal to.
GT.
,
GT.Ordering.
: Ordering.
Greater than.
subtype Ordering. <: Literal.
subtype Ordering. <: Showable.
==.Ordering.
: Ordering. -> Ordering. -> Boolean.
Equal.
/=.Ordering.
: Ordering. -> Ordering. -> Boolean.
Not equal.
order.Ordering.
: Ordering. -> Ordering. -> Ordering.
Order
<.Ordering.
: Ordering. -> Ordering. -> Boolean.
Strictly less.
<=.Ordering.
: Ordering. -> Ordering. -> Boolean.
Less or equal.
>.Ordering.
: Ordering. -> Ordering. -> Boolean.
Strictly greater.
>=.Ordering.
: Ordering. -> Ordering. -> Boolean.
Greater or equal.
min.Ordering.
: Ordering. -> Ordering. -> Ordering.
Lesser of two
max.Ordering.
: Ordering. -> Ordering. -> Ordering.
Greater of two
<>.Ordering.
: Ordering. -> Ordering. -> Ordering.
concat1.Ordering.
: List1.List. Ordering. -> Ordering.
empty.Ordering.
: Ordering.
concat.Ordering.
: List. Ordering. -> Ordering.
eq.
,
eq.Ordering.
: Ordering. -> Boolean.
Equal.
ne.
,
ne.Ordering.
: Ordering. -> Boolean.
Not equal.
lt.
,
lt.Ordering.
: Ordering. -> Boolean.
Less than.
le.
,
le.Ordering.
: Ordering. -> Boolean.
Less than or equal to.
gt.
,
gt.Ordering.
: Ordering. -> Boolean.
Greater than.
ge.
,
ge.Ordering.
: Ordering. -> Boolean.
Greater than or equal to.
Order
<>.Order.
: (a -> a -> Ordering.) -> (a -> a -> Ordering.) -> a -> a -> Ordering.
concat1.Order.
: List1.List. (a -> a -> Ordering.) -> a -> a -> Ordering.
empty.Order.
: a -> a -> Ordering.
concat.Order.
: List. (a -> a -> Ordering.) -> a -> a -> Ordering.
reverse.Order.
: (a -> a -> Ordering.) -> a -> a -> Ordering.
Reverse an order.
lesser.
,
lesser.Order.
: (a -> a -> Ordering.) -> a -> a -> a
The lesser of two items in this order.
greater.
,
greater.Order.
: (a -> a -> Ordering.) -> a -> a -> a
The greater of two items in this order.
on.
,
on.Order.
: (b -> a) -> (a -> a -> Ordering.) -> b -> b -> Ordering.
Map an order by a function
Text
type storable
Text.
subtype Text. <: Literal.
subtype Text. <: Showable.
<>.Text.
: Text. -> Text. -> Text.
concat1.Text.
: List1.List. Text. -> Text.
empty.Text.
: Text.
concat.Text.
: List. Text. -> Text.
==.Text.
: Text. -> Text. -> Boolean.
Equal.
/=.Text.
: Text. -> Text. -> Boolean.
Not equal.
order.Text.
: Text. -> Text. -> Ordering.
Order alphabetical first, then lower case before upper, per Unicode normalisation.
<.Text.
: Text. -> Text. -> Boolean.
Strictly less.
<=.Text.
: Text. -> Text. -> Boolean.
Less or equal.
>.Text.
: Text. -> Text. -> Boolean.
Strictly greater.
>=.Text.
: Text. -> Text. -> Boolean.
Greater or equal.
min.Text.
: Text. -> Text. -> Text.
Lesser of two
max.Text.
: Text. -> Text. -> Text.
Greater of two
length.Text.
: Text. -> Integer.
The length of a text.
section.Text.
: Integer. -> Integer. -> Text. -> Text.
section start len text
is the section oftext
beginning atstart
of lengthlen
.
toUpperCase.Text.
: Text. -> Text.
toLowerCase.Text.
: Text. -> Text.
Numeric
Integer
type storable
Integer.
subtype Integer. <: Rational.
==.Integer.
: Integer. -> Integer. -> Boolean.
Equal.
/=.Integer.
: Integer. -> Integer. -> Boolean.
Not equal.
order.Integer.
: Integer. -> Integer. -> Ordering.
Order
<.Integer.
: Integer. -> Integer. -> Boolean.
Strictly less.
<=.Integer.
: Integer. -> Integer. -> Boolean.
Less or equal.
>.Integer.
: Integer. -> Integer. -> Boolean.
Strictly greater.
>=.Integer.
: Integer. -> Integer. -> Boolean.
Greater or equal.
min.
,
min.Integer.
: Integer. -> Integer. -> Integer.
Lesser of two
max.
,
max.Integer.
: Integer. -> Integer. -> Integer.
Greater of two
pred.
,
pred.Integer.
: Integer. -> Integer.
Previous value.
succ.
,
succ.Integer.
: Integer. -> Integer.
Next value.
asText.Integer.
: Prism. Text. Integer.
Represent an integer as text.
+
,
+.Integer.
: Integer. -> Integer. -> Integer.
Add.
-
,
-.Integer.
: Integer. -> Integer. -> Integer.
Subtract.
*
,
*.Integer.
: Integer. -> Integer. -> Integer.
Multiply.
negate.
,
negate.Integer.
: Integer. -> Integer.
Negate.
abs.
,
abs.Integer.
: Integer. -> Integer.
Absolute value.
signum.
,
signum.Integer.
: Integer. -> Integer.
Sign.
mod.
,
mod.Integer.
: Integer. -> Integer. -> Integer.
Modulus, leftover from
div
even.
,
even.Integer.
: Integer. -> Boolean.
Is even?
odd.
,
odd.Integer.
: Integer. -> Boolean.
Is odd?
gcd.
,
gcd.Integer.
: Integer. -> Integer. -> Integer.
Greatest common divisor.
lcm.
,
lcm.Integer.
: Integer. -> Integer. -> Integer.
Least common multiple.
^
,
^.Integer.
: Integer. -> Integer. -> Integer.
Raise to non-negative power.
sum.
,
sum.Integer.
: List. Integer. -> Integer.
Sum.
product.
,
product.Integer.
: List. Integer. -> Integer.
Product.
range.
,
range.Integer.
: Integer. -> Integer. -> List. Integer.
range a b
is an arithmetic sequence starting froma
, with all numbers<= b
. Step is +1.
arithList.
,
arithList.Integer.
: Integer. -> Integer. -> Maybe. Integer. -> List. Integer.
arithList step a (Just b)
is an arithmetic sequence starting froma
, with all numbers<= b
(for positive step) or>= b
(for negative step).
arithList step a Nothing
is an infinite arithmetic sequence starting from a
.
Rational
type storable
Rational.
subtype Rational. <: Number.
asText.Rational.
: Prism. Text. Rational.
Represent a rational as text.
min.Rational.
: Rational. -> Rational. -> Rational.
Lesser of two Rationals
max.Rational.
: Rational. -> Rational. -> Rational.
Greater of two Rationals
+.Rational.
: Rational. -> Rational. -> Rational.
Add.
-.Rational.
: Rational. -> Rational. -> Rational.
Subtract.
*.Rational.
: Rational. -> Rational. -> Rational.
Multiply.
/
,
/.Rational.
: Rational. -> Rational. -> Rational.
Divide.
negate.Rational.
: Rational. -> Rational.
Negate.
recip.Rational.
: Rational. -> Rational.
Reciprocal.
abs.Rational.
: Rational. -> Rational.
Absolute value.
signum.Rational.
: Rational. -> Rational.
Sign.
mod.Rational.
: Rational. -> Rational. -> Rational.
Modulus, leftover from
div
^.Rational.
: Rational. -> Integer. -> Rational.
Raise to Integer power.
sum.Rational.
: List. Rational. -> Rational.
Sum.
mean.Rational.
: List. Rational. -> Rational.
Mean.
product.Rational.
: List. Rational. -> Rational.
Product.
Number
type storable
Number.
subtype Number. <: Literal.
subtype Number. <: Showable.
==.Number.
: Number. -> Number. -> Boolean.
Equal.
/=.Number.
: Number. -> Number. -> Boolean.
Not equal.
order.Number.
: Number. -> Number. -> Ordering.
Order
<
,
<.Number.
: Number. -> Number. -> Boolean.
Strictly less.
<=
,
<=.Number.
: Number. -> Number. -> Boolean.
Less or equal.
>
,
>.Number.
: Number. -> Number. -> Boolean.
Strictly greater.
>=
,
>=.Number.
: Number. -> Number. -> Boolean.
Greater or equal.
min.Number.
: Number. -> Number. -> Number.
Lesser of two
max.Number.
: Number. -> Number. -> Number.
Greater of two
asText.Number.
: Prism. Text. Number.
Represent a number as text.
+.Number.
: Number. -> Number. -> Number.
Add.
-.Number.
: Number. -> Number. -> Number.
Subtract.
*.Number.
: Number. -> Number. -> Number.
Multiply.
/.Number.
: Number. -> Number. -> Number.
Divide.
negate.Number.
: Number. -> Number.
Negate.
recip.Number.
: Number. -> Number.
Reciprocal.
pi.
,
pi.Number.
: Number.
Half the radians in a circle.
exp.
,
exp.Number.
: Number. -> Number.
Exponent
log.
,
log.Number.
: Number. -> Number.
Natural logarithm
sqrt.
,
sqrt.Number.
: Number. -> Number.
Square root.
^.Number.
: Number. -> Number. -> Number.
Raise to power.
logBase.
,
logBase.Number.
: Number. -> Number. -> Number.
sin.
,
sin.Number.
: Number. -> Number.
Sine of an angle in radians.
cos.
,
cos.Number.
: Number. -> Number.
Cosine of an angle in radians.
tan.
,
tan.Number.
: Number. -> Number.
Tangent of an angle in radians.
asin.
,
asin.Number.
: Number. -> Number.
Radian angle of a sine.
acos.
,
acos.Number.
: Number. -> Number.
Radian angle of a cosine.
atan.
,
atan.Number.
: Number. -> Number.
Radian angle of a tangent.
sinh.
,
sinh.Number.
: Number. -> Number.
Hyperbolic sine.
cosh.
,
cosh.Number.
: Number. -> Number.
Hyperbolic cosine.
tanh.
,
tanh.Number.
: Number. -> Number.
Hyperbolic tangent.
asinh.
,
asinh.Number.
: Number. -> Number.
Inverse hyperbolic sine.
acosh.
,
acosh.Number.
: Number. -> Number.
Inverse hyperbolic cosine.
atanh.
,
atanh.Number.
: Number. -> Number.
Inverse hyperbolic tangent.
abs.Number.
: Number. -> Number.
Absolute value.
signum.Number.
: Number. -> Number.
Sign. Note this will be the same exact or inexact as the number.
floor.
,
floor.Number.
: Number. -> Integer.
Integer towards negative infinity.
ceiling.
,
ceiling.Number.
: Number. -> Integer.
Integer towards positive infinity.
round.
,
round.Number.
: Number. -> Integer.
Closest Integer.
inexact.
,
inexact.Number.
: Number. -> Number.
Convert a number to inexact.
approximate.
,
approximate.Number.
: Rational. -> Number. -> Rational.
approximate d x
gives the exact number that’s a multiple ofd
that’s closest tox
.
div.
,
div.Number.
: Number. -> Number. -> Integer.
Division to Integer, towards negative infinity.
mod.
,
mod.Number.
: Number. -> Number. -> Number.
Modulus, leftover from
div
isNaN.
,
isNaN.Number.
: Number. -> Boolean.
Is not a number?
isInfinite.
,
isInfinite.Number.
: Number. -> Boolean.
Is infinite?
isNegativeZero.
,
isNegativeZero.Number.
: Number. -> Boolean.
Is negative zero?
isExact.
,
isExact.Number.
: Number. -> Boolean.
Is exact?
sum.Number.
: List. Number. -> Number.
Sum.
mean.Number.
: List. Number. -> Number.
Mean.
product.Number.
: List. Number. -> Number.
Product.
checkSafeRational.
,
checkSafeRational.Number.
: Number. -> Maybe. Rational.
Get the exact value of a Number, if it is one.
checkExactInteger.
,
checkExactInteger.Number.
: Number. -> Maybe. Integer.
Get the exact Integer value of a Number, if it is one. Works as expected on Rationals.
Date & Time
Duration
type storable
Duration.
Seconds.
,
Seconds.Duration.
: Rational. -> Duration.
Construct a
Duration
from seconds.
subtype Duration. <: Literal.
subtype Duration. <: Showable.
==.Duration.
: Duration. -> Duration. -> Boolean.
Equal.
/=.Duration.
: Duration. -> Duration. -> Boolean.
Not equal.
order.Duration.
: Duration. -> Duration. -> Ordering.
Order
<.Duration.
: Duration. -> Duration. -> Boolean.
Strictly less.
<=.Duration.
: Duration. -> Duration. -> Boolean.
Less or equal.
>.Duration.
: Duration. -> Duration. -> Boolean.
Strictly greater.
>=.Duration.
: Duration. -> Duration. -> Boolean.
Greater or equal.
min.Duration.
: Duration. -> Duration. -> Duration.
Lesser of two
max.Duration.
: Duration. -> Duration. -> Duration.
Greater of two
zero.Duration.
: Duration.
No duration.
day.Duration.
: Duration.
One day duration.
+.Duration.
: Duration. -> Duration. -> Duration.
Add durations.
-.Duration.
: Duration. -> Duration. -> Duration.
Subtract durations.
negate.Duration.
: Duration. -> Duration.
Negate duration.
*.Duration.
: Number. -> Duration. -> Duration.
Multiply a duration by a number.
/.Duration.
: Duration. -> Duration. -> Number.
Divide durations.
Time
type storable
Time.
Absolute time as measured by UTC.
UTCDateAndSinceMidnight.
,
UTCDateAndSinceMidnight.Time.
: Date. -> Duration. -> Time.
Construct a
Time
from aDate
and aDuration
since UTC midnight.
UTC.
,
UTC.Time.
: LocalTime. -> Time.
Construct a
Time
from aLocalTime
in UTC.
SinceUnixEpoch.
,
SinceUnixEpoch.Time.
: Duration. -> Time.
Construct a
Time
from aDuration
since the Unix epoch (beginning of 1970 UTC).
subtype Time. <: Literal.
subtype Time. <: Showable.
==.Time.
: Time. -> Time. -> Boolean.
Equal.
/=.Time.
: Time. -> Time. -> Boolean.
Not equal.
order.Time.
: Time. -> Time. -> Ordering.
Order
<.Time.
: Time. -> Time. -> Boolean.
Strictly less.
<=.Time.
: Time. -> Time. -> Boolean.
Less or equal.
>.Time.
: Time. -> Time. -> Boolean.
Strictly greater.
>=.Time.
: Time. -> Time. -> Boolean.
Greater or equal.
min.Time.
: Time. -> Time. -> Time.
Lesser of two
max.Time.
: Time. -> Time. -> Time.
Greater of two
asText.Time.
: Prism. Text. Time.
Represent a time as text.
unixAsText.Time.
: Text. -> Prism. Text. Time.
Represent a time as text, using the given Unix-like format/parsing string.
+.Time.
: Duration. -> Time. -> Time.
Add duration to time.
-.Time.
: Time. -> Time. -> Duration.
Difference of times.
getNow.Time.
: Action. Time.
Get the current time.
newClock.
,
newClock.Time.
: Duration. -> Action. (WholeModel. +Time.)
Make a model of the current time that updates per the given duration.
Date
type storable
Date.
YearMonthDay.
,
YearMonthDay.Date.
: Integer. -> Integer. -> Integer. -> Date.
Construct a
Date
from year, month, day.
ModifiedJulianDay.
,
ModifiedJulianDay.Date.
: Integer. -> Date.
Construct a
Date
from its MJD.
subtype Date. <: Literal.
subtype Date. <: Showable.
pred.Date.
: Date. -> Date.
Previous value.
succ.Date.
: Date. -> Date.
Next value.
==.Date.
: Date. -> Date. -> Boolean.
Equal.
/=.Date.
: Date. -> Date. -> Boolean.
Not equal.
order.Date.
: Date. -> Date. -> Ordering.
Order
<.Date.
: Date. -> Date. -> Boolean.
Strictly less.
<=.Date.
: Date. -> Date. -> Boolean.
Less or equal.
>.Date.
: Date. -> Date. -> Boolean.
Strictly greater.
>=.Date.
: Date. -> Date. -> Boolean.
Greater or equal.
min.Date.
: Date. -> Date. -> Date.
Lesser of two
max.Date.
: Date. -> Date. -> Date.
Greater of two
asText.Date.
: Prism. Text. Date.
Represent a date as text.
unixAsText.Date.
: Text. -> Prism. Text. Date.
Represent a date as text, using the given Unix-like format/parsing string.
+.Date.
: Integer. -> Date. -> Date.
Add count to days to date.
-.Date.
: Date. -> Date. -> Integer.
Difference of days between dates.
getNowUTC.Date.
: Action. Date.
Get the current UTC date.
getNowLocal.Date.
: Action. Date.
Get the current local date.
newClockUTC.Date.
: Action. (WholeModel. +Date.)
Get a whole model for the current UTC date.
newClockLocal.Date.
: Action. (WholeModel. +Date.)
Get a whole model for the current local date.
Time of Day
type storable
TimeOfDay.
HourMinuteSecond.
,
HourMinuteSecond.TimeOfDay.
: Integer. -> Integer. -> Rational. -> TimeOfDay.
Construct a
TimeOfDay
from hour, minute, second.
SinceMidnight.
,
SinceMidnight.TimeOfDay.
: Duration. -> TimeOfDay.
Construct a
TimeOfDay
from duration since midnight (wrapping whole days).
subtype TimeOfDay. <: Literal.
subtype TimeOfDay. <: Showable.
==.TimeOfDay.
: TimeOfDay. -> TimeOfDay. -> Boolean.
Equal.
/=.TimeOfDay.
: TimeOfDay. -> TimeOfDay. -> Boolean.
Not equal.
order.TimeOfDay.
: TimeOfDay. -> TimeOfDay. -> Ordering.
Order
<.TimeOfDay.
: TimeOfDay. -> TimeOfDay. -> Boolean.
Strictly less.
<=.TimeOfDay.
: TimeOfDay. -> TimeOfDay. -> Boolean.
Less or equal.
>.TimeOfDay.
: TimeOfDay. -> TimeOfDay. -> Boolean.
Strictly greater.
>=.TimeOfDay.
: TimeOfDay. -> TimeOfDay. -> Boolean.
Greater or equal.
min.TimeOfDay.
: TimeOfDay. -> TimeOfDay. -> TimeOfDay.
Lesser of two
max.TimeOfDay.
: TimeOfDay. -> TimeOfDay. -> TimeOfDay.
Greater of two
asText.TimeOfDay.
: Prism. Text. TimeOfDay.
Represent a time of day as text.
unixAsText.TimeOfDay.
: Text. -> Prism. Text. TimeOfDay.
Represent a time of day as text, using the given Unix-like format/parsing string.
midnight.
,
midnight.TimeOfDay.
: TimeOfDay.
Midnight.
midday.
,
midday.TimeOfDay.
: TimeOfDay.
Midday.
Local Time
type storable
LocalTime.
DateAndTime.
,
DateAndTime.LocalTime.
: Date. -> TimeOfDay. -> LocalTime.
Construct a
LocalTime
from day and time of day.
subtype LocalTime. <: Literal.
subtype LocalTime. <: Showable.
==.LocalTime.
: LocalTime. -> LocalTime. -> Boolean.
Equal.
/=.LocalTime.
: LocalTime. -> LocalTime. -> Boolean.
Not equal.
order.LocalTime.
: LocalTime. -> LocalTime. -> Ordering.
Order
<.LocalTime.
: LocalTime. -> LocalTime. -> Boolean.
Strictly less.
<=.LocalTime.
: LocalTime. -> LocalTime. -> Boolean.
Less or equal.
>.LocalTime.
: LocalTime. -> LocalTime. -> Boolean.
Strictly greater.
>=.LocalTime.
: LocalTime. -> LocalTime. -> Boolean.
Greater or equal.
min.LocalTime.
: LocalTime. -> LocalTime. -> LocalTime.
Lesser of two
max.LocalTime.
: LocalTime. -> LocalTime. -> LocalTime.
Greater of two
asText.LocalTime.
: Prism. Text. LocalTime.
Represent a local time as text.
unixAsText.LocalTime.
: Text. -> Prism. Text. LocalTime.
Represent a local time as text, using the given Unix-like format/parsing string.
fromTime.LocalTime.
: Integer. -> Time. -> LocalTime.
Convert a time to local time, given a time zone offset in minutes
toTime.LocalTime.
: Integer. -> LocalTime. -> Time.
Convert a local time to time, given a time zone offset in minutes
getTimeZone.LocalTime.
: Time. -> Action. Integer.
Get the offset for a time in the current time zone.
getCurrentTimeZone.LocalTime.
: Action. Integer.
Get the current time zone offset in minutes.
getNow.LocalTime.
: Action. LocalTime.
Get the current local time.
newTimeZoneModel.LocalTime.
: WholeModel. +Time. -> Action. (WholeModel. +Integer.)
The current time zone offset in minutes.
Open Entities
point.OpenEntity.
@A <anchor>: A
An open entity for this anchor.
A
is an open entity type.
new.OpenEntity.
@A: Action. A
Generate an open entity.
A
is an open entity type.
Dynamic Entities
type storable
DynamicEntity.
subtype DynamicEntity. <: Entity.
point.DynamicEntity.
@A <anchor>: A
A dynamic entity for this anchor.
A
is a concrete dynamic entity type.
new.DynamicEntity.
@A: Action. A
Generate a dynamic entity.
A
is a concrete dynamic entity type.
Dynamic Types
type
DynamicType.
subtype DynamicType. <: Entity.
fromEntity.DynamicType.
: DynamicEntity. -> DynamicType.
The type of this dynamic entity.
newEntity.DynamicType.
: DynamicType. -> Action. DynamicEntity.
Generate a dynamic entity of this type.
fromType.DynamicType.
@A: DynamicType.
The dynamic type of
A
, a concrete dynamic entity type.
fromAbstract.DynamicType.
@A: List. DynamicType.
The dynamic types of
A
, a dynamic entity type.
subtype.DynamicType.
@A: DynamicType. -> Boolean.
Whether this type is in
A
, a dynamic entity type.
Maybe
type storable
Maybe.
+a
Just.
,
Just.Maybe.
: a -> Maybe. a
Construct a Maybe from a value.
Nothing.
,
Nothing.Maybe.
: Maybe. None
Construct a Maybe without a value.
subtype Maybe. Entity. <: Entity.
subtype Maybe. Showable. <: Showable.
map.Maybe.
: (a -> b) -> Maybe. a -> Maybe. b
pure.Maybe.
: a -> Maybe. a
ap.Maybe.
: Maybe. (a -> b) -> Maybe. a -> Maybe. b
liftA2.Maybe.
: (a -> b -> c) -> Maybe. a -> Maybe. b -> Maybe. c
**.Maybe.
: Maybe. a -> Maybe. b -> Maybe. (a *: b)
>>.Maybe.
: Maybe. Any -> Maybe. a -> Maybe. a
>>=.Maybe.
: Maybe. a -> (a -> Maybe. b) -> Maybe. b
Type Product
type storable +a
*:
+b
subtype Entity. *: Entity. <: Entity.
subtype Showable. *: Showable. <: Showable.
fst.
,
fst.Product.
: a *: b -> a
Get the first member of a pair.
snd.
,
snd.Product.
: a *: b -> b
Get the second member of a pair.
to.Product.
: a -> b -> a *: b
Construct a pair.
both.
,
both.Product.
: a -> a *: a
Construct a pair.
Type Sum
type storable +a
+:
+b
Left.
,
Left.+:.
: a -> a +: b
Construct an Either from the left.
Right.
,
Right.+:.
: b -> a +: b
Construct an Either from the right.
subtype Entity. +: Entity. <: Entity.
subtype Showable. +: Showable. <: Showable.
map.Sum.
: (a -> b) -> p +: a -> p +: b
pure.Sum.
: a -> p +: a
ap.Sum.
: p +: (a -> b) -> p +: a -> p +: b
liftA2.Sum.
: (a -> b -> c) -> p +: a -> p +: b -> p +: c
**.Sum.
: p +: a -> p +: b -> p +: a *: b
>>.Sum.
: p +: Any -> p +: a -> p +: a
>>=.Sum.
: p +: a -> (a -> p +: b) -> p +: b
from.Sum.
: (a -> c) -> (b -> c) -> a +: b -> c
Eliminate a sum
either.
,
either.Sum.
: a +: a -> a
Eliminate a sum
List
type storable
List.
+a
A list.
type storable
List1.
,
List1.List.
+a
A list with at least one element.
subtype List1.List. a <: List. a
[]
,
[].List.
: List. None
Empty list
::
,
::.List.
: a -> List. a -> List1.List. a
Construct a list
subtype List. Entity. <: Entity.
subtype List. Showable. <: Showable.
<>
,
<>.List.
: List. a -> List. a -> List. a
concat1.List.
: List1.List. (List. a) -> List. a
empty.List.
: List. a
concat.List.
: List. (List. a) -> List. a
map.List.
: (a -> b) -> List. a -> List. b
pure.List.
: a -> List. a
ap.List.
: List. (a -> b) -> List. a -> List. b
liftA2.List.
: (a -> b -> c) -> List. a -> List. b -> List. c
**.List.
: List. a -> List. b -> List. (a *: b)
>>.List.
: List. Any -> List. a -> List. a
>>=.List.
: List. a -> (a -> List. b) -> List. b
from.List.
: b -> (a -> List. a -> b) -> List. a -> b
Eliminate a list
length.
,
length.List.
: List. Any -> Integer.
Number of items in a list
index.
,
index.List.
: List. a -> Integer. -> Maybe. a
Get item from list by index.
filter.
,
filter.List.
: (a -> Boolean.) -> List. a -> List. a
Filter a list.
maybeMap.
,
maybeMap.List.
: (a -> Maybe. b) -> List. a -> List. b
Map and filter a list.
take.
,
take.List.
: Integer. -> List. a -> List. a
Take the first n elements.
drop.
,
drop.List.
: Integer. -> List. a -> List. a
Drop the first n elements.
takeWhile.
,
takeWhile.List.
: (a -> Boolean.) -> List. a -> List. a
Take while the condition holds.
dropWhile.
,
dropWhile.List.
: (a -> Boolean.) -> List. a -> List. a
Drop while the condition holds.
zip.
,
zip.List.
: List. a -> List. b -> List. (a *: b)
Zip two lists.
sort.
,
sort.List.
: (a -> a -> Ordering.) -> List. a -> List. a
Sort list by an order.
map.List1.
: (a -> b) -> List1.List. a -> List1.List. b
pure.List1.
: a -> List1.List. a
ap.List1.
: List1.List. (a -> b) -> List1.List. a -> List1.List. b
liftA2.List1.
: (a -> b -> c) -> List1.List. a -> List1.List. b -> List1.List. c
**.List1.
: List1.List. a -> List1.List. b -> List1.List. (a *: b)
>>.List1.
: List1.List. Any -> List1.List. a -> List1.List. a
<>.List1.
: List1.List. a -> List. a -> List1.List. a
Concatenate a non-empty list with a list.
concat1.
,
concat1.List1.
: List1.List. (List1.List. a) -> List1.List. a
Concatenate a non-empty list of non-empty lists.
sort.List1.
: (a -> a -> Ordering.) -> List1.List. a -> List1.List. a
Sort non-empty list by an order.
Map
type storable
Map.
+a
A hash map.
subtype Map. Entity. <: Entity.
<>.Map.
: Map. a -> Map. a -> Map. a
concat1.Map.
: List1.List. (Map. a) -> Map. a
empty.Map.
: Map. a
concat.Map.
: List. (Map. a) -> Map. a
lookup.Map.
: Entity. -> Map. a -> Maybe. a
Look up element.
insert.Map.
: Entity. -> a -> Map. a -> Map. a
Insert into map.
delete.Map.
: Entity. -> Map. a -> Map. a
Delete from map.
single.Map.
: Entity. -> a -> Map. a
A map with one element.
keys.Map.
: Map. Any -> List. Entity.
The keys of the map.
values.Map.
: Map. a -> List. a
The values of the map.
fromList.Map.
: List. (Entity. *: a) -> Map. a
Construct from list.
toList.Map.
: Map. a -> List. (Entity. *: a)
Convert to list.
Function
type -a
->
+b
A pure function.
map.Function.
: (a -> b) -> (p -> a) -> p -> b
pure.Function.
: a -> p -> a
ap.Function.
: (p -> a -> b) -> (p -> a) -> p -> b
liftA2.Function.
: (a -> b -> c) -> (p -> a) -> (p -> b) -> p -> c
**.Function.
: (p -> a) -> (p -> b) -> p -> a *: b
>>.Function.
: (p -> Any) -> (p -> a) -> p -> a
>>=.Function.
: (p -> a) -> (a -> p -> b) -> p -> b
$
,
$.Function.
: (a -> b) -> a -> b
Apply a function to a value.
>-
,
>-.Function.
: a -> (a -> b) -> b
Apply a value to a function.
id.
,
id.Function.
: a -> a
The identity function.
.
,
..Function.
: (a -> b) -> (c -> a) -> c -> b
Compose functions.
fix.
,
fix.Function.
: (a -> a) -> a
Fixed point of a function.
error.
,
error.Function.
: Text. -> None
Error.
undefined.
,
undefined.Function.
: None
Same as
error "undefined"
.
seq.
,
seq.Function.
: Any -> a -> a
Evaluate the first argument, then if that’s not “bottom” (error or non-termination), return the second argument.
check.
,
check.Function.
@A: D(A) -> Maybe. A
Check from a dynamic supertype.
coerce.
,
coerce.Function.
@A: D(A) -> A
Coerce from a dynamic supertype.
Action
type
Action.
+a
map.
,
map.Action.
: (a -> b) -> Action. a -> Action. b
pure.
,
pure.Action.
: a -> Action. a
ap.
,
ap.Action.
: Action. (a -> b) -> Action. a -> Action. b
liftA2.
,
liftA2.Action.
: (a -> b -> c) -> Action. a -> Action. b -> Action. c
**
,
**.Action.
: Action. a -> Action. b -> Action. (a *: b)
>>
,
>>.Action.
: Action. Any -> Action. a -> Action. a
>>=
,
>>=.Action.
: Action. a -> (a -> Action. b) -> Action. b
mfix.
,
mfix.Action.
: (a -> Action. a) -> Action. a
The fixed point of an Action.
fail.
,
fail.Action.
: Text. -> Action. None
Fail, causing the program to terminate with error.
stop.
,
stop.Action.
: Action. None
Stop. This is similar to an exception that can be caught with
onStop
. The default handler (for the main program, button presses, etc.), is to catch and ignore it.
onStop.
,
onStop.Action.
: Action. a -> Action. a -> Action. a
onStop p q
doesp
first, and if it stops, then doesq
.
forever.
,
forever.Action.
: Action. Unit. -> Action. None
Run this action repeatedly forever. Use
stop
to break out, propagating the stop.
Same asfn x => let rec fx = x >> fx in fx
.
tryStop.
,
tryStop.Action.
: Action. a -> Action. (Maybe. a)
Run action. If it stops, catch and return
Nothing
.
Same asfn x => onStop (map.Action Just x) $ pure Nothing
.
tryStop_.
,
tryStop_.Action.
: Action. Unit. -> Action. Unit.
Run action. If it stops, catch and return
()
.
Same asfn x => onStop x $ pure ()
.
for_.
,
for_.Action.
: List. a -> (a -> Action. Unit.) -> Action. Unit.
Perform an action on each value of a list.
for.
,
for.Action.
: List. a -> (a -> Action. b) -> Action. (List. b)
Perform an action on each value of a list, returning a list.
sleep.
,
sleep.Action.
: Duration. -> Action. Unit.
Do nothing for this duration.
Lifecycles
Ways of managing the closing of things that get opened, most notably UI windows.
run.Lifecycle.
: Action. a -> Action. a
Close everything that gets opened in the given action.
Example: run $ do openResource; sleep (Seconds 1) end
This opens some resource, sleeps for one second, and then closes it again.
onClose.
,
onClose.Lifecycle.
: Action. Unit. -> Action. Unit.
Add this action as to be done when closing.
Example: run $ do onClose $ outputLn.Env "hello"; sleep (Seconds 1) end
This sleeps for one second, and then outputs “hello” (when the lifecycle closes).
closer.
,
closer.Lifecycle.
: Action. a -> Action. (a *: Action. Unit.)
Get an (idempotent) action that closes what gets opened in the given action.
Example: (cl,r) <- closer openResource
This opens a resource r
, also creating an action cl
, that will close the resource when first called (subsequent calls do nothing).
This action will also be run at the end of the lifecycle, only if it hasn’t already.
Interpretation
This is used as a supertype of various media etc. type to represent “can be interpreted as”.
type
Interpret.
+a
Mk.Interpret.
: a -> Interpret. a
map.Interpret.
: (a -> b) -> Interpret. a -> Interpret. b
interpret.
,
interpret.Interpret.
: Interpret. a -> a
MIME
type
MIME.
text.MIME.
: Prism. MIME. Text.
Models
Models keep track of updates, and will update user interfaces constructed from them when their value changes.
Model
type
Model.
onUpdate.
,
onUpdate.Model.
: Model. -> Action. Unit. -> Action. Unit.
Do this on every update, during this lifecycle.
WholeModel
type
WholeModel.
{-a,+b}
A whole model of type
WholeModel {-p,+q}
has a setting type ofp
and a getting type ofq
.
subtype WholeModel. {} <: Model.
map.WholeModel.
: (a -> b) -> WholeModel. +a -> WholeModel. +b
pure.WholeModel.
: a -> WholeModel. +a
ap.WholeModel.
: WholeModel. +(a -> b) -> WholeModel. +a -> WholeModel. +b
liftA2.WholeModel.
: (a -> b -> c) -> WholeModel. +a -> WholeModel. +b -> WholeModel. +c
**.WholeModel.
: WholeModel. +a -> WholeModel. +b -> WholeModel. +(a *: b)
>>.WholeModel.
: WholeModel. {} -> WholeModel. +a -> WholeModel. +a
immut.WholeModel.
: WholeModel. +a -> WholeModel. +a
Convert a whole model to immutable.
immut.WholeModel r = {%r}
coMap.WholeModel.
: (a -> b) -> WholeModel. {-c,+a} -> WholeModel. {-c,+b}
Map a function on getting a whole model.
contraMap.WholeModel.
: (b -> a) -> WholeModel. {-a,+c} -> WholeModel. {-b,+c}
Map a function on setting a whole model.
maybeLensMap.WholeModel.
: (Maybe. aq -> Maybe. bq) -> (Maybe. bp -> Maybe. aq -> Maybe. (Maybe. ap)) -> WholeModel. {-ap,+aq} -> WholeModel. {-bp,+bq}
Map getter & pushback functions on a whole model.
lensMap.WholeModel.
: (aq -> b) -> (b -> Maybe. aq -> Maybe. ap) -> WholeModel. {-ap,+aq} -> WholeModel. b
Map getter & pushback functions on a whole model.
toMaybe.WholeModel.
: WholeModel. {-a,+b} -> WholeModel. {-(Maybe. a),+(Maybe. b)}
Map known/unknown to
Maybe
for a whole model.
fromMaybe.WholeModel.
: WholeModel. {-(Maybe. a),+(Maybe. b)} -> WholeModel. {-a,+b}
Map
Maybe
to known/unknown for a whole model.
for.WholeModel.
: List. a -> (a -> WholeModel. +b) -> WholeModel. +(List. b)
Traverse a list to make a model of a list.
product.WholeModel.
: WholeModel. {-ap,+aq} -> WholeModel. {-bp,+bq} -> WholeModel. {-(ap *: bp),+(aq *: bq)}
Combine whole models.
unknown.
,
unknown.WholeModel.
: WholeModel. {}
The unknown whole model, representing missing information.
known.
,
known.WholeModel.
: WholeModel. {} -> WholeModel. +Boolean.
True if the whole model is known.
??
,
??.WholeModel.
: WholeModel. +a -> WholeModel. +a -> WholeModel. +a
p ?? q
=p
if it is known, elseq
.
get.
,
get.WholeModel.
: WholeModel. +a -> Action. a
Get a whole model, or
stop
if the whole model is unknown.
:=
,
:=.WholeModel.
: WholeModel. -a -> a -> Action. Unit.
Set a whole model to a value. Stop if failed.
delete.
,
delete.WholeModel.
: WholeModel. {} -> Action. Unit.
Delete a whole model (i.e., make unknown). Stop if failed.
onUpdate.WholeModel.
: WholeModel. +a -> (Maybe. a -> Action. Unit.) -> Action. Unit.
Do an action initially and on every update, during this lifecycle.
newMem.WholeModel.
: Action. (WholeModel. a)
Create a new whole model of memory, initially unknown.
SetModel
type
SetModel.
-a
subtype SetModel. None <: Model.
map.SetModel.
: (a -> b) -> SetModel. b -> SetModel. a
Map a function on a set.
pure.SetModel.
: (a -> Boolean.) -> SetModel. (Entity. & a)
Convert a predicate to a set.
predicate.SetModel.
: WholeModel. {-((Entity. & a) -> Boolean.),+(a -> Boolean.)} -> SetModel. (Entity. & a)
Convert a predicate model to a set.
immut.SetModel.
: SetModel. a -> SetModel. a
Convert a set to immutable.
+=
,
+=.SetModel.
: SetModel. a -> a -> Action. Unit.
Add an entity to a set.
-=
,
-=.SetModel.
: SetModel. a -> a -> Action. Unit.
Remove an entity from a set.
member.
,
member.SetModel.
: SetModel. a -> WholeModel. +a -> WholeModel. Boolean.
A model of the membership of a value in a set.
empty.SetModel.
: SetModel. Entity.
The immutable empty set.
full.SetModel.
: SetModel. Entity.
The immutable full set.
not.SetModel.
: SetModel. a -> SetModel. a
Complement of a set. The resulting set can be added to (deleting from the original set) and deleted from (adding to the original set).
<&>
,
<&>.SetModel.
: SetModel. a -> SetModel. a -> SetModel. a
Intersection of sets. The resulting set can be added to (adding to both sets), but not deleted from.
<|>
,
<|>.SetModel.
: SetModel. a -> SetModel. a -> SetModel. a
Union of sets. The resulting set can be deleted from (deleting from both sets), but not added to.
<\>
,
<\>.SetModel.
: SetModel. a -> SetModel. a -> SetModel. a
Difference of sets, everything in the first set but not the second. The resulting set can be added to (adding to the first and deleting from the second), but not deleted from.
<^>
,
<^>.SetModel.
: SetModel. a -> SetModel. a -> SetModel. a
Symmetric difference of sets, everything in exactly one of the sets. The resulting set will be read-only.
<+>
,
<+>.SetModel.
: SetModel. a -> SetModel. b -> SetModel. (a +: b)
Cartesian sum of sets.
<*>
,
<*>.SetModel.
: SetModel. a -> SetModel. b -> SetModel. (a *: b)
Cartesian product of sets. The resulting set will be read-only.
FiniteSetModel
type
FiniteSetModel.
{-a,+b}
subtype FiniteSetModel. -a <: SetModel. a
coMap.FiniteSetModel.
: (a -> b) -> FiniteSetModel. {-c,+a} -> FiniteSetModel. {-c,+b}
Map a function on getting from a finite set.
contraMap.FiniteSetModel.
: (b -> a) -> FiniteSetModel. {-a,+c} -> FiniteSetModel. {-b,+c}
Map a function on setting to and testing a finite set.
filter.FiniteSetModel.
: (aq -> Boolean.) -> FiniteSetModel. {-ap,+aq} -> FiniteSetModel. {-ap,+aq}
Filter a finite set.
maybeMap.FiniteSetModel.
: (aq -> Maybe. b) -> FiniteSetModel. {-ap,+aq} -> FiniteSetModel. {b,-ap}
Map and filter a function on a finite set.
collect.FiniteSetModel.
: WholeModel. +(aq -> Maybe. b) -> FiniteSetModel. {-ap,+aq} -> FiniteSetModel. {b,-ap}
Map and filter a function from a model on a finite set.
<:&>
,
<:&>.FiniteSetModel.
: FiniteSetModel. {-a,+b} -> SetModel. b -> FiniteSetModel. {-a,+b}
Intersect a finite set with any set. The resulting finite set will be read-only.
<:\>
,
<:\>.FiniteSetModel.
: FiniteSetModel. {-a,+b} -> SetModel. b -> FiniteSetModel. {-a,+b}
Difference of a finite set and any set. The resulting finite set will be read-only.
<:&:>
,
<:&:>.FiniteSetModel.
: FiniteSetModel. {a,+Entity.} -> FiniteSetModel. {a,+Entity.} -> FiniteSetModel. {a,-Entity.}
Intersection of finite sets. The resulting finite set can be added to, but not deleted from.
<:|:>
,
<:|:>.FiniteSetModel.
: FiniteSetModel. {a,+Entity.} -> FiniteSetModel. {a,+Entity.} -> FiniteSetModel. {a,-Entity.}
Union of finite sets. The resulting finite set can be deleted from, but not added to.
<:+:>
,
<:+:>.FiniteSetModel.
: FiniteSetModel. {-ap,+aq} -> FiniteSetModel. {-bp,+bq} -> FiniteSetModel. {-(ap +: bp),+(aq +: bq)}
Cartesian sum of finite sets.
<:*:>
,
<:*:>.FiniteSetModel.
: FiniteSetModel. {-ap,+aq} -> FiniteSetModel. {-bp,+bq} -> FiniteSetModel. {-(ap *: bp),+(aq *: bq)}
Cartesian product of finite sets. The resulting finite set will be read-only.
fromList.FiniteSetModel.
: WholeModel. {-(List. a),+(List. (Entity. & a))} -> FiniteSetModel. {a,-Entity.}
Represent a model of a list as a finite set. Changing the set may scramble the order of the list.
single.FiniteSetModel.
: FiniteSetModel. {+Entity.,+a} -> WholeModel. +a
The member of a single-member finite set, or unknown.
count.FiniteSetModel.
: FiniteSetModel. {} -> WholeModel. +Integer.
Count of members in a finite set.
clear.FiniteSetModel.
: FiniteSetModel. {} -> Action. Unit.
Remove all entities from a finite set.
toList.FiniteSetModel.
: ModelOrder. a -> FiniteSetModel. +a -> WholeModel. +(List. a)
All members of a finite set, by an order.
getList.FiniteSetModel.
: ModelOrder. a -> FiniteSetModel. +a -> Action. (ListModel. +a)
Get all members of a finite set, by an order. The resulting
ListModel
will behave more “list-like” thantoList.FiniteSetModel
.
newMem.FiniteSetModel.
: Action. (FiniteSetModel. {a,-Entity.})
Create a new finite set model of memory, initially empty.
ListModel
type
ListModel.
{-a,+b}
subtype ListModel. {} <: Model.
subtype ListModel. a <: WholeModel. (List. a)
fromWhole.ListModel.
: WholeModel. (List. a) -> ListModel. a
Represent a whole model as a list model.
getCount.ListModel.
: ListModel. {} -> Action. Integer.
Get Count of elements in a list model.
getItem.ListModel.
: Integer. -> ListModel. +q -> Action. q
Get an element of a list model.
insert.ListModel.
: Integer. -> p -> ListModel. -p -> Action. Unit.
Insert an element in a list model.
set.ListModel.
: Integer. -> p -> ListModel. -p -> Action. Unit.
Set an element of a list model.
delete.ListModel.
: Integer. -> ListModel. {} -> Action. Unit.
Delete an element of a list model.
clear.ListModel.
: ListModel. {} -> Action. Unit.
Delete all elements of a list model.
count.ListModel.
: ListModel. {} -> WholeModel. +Integer.
Model of a count of elements in a list model.
item.ListModel.
: Boolean. -> Integer. -> ListModel. {-p,+q} -> Action. (WholeModel. {-p,+q})
Get a whole model of a particular item in the list. It will track the item as the list changes. Pass
True
for an existing item,False
for a point between items.
immut.ListModel.
: ListModel. +a -> ListModel. +a
Convert a list model to immutable.
newMem.ListModel.
: Action. (ListModel. a)
Create a new list model of memory, initially empty.
TextModel
type
TextModel.
subtype TextModel. <: WholeModel. Text.
fromWhole.TextModel.
: WholeModel. Text. -> TextModel.
Represent a whole model as a text model.
getLength.TextModel.
: TextModel. -> Action. Integer.
Get the length of text.
get.TextModel.
: TextModel. -> Action. Text.
Get the whole text.
set.TextModel.
: Text. -> TextModel. -> Action. Unit.
Set the whole text.
getSection.TextModel.
: Integer. *: Integer. -> TextModel. -> Action. Text.
Get a (start,length) section of the text.
setSection.TextModel.
: Integer. *: Integer. -> Text. -> TextModel. -> Action. Unit.
Set a (start,length) section of the text.
section.TextModel.
: Integer. *: Integer. -> TextModel. -> Action. TextModel.
Create a model of a (start,length) section of a text model. It will track the section as the text changes.
newMem.TextModel.
: Action. TextModel.
Create a new text model of memory, initially empty.
Optics & Properties
Lens
type
Lens.
{-a,+b} {-c,+d}
Mk.Lens.
: (ap -> bq) -> (ap -> bp -> aq) -> Lens. {-ap,+aq} {-bp,+bq}
subtype Lens. {-ap,+aq} {-bp,+bq} <: Attribute. {-ap,+aq} {-bp,+bq}
fetch.
,
fetch.Lens.
: Lens. {-ap,+aq} {-bp,+bq} -> ap -> bq
putback.
,
putback.Lens.
: Lens. {-ap,+aq} {-bp,+bq} -> ap -> bp -> aq
id.Lens.
: Lens. {-x,+y} {-y,+x}
Identity lens.
..Lens.
: Lens. {-bx,+by} {-cp,+cq} -> Lens. {-ap,+aq} {-by,+bx} -> Lens. {-ap,+aq} {-cp,+cq}
Compose lenses.
product.Lens.
: Lens. a {-bp,+bq} -> Lens. a {-cp,+cq} -> Lens. a {-(bp *: cp),+(bq *: cq)}
Product of lenses.
sum.Lens.
: Lens. {-ap,+aq} {-cp,+cq} -> Lens. {-bp,+bq} {-cp,+cq} -> Lens. {-(ap +: bp),+(aq +: bq)} {-cp,+cq}
Sum of lenses.
Prism
type
Prism.
{-a,+b} {-c,+d}
Mk.Prism.
: (ap -> aq +: bq) -> (bp -> aq) -> Prism. {-ap,+aq} {-bp,+bq}
subtype Prism. {-ap,+aq} {-bp,+bq} <: Attribute. {-ap,+aq} {-bp,+bq}
decode.
,
decode.Prism.
: Prism. {-ap,+aq} {-bp,+bq} -> ap -> Maybe. bq
encode.
,
encode.Prism.
: Prism. {-ap,+aq} {-bp,+bq} -> bp -> aq
id.Prism.
: Prism. {-x,+y} {-y,+x}
Identity prism.
..Prism.
: Prism. {-bx,+by} {-cp,+cq} -> Prism. {-ap,+aq} {-by,+bx} -> Prism. {-ap,+aq} {-cp,+cq}
Compose prisms.
reverse.Prism.
: Prism. {-ap,+aq} {-bp,+bq} -> Attribute. {-bp,+bq} {-ap,+aq}
Attribute
Attributes relate entities.
type
Attribute.
{-a,+b} {-c,+d}
id.Attribute.
: Attribute. {-x,+y} {-y,+x}
The identity attribute.
..Attribute.
: Attribute. {-bx,+by} {-cp,+cq} -> Attribute. {-ap,+aq} {-by,+bx} -> Attribute. {-ap,+aq} {-cp,+cq}
Compose attributes.
**.Attribute.
: Attribute. {-ap,+Entity.,+aq} {-bp,+bq} -> Attribute. {-ap,+Entity.,+aq} {-cp,+cq} -> Attribute. {-ap,+aq} {-(bp *: cp),+(bq *: cq)}
Type product of attributes. Models from these attributes are undeleteable.
++.Attribute.
: Attribute. {-ap,+aq} {-cp,+cq} -> Attribute. {-bp,+bq} {-cp,+cq} -> Attribute. {-(ap +: bp),+(aq +: bq)} {-cp,+cq}
Type sum of attributes. Models from these attributes are undeleteable.
!$
,
!$.Attribute.
: Attribute. {-ap,+aq} {-bp,+bq} -> WholeModel. {-aq,+ap} -> WholeModel. {-bp,+bq}
Apply an attribute to a model.
!$%
,
!$%.Attribute.
: Attribute. -a {-bp,+bq} -> WholeModel. +a -> WholeModel. {-bp,+bq}
Apply an attribute to an immutable model.
m !$% r = m !$ immut.WholeModel r
!$$
,
!$$.Attribute.
: Attribute. -a {+Entity.,+b} -> FiniteSetModel. +a -> FiniteSetModel. {b,-Entity.}
Apply an attribute to a set.
Property
Properties relate entities.
type
Property.
{-a,+b} {-c,+d}
subtype Property. {-ap,+aq} {-bp,+bq} <: Attribute. {-ap,+aq} {-bp,+bq}
id.Property.
: Property. {-x,+y} {-y,+x}
The identity property.
..Property.
: Property. {-bx,+by} {-cp,+cq} -> Property. {-ap,+aq} {-by,+bx} -> Property. {-ap,+aq} {-cp,+cq}
Compose properties.
**.Property.
: Property. {-ap,+Entity.,+aq} {-bp,+bq} -> Property. {-ap,+Entity.,+aq} {-cp,+cq} -> Property. {-ap,+aq} {-(bp *: cp),+(bq *: cq)}
Type product of properties. Models from these properties are undeleteable.
++.Property.
: Property. {-ap,+aq} {-cp,+cq} -> Property. {-bp,+bq} {-cp,+cq} -> Property. {-(ap +: bp),+(aq +: bq)} {-cp,+cq}
Type sum of properties. Models from these properties are undeleteable.
!@
,
!@.Property.
: Property. {a,+Entity.} {-bx,+by} -> WholeModel. {-by,+bx} -> FiniteSetModel. {a,-Entity.}
Co-apply a property to a model.
!@%
,
!@%.Property.
: Property. {a,+Entity.} -b -> WholeModel. +b -> FiniteSetModel. {a,-Entity.}
Co-apply a property to an immutable model.
m !@% r = m !@ immut.WholeModel r
!@@
,
!@@.Property.
: Property. {a,+Entity.} {-bx,+by} -> FiniteSetModel. {-by,+bx} -> FiniteSetModel. {a,-Entity.}
Co-apply a property to a set.
ModelOrder
type
ModelOrder.
-a
subtype a -> a -> Ordering. <: ModelOrder. a
<>.ModelOrder.
: ModelOrder. a -> ModelOrder. a -> ModelOrder. a
concat1.ModelOrder.
: List1.List. (ModelOrder. a) -> ModelOrder. a
empty.ModelOrder.
: ModelOrder. a
concat.ModelOrder.
: List. (ModelOrder. a) -> ModelOrder. a
map.ModelOrder.
: (b -> a) -> ModelOrder. a -> ModelOrder. b
Map a function on a
ModelOrder
.
on.ModelOrder.
: Attribute. -b +a -> ModelOrder. a -> ModelOrder. b
Order by a
ModelOrder
on a particular property.
reverse.ModelOrder.
: ModelOrder. a -> ModelOrder. a
Reverse a
ModelOrder
.
whole.ModelOrder.
: ModelOrder. a -> WholeModel. +a -> WholeModel. +a -> WholeModel. +Ordering.
Order two whole models.
Task
type
Task.
+a
A task is something that can be waited for to give a result.
map.Task.
: (a -> b) -> Task. a -> Task. b
pure.Task.
: a -> Task. a
ap.Task.
: Task. (a -> b) -> Task. a -> Task. b
liftA2.Task.
: (a -> b -> c) -> Task. a -> Task. b -> Task. c
**.Task.
: Task. a -> Task. b -> Task. (a *: b)
>>.Task.
: Task. Any -> Task. a -> Task. a
async.Task.
: Action. a -> Action. (Task. a)
Run an action in another thread. It will complete in the current life cycle.
await.Task.
: Task. a -> Action. a
Wait for a task to complete. This action is idempotent.
check.Task.
: Task. a -> Action. (Maybe. a)
Check to see if a task is done without waiting.
isDone.Task.
: Task. Any -> Action. Boolean.
Check whether a task is done.
time.Task.
: Time. -> Task. Unit.
A task that is done at this time.
duration.Task.
: Duration. -> Action. (Task. Unit.)
A task that will be done after this duration.
race.Task.
: List. (Task. a) -> Action. (Task. a)
Whichever task is done first.
Stream
Sinks and sources.
ItemOrEnd
type
ItemOrEnd.
+a
Either an item, or end (meaning end of stream).
Item.ItemOrEnd.
: a -> ItemOrEnd. a
Construct an
ItemOrEnd
representing an item.
End.ItemOrEnd.
: ItemOrEnd. None
Construct an
ItemOrEnd
representing end of stream.
Sink
type
Sink.
-a
A sink is something you can write data (and “end”) to.
Mk.Sink.
: (ItemOrEnd. a -> Action. Unit.) -> Sink. a
Construct a
Sink
from a function.
map.Sink.
: (a -> b) -> Sink. b -> Sink. a
write.Sink.
: Sink. a -> a -> Action. Unit.
Write an item to a sink.
writeEnd.Sink.
: Sink. None -> Action. Unit.
Write end to a sink. You should not write to the sink after this.
writeLn.Sink.
: Sink. Text. -> Text. -> Action. Unit.
Write text followed by a newline to a text sink.
Source
type
Source.
+a
A source is something you can read data from.
map.Source.
: (a -> b) -> Source. a -> Source. b
isReady.Source.
: Source. Any -> Action. Boolean.
Does this source have data available now?
read.Source.
: Source. a -> Action. (ItemOrEnd. a)
Read data (or end), waiting if necessary.
readAvailable.Source.
: Source. a -> Action. (Maybe. (ItemOrEnd. a))
Read data (or end), if it is now available.
readAllAvailable.Source.
: Source. a -> Action. (List. a *: Boolean.)
Read all data now available. Second value is set if end was read.
gather.Source.
: Source. a -> Action. (List. a)
Gather all data (until end) from a source.
listSource.Source.
: List. a -> Action. (Source. a)
Create a source for a list of items.
connect.Source.
: Source. a -> Sink. a -> Action. Unit.
Read all data (until end) from a source and write it to a sink, as it becomes available. Does not write end to the sink.
createPipe.Source.
: Action. (Sink. a *: Source. a)
Create a pipe. Data written to the sink will be added to a buffer, which can be read from with the source. Can be used to transfer data between asynchronous tasks.
lineBuffer.Source.
: Source. Text. -> Action. (Source. Text.)
Get a line-buffering source from a text source. Each read will be exactly one line.
Storage
type
Store.
Storage of information.
property.
,
property.Store.
@A @B <anchor>: Store. -> Property. A B
A property for this anchor.
A
andB
are types that are subtypes ofEntity
.
openDefault.Store.
: Action. Store.
Open the default
Store
. Will be closed at the end of the lifecycle.
Undo
Undo and redo changes to models.
type
UndoHandler.
A queue of undo (and redo) actions.
new.UndoHandler.
: Action. UndoHandler.
Create a new
UndoHandler
.
queueUndo.
,
queueUndo.UndoHandler.
: UndoHandler. -> Action. Boolean.
Undo an action.
queueRedo.
,
queueRedo.UndoHandler.
: UndoHandler. -> Action. Boolean.
Redo an action.
handleStore.UndoHandler.
: UndoHandler. -> Store. -> Action. Store.
Handle undo/redo for this model.
handleWholeModel.UndoHandler.
: UndoHandler. -> WholeModel. a -> WholeModel. a
Handle undo/redo for this model.
handleTextModel.UndoHandler.
: UndoHandler. -> TextModel. -> TextModel.
Handle undo/redo for this model.
handleListModel.UndoHandler.
: UndoHandler. -> ListModel. a -> ListModel. a
Handle undo/redo for this model.
handleFiniteSetModel.UndoHandler.
: UndoHandler. -> FiniteSetModel. {-p,+q} -> FiniteSetModel. {-p,+q}
Handle undo/redo for this model.
handleSetModel.UndoHandler.
: UndoHandler. -> SetModel. a -> SetModel. (Entity. & a)
Handle undo/redo for this model.
Env
The environment in which the script was invoked.
scriptName.Env.
: Text.
The name of the script.
arguments.Env.
: List. Text.
Arguments passed to the script.
variables.Env.
: List. (Text. *: Text.)
Environment variables.
getVar.Env.
: Text. -> Maybe. Text.
Get environment variable.
stdin.Env.
: Source. Text.
Standard input source.
stdout.Env.
: Sink. Text.
Standard output sink.
stderr.Env.
: Sink. Text.
Standard error/diagnostics sink.
outputLn.Env.
: Text. -> Action. Unit.
Output text and a newline to standard output. Same as
writeLn stdout
.
Eval
evaluate.Eval.
@A: Text. -> Action. (Text. +: A)
A function that evaluates text as a Pinafore expression to be subsumed to positive type
A
.
The result of the action is either the value (Right
), or an error message (Left
).
The local scope is not in any way transmitted to the evaluation.
Debug
Functions for debugging.
message.Debug.
: Text. -> Action. Unit.
Debug message to std error.
checkEntity.Debug.
: Text. -> Entity. -> Action. Unit.
debugCheckEntity
literalLength.Debug.
: Literal. -> Integer.
Byte length of a Literal
literalIsEmbedded.Debug.
: Literal. -> Boolean.
Is this Literal embeddable in an Entity?