Commit b71e3e07b9883ee11f544a399c1eb3da8b258835

Thomas de Grivel 2024-09-16T04:24:32

document modules

diff --git a/doc/1_KC3/1.1_Introduction.en.md b/doc/1_KC3/1.1_Introduction.en.md
index d4dd902..0f08a18 100644
--- a/doc/1_KC3/1.1_Introduction.en.md
+++ b/doc/1_KC3/1.1_Introduction.en.md
@@ -25,10 +25,35 @@ Everything in KC3 is in a module. A module is a namespace,
 and is named with a symbol starting with a uppercase character.
 For instance `Sym` and `Str` are valid module names.
 
+Use defmodule to define a module. Example :
+```
+defmodule Test do
+  def one = 1
+  def double = fn (x) { x * 2 }
+  def add = cfn Tag "tag_add" (Tag, Tag, Result)
+end
+```
+
 Each module can define a type and a module name can also be a
 type name if the corresponding module defines a type.
 
-The module can also include definitions for functions for
+Use defstruct to define a struct type in a module. The struct will have
+the same name as the module. Example :
+```
+ikc3> defmodule Test do
+ikc3>   defstruct [x: (F32) 0.0,
+ikc3>              y: (F32) 0.0]
+ikc3> end
+ikc3> a = %Test{}
+%Test{x: (F32) 0.0,
+      y: (F32) 0.0}
+ikc3> a.x
+(F32) 0.0
+ikc3> a.y
+(F32) 0.0
+```
+
+The module can also include definitions for constants or functions for
 operating on the module type or other types.
 
 The default module is `KC3`, which is defined as facts (triples)