Remove linearity subtyping
It's disappointing to have to do this, but I think necessary because
various issue reports have shown it to be unsound (at least as far as
inference goes) and, at the very least, confusing. This patch brings us
back to the basic rules of QTT.
On the one hand, this makes the 1 multiplicity less useful, because it
means we can't flag arguments as being used exactly once which would be
useful for optimisation purposes as well as precision in the type. On
the other hand, it removes some complexity (and a hack) from
unification, and has the advantage of being correct! Also, I still
consider the 1 multiplicity an experiment.
We can still do interesting things like protocol state tracking, which
is my primary motivation at least.
Ideally, if the 1 multiplicity is going to be more generall useful,
we'll need some kind of way of doing multiplicity polymorphism in the
future. I don't think subtyping is the way (I've pretty much always come
to regret adding some form of subtyping).
Fixes #73 (and maybe some others).
2020-12-27 22:58:35 +03:00
|
|
|
Main> Prelude.plus : Nat -> Nat -> Nat
|
2020-07-08 17:52:57 +03:00
|
|
|
Add two natural numbers.
|
|
|
|
@ x the number to case-split on
|
|
|
|
@ y the other numberpublic export
|
|
|
|
|
|
|
|
Totality: total
|
2020-07-08 18:52:56 +03:00
|
|
|
Main> Prelude.Nat : Type
|
2020-07-08 17:52:57 +03:00
|
|
|
Natural numbers: unbounded, unsigned integers which can be pattern matched.
|
|
|
|
|
|
|
|
Constructors:
|
2020-07-08 18:52:56 +03:00
|
|
|
Z : Nat
|
2020-07-08 17:52:57 +03:00
|
|
|
Zero.
|
Remove linearity subtyping
It's disappointing to have to do this, but I think necessary because
various issue reports have shown it to be unsound (at least as far as
inference goes) and, at the very least, confusing. This patch brings us
back to the basic rules of QTT.
On the one hand, this makes the 1 multiplicity less useful, because it
means we can't flag arguments as being used exactly once which would be
useful for optimisation purposes as well as precision in the type. On
the other hand, it removes some complexity (and a hack) from
unification, and has the advantage of being correct! Also, I still
consider the 1 multiplicity an experiment.
We can still do interesting things like protocol state tracking, which
is my primary motivation at least.
Ideally, if the 1 multiplicity is going to be more generall useful,
we'll need some kind of way of doing multiplicity polymorphism in the
future. I don't think subtyping is the way (I've pretty much always come
to regret adding some form of subtyping).
Fixes #73 (and maybe some others).
2020-12-27 22:58:35 +03:00
|
|
|
S : Nat -> Nat
|
2020-07-08 17:52:57 +03:00
|
|
|
Successor.
|
Remove linearity subtyping
It's disappointing to have to do this, but I think necessary because
various issue reports have shown it to be unsound (at least as far as
inference goes) and, at the very least, confusing. This patch brings us
back to the basic rules of QTT.
On the one hand, this makes the 1 multiplicity less useful, because it
means we can't flag arguments as being used exactly once which would be
useful for optimisation purposes as well as precision in the type. On
the other hand, it removes some complexity (and a hack) from
unification, and has the advantage of being correct! Also, I still
consider the 1 multiplicity an experiment.
We can still do interesting things like protocol state tracking, which
is my primary motivation at least.
Ideally, if the 1 multiplicity is going to be more generall useful,
we'll need some kind of way of doing multiplicity polymorphism in the
future. I don't think subtyping is the way (I've pretty much always come
to regret adding some form of subtyping).
Fixes #73 (and maybe some others).
2020-12-27 22:58:35 +03:00
|
|
|
Main> Prelude.List : Type -> Type
|
2020-07-08 17:52:57 +03:00
|
|
|
Generic lists.
|
|
|
|
|
|
|
|
Constructors:
|
2020-07-08 18:52:56 +03:00
|
|
|
Nil : List a
|
2020-07-08 17:52:57 +03:00
|
|
|
Empty list
|
Remove linearity subtyping
It's disappointing to have to do this, but I think necessary because
various issue reports have shown it to be unsound (at least as far as
inference goes) and, at the very least, confusing. This patch brings us
back to the basic rules of QTT.
On the one hand, this makes the 1 multiplicity less useful, because it
means we can't flag arguments as being used exactly once which would be
useful for optimisation purposes as well as precision in the type. On
the other hand, it removes some complexity (and a hack) from
unification, and has the advantage of being correct! Also, I still
consider the 1 multiplicity an experiment.
We can still do interesting things like protocol state tracking, which
is my primary motivation at least.
Ideally, if the 1 multiplicity is going to be more generall useful,
we'll need some kind of way of doing multiplicity polymorphism in the
future. I don't think subtyping is the way (I've pretty much always come
to regret adding some form of subtyping).
Fixes #73 (and maybe some others).
2020-12-27 22:58:35 +03:00
|
|
|
:: : a -> List a -> List a
|
2020-07-08 18:52:56 +03:00
|
|
|
Main> Prelude.Show : Type -> Type
|
2020-07-08 17:52:57 +03:00
|
|
|
Things that have a canonical `String` representation.
|
2020-07-08 19:21:28 +03:00
|
|
|
Parameters: ty
|
2020-07-08 17:52:57 +03:00
|
|
|
|
2020-07-08 18:52:56 +03:00
|
|
|
Methods:
|
2020-07-08 19:21:28 +03:00
|
|
|
show : (x : ty) -> String
|
2020-07-08 18:52:56 +03:00
|
|
|
Convert a value to its `String` representation.
|
|
|
|
@ x the value to convert
|
2020-07-08 19:21:28 +03:00
|
|
|
showPrec : (d : Prec) -> (x : ty) -> String
|
2020-07-08 18:52:56 +03:00
|
|
|
Convert a value to its `String` representation in a certain precedence
|
|
|
|
context.
|
|
|
|
|
|
|
|
A value should produce parentheses around itself if and only if the given
|
|
|
|
precedence context is greater than or equal to the precedence of the
|
|
|
|
outermost operation represented in the produced `String`. *This is
|
|
|
|
different from Haskell*, which requires it to be strictly greater. `Open`
|
|
|
|
should thus always produce *no* outermost parens, `App` should always
|
|
|
|
produce outermost parens except on atomic values and those that provide
|
|
|
|
their own bracketing, like `Pair` and `List`.
|
|
|
|
@ d the precedence context.
|
|
|
|
@ x the value to convert
|
|
|
|
|
2020-07-08 19:21:28 +03:00
|
|
|
Implementations:
|
|
|
|
Show Int
|
|
|
|
Show Integer
|
|
|
|
Show Bits8
|
|
|
|
Show Bits16
|
|
|
|
Show Bits32
|
|
|
|
Show Bits64
|
|
|
|
Show Double
|
|
|
|
Show Char
|
|
|
|
Show String
|
|
|
|
Show Nat
|
|
|
|
Show Bool
|
|
|
|
Show ()
|
|
|
|
(Show a, Show b) => Show (a, b)
|
|
|
|
(Show a, Show (p y)) => Show (DPair a p)
|
|
|
|
Show a => Show (List a)
|
|
|
|
Show a => Show (Maybe a)
|
|
|
|
(Show a, Show b) => Show (Either a b)
|
2020-07-08 18:52:56 +03:00
|
|
|
Main> Prelude.show : Show ty => ty -> String
|
2020-07-08 17:52:57 +03:00
|
|
|
Convert a value to its `String` representation.
|
|
|
|
@ x the value to convert
|
|
|
|
|
|
|
|
Totality: total
|
2020-07-08 19:21:28 +03:00
|
|
|
Main> Prelude.Monad : (Type -> Type) -> Type
|
|
|
|
Parameters: m
|
|
|
|
Constraints: Applicative m
|
|
|
|
|
|
|
|
Methods:
|
|
|
|
>>= : m a -> (a -> m b) -> m b
|
|
|
|
Also called `bind`.
|
|
|
|
join : m (m a) -> m a
|
|
|
|
Also called `flatten` or mu.
|
|
|
|
|
|
|
|
Implementations:
|
2020-07-12 17:54:10 +03:00
|
|
|
Monad IO
|
2020-07-08 19:21:28 +03:00
|
|
|
Monad Maybe
|
|
|
|
Monad (Either e)
|
|
|
|
Monad List
|
2020-07-08 17:52:57 +03:00
|
|
|
Main> Bye for now!
|