Mapa mental
Types and Typeclasses
Conteúdo do mapa
Types and Typeclasses
Use the data keyword to define a type
Value constructors are actually functions that return a value of a data type
You can export your data types in your modules: Shape(..)
Record syntax
- data Person = Person { firstName :: String , ...
Type parameters
- We use them when our data type would work regardless of the type of the value it then holds inside it
Typeclass is a sort of an interface that defines some behavior
Derived instances
- A type is an instance of a typeclass if the type has the behavior of the typeclass
Type synonyms
- They're just about giving some types different names
- Just like we call a function with too few parameters to get back a new function, we can specify a type constructor with too few type parameters and get back a partially applied type constructor.
A typeclass is a sort of an interface that defines some behavior
Recursive data structures
- We can make types whose constructors have fields that are of the same type
Types
- data Bool = False | True
- type = The different values that this type can have
- if we add deriving (Show) at the end of a data declaration, that type become part of the Show typeclass
- data Shape ...|... deriving (Show)
- Intermediate data type
- data Point = Point Float Float data Shape = Circle Point Float
- data Bool = False | True
Typeclass
- A typeclass defines some behavior like comparing for equality and then types that can behave in that way are made instances of that typeclass
- class Eq a where...
Informações
- Descrição
- Mapa Mental sobre Types and Typeclasses, criado por SUAREZ HERNANDEZ SANTIAGO em 20-03-2019.
- Criado por
- SUAREZ HERNANDEZ SANTIAGO
- Visualizações
- 0
- Avaliação
Mais sobre Data Types and Typeclasses