all repos — min @ 0cdd541ad933bc62d3dbde84a86fceec4a43661e

A small but practical concatenative programming language.

Updated docs.
h3rald h3rald@h3rald.com
Fri, 15 Jan 2021 20:58:25 +0000
commit

0cdd541ad933bc62d3dbde84a86fceec4a43661e

parent

af4f4ccdc727879c3624fe8d951af2c44d574a20

M next-release.mdnext-release.md

@@ -3,5 +3,5 @@ * Added **sealed?** and **sealed-sigil?** symbols.

+ **floor** and **ceil** now correctly return an integer again. * Added **abs** symbol. * Now executing min shell if no file is specified (unless input is piped in), without the need of specifying **-i**. -* Implemented the possibility to define type classes. +* Implemented the possibility to define type classes using the **typeclass** symbol. * Added **stringlike?** symbol.
M site/contents/learn-data-types.mdsite/contents/learn-data-types.md

@@ -5,7 +5,7 @@ -----

{@ _defs_.md || 0 @} -The type system of min is very simple -- only the following data types are available: +The following data types are availanle in {{m}}: null : null value.

@@ -33,9 +33,26 @@ > "concatenative" :paradigm

> 2017 :"first release year" > } -The {#link-module||logic#} provides predicate operators to check if an element belongs to a particular data type or pseudo-type (`boolean?`, `number?`, `integer?`, `float?`, `string?`, `quotation?`, `dictionary?`). +Additionally, dictionaries can also be typed to denote complex objects like sockets, errors, etc. For example, the following dictionary defines an error: + + { + "MyError" :error + "An error occurred" :message + "symbol1" :symbol + "dir1/file1.min" :filename + 3 :line + 13 :column + ;error + } -Additionally, the {#link-module||lang#} provides operators to convert values from a data type to another (e.g. {#link-operator||lang||int#}, {#link-operator||lang||string#}, and so on). +> %tip% +> Tip +> +> The {#link-operator||dict||dtype#} operator can be used to set the type of a dictionary. + +The {#link-module||logic#} provides predicate operators to check if an element belongs to a particular data type or pseudo-type (`boolean?`, `number?`, `integer?`, `float?`, ...). + +Additionally, the {#link-module||lang#} provides operators to convert values from a data type to another (e.g. {#link-operator||lang||integer#}, {#link-operator||lang||string#}, and so on). > %note% > Note
M site/contents/reference-lang.mdsite/contents/reference-lang.md

@@ -499,6 +499,7 @@ Converts {{any}} into a JSON string.#}

{#op||to-yaml||{{any}}||{{s}}|| > Converts {{any}} into a YAML string. +> > > %note% > > Note > >

@@ -523,6 +524,24 @@ > > (pop)

> > (format-error puts) > > (0) > > ) try #} + +{#op||typeclass||{{q}} {{sl}}||{{none}}|| +> Defines a new type class {{sl}} set to quotation {{q}}, which can be used in operator signatures. +> +> > %sidebar% +> > Example +> > +> > Consider the following type class which defines a natural number: +> > +> > (:n ((n integer?) (n 0 >)) &&) 'natural typeclass +> > +> > It can now be used in operator signatures, like this: +> > +> > ( +> > symbol natural-sum +> > (natural :n natural :m ==> natural :result) +> > (n m + @result) +> > ) :: #} {#op||unless||{{q1}} {{q2}}||{{a0p}}|| If {{1}} evaluates to {{f}} then evaluates {{2}}.#}
M site/contents/reference-logic.mdsite/contents/reference-logic.md

@@ -76,6 +76,12 @@

{#op||quotation?||{{any}}||{{b}}|| Returns {{t}} if {{any}} is a quotation, {{f}} otherwise. #} +{#op||string?||{{any}}||{{b}}|| +Returns {{t}} if {{any}} is a string, {{f}} otherwise. #} + +{#op||stringlike?||{{any}}||{{b}}|| +Returns {{t}} if {{any}} is a string or a quoted symbol, {{f}} otherwise. #} + {#op||type?||{{any}} {{sl}}||{{b}}|| Returns {{t}} if the data type of {{any}} is the specified type {{sl}}, {{f}} otherwise. #}