O GoConqr está de visual novo! Conte para nós o que você achou.

Mapa mental

Chapter 8 - Making Our Own Types and Typeclasses

SANTIAGO CÁRDENAS PEDRAZA Espanhol

Conteúdo do mapa

Chapter 8 - Making Our Own Types and Typeclasses

  1. We can create our own data types, it could be usefull for store diferent types of data in the same typeclass

    • Syntaxis
      • data <name of typeclass>
      • =
      • Data constructor or class definition
  2. Record syntax

    • It is used as an alternative to define data types
    • data Person = Person { firstName :: String , lastName :: String , age :: Int }
  3. Type parameters

    • A value constructor can take some values parameters and then produce a new value.
    • data Maybe a = Nothing | Just a
  4. Derived instances

    • This works like inheritance in programming languages, the class takes attributes from parent class.
    • data Person = Person { firstName :: String , lastName :: String , age :: Int } deriving (Eq)
  5. Type synonyms

    • type String = [Char]
    • Give equivalence between different types
  6. Recursive data structures

    • This data structures, allow to store the same data type into same
    • data List a = Empty | Cons a (List a) deriving (Show, Read, Eq, Ord)
  7. A yes-no typeclass

    • This type of class define a data as boolean like "" or [] in javascript
    • instance YesNo Int where yesno 0 = False yesno _ = True
  8. Functor typeclass

    • This class is used for map classes that can be maped like lists
    • class Functor f where fmap :: (a -> b) -> f a -> f b

Informações

Descrição
Mapa Mental sobre Chapter 8 - Making Our Own Types and Typeclasses, criado por SANTIAGO CÁRDENAS PEDRAZA em 29-03-2020.
Criado por
SANTIAGO CÁRDENAS PEDRAZA · mar 2020
Atualizado
30 mar 2020
Visualizações
0
Avaliação

Mais sobre Data Types and Typeclasses

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?