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

Mapa mental

Chapter 8

NICOLÁS ALBORNOZ TIBASOZA Español

Contenido del mapa

Chapter 8

  1. Algebraic data types

    • Define our own data types
    • using the word "data"
      • means that a new data type is being defined
    • It is necessary to write the data type name
    • Value constructors
      • Defines the values that can take the data type that is going to be defined
    • Example
      • data Bool = True | False
  2. Record syntax

    • Modules can define data types aswell
      • To be more simple to understand and read it is used record syntax
        • Works the same way as the algebraic data types, the only difference is that it's more readable
        • Record syntax works like object oriented prgramming
          • We define the attributes and their data types
  3. Type parameters

    • Instead of having values as parameters we have data types as parameters
    • For example
      • data Maybe a = Nothing | Just a
        • "a" is a type parameter
          • the result could be Just Int or Just Char
  4. Derived instances

    • It is used to implement a behaviour in a new data type
      • To do so it is necessary to use the word "Deriving"
        • And then write the typeclass we want to implement
        • For example: deriving (Eq, Show, Read)
  5. Type synonims

    • Give types a different name
      • For example [Char], its type synomim would be String
  6. Typeclasses 102

    • As we can define modules, we can also define our own typeclasses
      • To define a new typeclass we use the word "class" followed by the name and then "where"
        • class Eq a where

Información

Descripción
Mapa Mental sobre Chapter 8, creado por NICOLÁS ALBORNOZ TIBASOZA el 26/03/2019.
Visitas
2
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?