Mapa mental
Making Our Own Types and Typeclasses
Conteúdo do mapa
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.
Imagens e arquivos do mapa
Informações
- Descrição
- Mapa Mental sobre Making Our Own Types and Typeclasses, criado por Nicolas Medina em 19-09-2018.
- Criado por
- Nicolas Medina
- Visualizações
- 0
- Avaliação
Mais sobre Data Types and Typeclasses