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

Mapa mental

Making Our Own Types and Typeclasses

HERRERA BOHORQUEZ JAVIER FELIPE Español

Contenido del mapa

Making Our Own Types and Typeclasses

  1. Algebraic data types

    • use the data keyword to define a type
      • means that we're defining a new data type.
      • has to have constructor attributes
      • some data types Bool, Int, Char, Maybe
    • Representation of a shape in haskell
      • tuples
      • could also represent a 3D vector or anything else
      • make our own type to represent a shape
        • can optionally add some types after it and those types define the values it will contain
        • can also export data types in diferent modules
  2. Record syntax

    • define what information wan to record
      • set the data type
      • use curly brackets
        • write a double colon
          • specify the type
            • creates functions that lookup fields in the data type
  3. Type parameters

    • can take some values parameters and then produce a new value
    • can take types as parameters to produce new types
    • can make different types with them depending on what kind of types we want contained in our data type
  4. Derived instances

    • Haskell can automatically make our type an instance of any of the following typeclasses
    • Haskell can derive the behavior of the types
  5. Type synonyms

    • they do nothing by itself
    • gave some types different names so that they make more sense to someone reading our code and documentation

Información

Descripción
Mapa Mental sobre Making Our Own Types and Typeclasses, creado por HERRERA BOHORQUEZ JAVIER FELIPE el 09/10/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?