tony-lang / prelude

Standard library of the Tony programming language
https://tony-lang.github.io
MIT License
0 stars 0 forks source link

First version of prelude #10

Open jonhue opened 3 years ago

jonhue commented 3 years ago
type Void = Void
type Nothing = ()
type Maybe(T) = nothing | just(T)
type Either(T, U) = left(T) | right(U)
type Const(T, U) = const(T)
type Identity(T) = identity(T)

type Map(T, U) = [(T, U)]

type IO(T) = io(T)

io->print :: <T <: Show> T -> IO(Nothing)
io->input :: () -> IO(String)

- :: Number -> Number
! :: T -> Boolean
^ :: Number -> Number -> Number
* :: Number -> Number -> Number
/ :: Number -> Number -> Number
+ :: Number -> Number -> Number
- :: Number -> Number -> Number
% :: Number -> Number -> Number
< :: Number -> Number -> Number
<= :: Number -> Number -> Number
> :: Number -> Number -> Number
>= :: Number -> Number -> Number
== :: T -> T -> Boolean
!= :: T -> T -> Boolean
=== :: T -> T -> Boolean
!== :: T -> T -> Boolean
&& :: T -> U -> Boolean
|| :: T -> U -> Boolean
==> :: T -> U -> Boolean
<=> :: T -> U -> Boolean

. :: T -> (T -> U) -> U
&. ::  T? -> (T -> U) -> U?
o :: (U -> V) -> (T -> U) -> (T -> V)
-> :: <U <: @T> T -> U -> T[U]

to_boolean :: String -> Boolean
to_number :: String -> Number
to_string :: T -> String

abs :: Number -> Number

unit :: ()
absurd :: Void -> T

Follow-ups:

jonhue commented 3 years ago

first idea for a stdlib https://github.com/jonhue/quik/issues/58