mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-15 14:23:32 +03:00
6a53e0177c
This is partly to tidy things up, but also a good test for 'import as'. Requires some internal changes since there are parts of reflection, unelaboration and a compiler hack that rely on where things are in the Prelude.
87 lines
2.1 KiB
Plaintext
87 lines
2.1 KiB
Plaintext
Main> Prelude.plus : (1 _ : Nat) -> (1 _ : Nat) -> Nat
|
|
Add two natural numbers.
|
|
@ x the number to case-split on
|
|
@ y the other numberpublic export
|
|
|
|
Totality: total
|
|
Main> Prelude.Nat : Type
|
|
Natural numbers: unbounded, unsigned integers which can be pattern matched.
|
|
|
|
Constructors:
|
|
Z : Nat
|
|
Zero.
|
|
S : (1 _ : Nat) -> Nat
|
|
Successor.
|
|
|
|
Main> Prelude.List : (1 _ : Type) -> Type
|
|
Generic lists.
|
|
|
|
Constructors:
|
|
Nil : List a
|
|
Empty list
|
|
:: : (1 _ : a) -> (1 _ : List a) -> List a
|
|
|
|
Main> Prelude.Show : Type -> Type
|
|
Things that have a canonical `String` representation.
|
|
Parameters: ty
|
|
|
|
Methods:
|
|
show : (x : ty) -> String
|
|
Convert a value to its `String` representation.
|
|
@ x the value to convert
|
|
showPrec : (d : Prec) -> (x : ty) -> String
|
|
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
|
|
|
|
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)
|
|
|
|
Main> Prelude.show : Show ty => ty -> String
|
|
Convert a value to its `String` representation.
|
|
@ x the value to convert
|
|
|
|
Totality: total
|
|
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:
|
|
Monad IO
|
|
Monad Maybe
|
|
Monad (Either e)
|
|
Monad List
|
|
|
|
Main> Bye for now!
|