Mindmap
Making Our Own Types and Typeclasses
Inhalt der Mindmap
Making Our Own Types and Typeclasses
To define a new data type we use the word data
- The part before the = is the Type and after the = are the value constructors: specify the values that the type can have
- we can optionally add some types after it and those types define the values it will contain.
- if there's only one value constructor, we can use the same name for the data type and the value constructor
- We can export our data types. we just have to write it in the module declaration.
- In parentheses, we specify the value constructor.
- To add everything just put ( .. ) inside the parentheses.
- In parentheses, we specify the value constructor.
- We can export our data types. we just have to write it in the module declaration.
- if there's only one value constructor, we can use the same name for the data type and the value constructor
- we can optionally add some types after it and those types define the values it will contain.
- The part before the = is the Type and after the = are the value constructors: specify the values that the type can have
RECORD SYNTAX
- It’s an alternative to write data types.
- We write the field types, and then write double colon :: to specify the type
- It’s an alternative to write data types.
Derived instances
- Haskell can derive the behavior of these types to our data types.
Type synonyms
- Give different names to the type data so that they make more sense to someone reading our code and documentation.
Recursive data structures
- where one value of some type contains values of that type, which in turn contain more values of the same type and so on.
Binary search tree
- An element points to two elements, one on its left and one on its right. The element to the left is smaller, the element to the right is bigger.
Bilder und Dateien der Mindmap
Informationen
- Beschreibung
- Mindmap am Making Our Own Types and Typeclasses, erstellt von Nicolas Medina am 19/09/2018.
- Erstellt von
- Nicolas Medina
- Aufrufe
- 0
- Bewertung
Mehr zu Data Types and Typeclasses