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

Mapa mental

Cap 3: Types and Typeclasses

MENESES CHAVARRIA XUASY SANTIAGO Español

Contenido del mapa

Cap 3: Types and Typeclasses

  1. The type

    • Haskell has a static type system
      • this is used for catch such errors at compile time instead of having your program crash
      • common types
        • Int and Integer
        • Float is a real floating point with single precision.
        • Double is a real floating point with double the precision
        • Bool is a boolean type. It can have only two values: True and False.
    • Haskell can infer the type
    • Functions also have types
      • For example
        • [Char] -> [Char]
          • meaning that it maps from a string to a string
        • Int -> Int -> Int -> Int
          • The parameters are separated with -> and there's no special distinction between the parameters and the return type
  2. Type variables

    • if it's not in capital case
      • it's actually a type variable
        • that means that a can be of any type
        • like generics in other languages
        • example [a] -> a
          • it takes a list of any type and returns one element of that type.
  3. Typeclasses

    • A typeclass is a sort of interface that defines some behavior
      • the => symbol
        • Everything before the symbol is called a class constraint
    • examples
      • The Eq typeclass provides an interface for testing for equality.
        • The functions its members implement are == and /=
      • Ord The compare function takes two Ord members of the same type and returns an ordering.
      • show: It takes a value whose type is a member of Show and presents it to us as a string.
      • The read function takes a string and returns a type which is a member of Read.
      • Enum are sequentially ordered types, they can be enumerated.
        • use its types in list ranges
        • can use the succ and pred functions.
      • Num is a numeric typeclass
        • include
          • Integral
          • Floating
          • (Num b) => length :: [a] -> b

Información

Descripción
Mapa Mental sobre Cap 3: Types and Typeclasses, creado por MENESES CHAVARRIA XUASY SANTIAGO el 02/03/2018.
Visitas
0
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?