¡GoConqr estrena diseño! Cuéntanos qué te parece.

Mapa mental

Chapter 8 - Making Our Own Types and Typeclasses

SANTIAGO CÁRDENAS PEDRAZA Español

Contenido del 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

Información

Descripción
Mapa Mental sobre Chapter 8 - Making Our Own Types and Typeclasses, creado por SANTIAGO CÁRDENAS PEDRAZA el 29/03/2020.
Creado por
SANTIAGO CÁRDENAS PEDRAZA · mar 2020
Actualizado
30 mar 2020
Visitas
0
Valoración

Más sobre Data Types and Typeclasses

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?