GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Mindmap

Chapter 8 - Making Our Own Types and Typeclasses

SANTIAGO CÁRDENAS PEDRAZA Spanisch

Inhalt der Mindmap

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

Informationen

Beschreibung
Mindmap am Chapter 8 - Making Our Own Types and Typeclasses, erstellt von SANTIAGO CÁRDENAS PEDRAZA am 29/03/2020.
Erstellt von
SANTIAGO CÁRDENAS PEDRAZA · Mär 2020
Aktualisiert
30 Mär 2020
Aufrufe
0
Bewertung

Mehr zu Data Types and Typeclasses

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck