PersonStudy
This is a simple ML study. It explores concepts like signature, structure, type aliases, and template matching.
Person
structure
The Person
structure is the main one. Its API has three functions:
Person.new : string -> Person.date -> Person.place -> Person.person
builds and return a personPerson.birthDate : Person.person -> Person.date
returns the person’s birth datePerson.hometown : Person.person -> Person.place
returns the person’s hometownPerson.show : Person.person -> string
serialises the person for show
The type aliases are:
Person.date
: the sameBirth.date
–Date.date
from basisPerson.place
: the sameBirth.place
– string optionPerson.person
: a hash containing the keysname
(string) andbirth
(Birth.birth
)
The Person
structure depends on the Birth
structure.
Birth
structure
The Birth
structure manage birth date and place. Its API has two functions:
Birth.new : Birth.date -> Birth.place -> Birth.birth
builds and return a birthBirth.show : Birth.birth -> string
serialises the birth for show
The type aliases are:
Birth.date
:Date.date
from basisBirth.place
: string optionBirth.birth
: a hash containing the keysdate
(Birth.date
) andplace
(Birth.place
)
Prompt
structure
The Prompt
structure offers helpers to request informations from standard
input.
Prompt.forInt : Prompt.message -> int option
requests an integerPrompt.forOpt : Prompt.message -> string option
requests a stringPrompt.forStr : Prompt.message -> string
requests a straight stringPrompt.getDate : Prompt.message -> Date.date
requests a date
forInt
and forOpt
return NONE
when the supplied value is invalid.
The type alias Prompt.message
is string.