GoConqr has a new look! Let us know what you think.

Mind map

Types and Typeclasses

SUAREZ HERNANDEZ SANTIAGO Spanish

Map content

Types and Typeclasses

  1. Use the data keyword to define a type

  2. Value constructors are actually functions that return a value of a data type

  3. You can export your data types in your modules: Shape(..)

  4. Record syntax

    • data Person = Person { firstName :: String , ...
  5. Type parameters

    • We use them when our data type would work regardless of the type of the value it then holds inside it
  6. Typeclass is a sort of an interface that defines some behavior

  7. Derived instances

    • A type is an instance of a typeclass if the type has the behavior of the typeclass
  8. Type synonyms

    • They're just about giving some types different names
    • Just like we call a function with too few parameters to get back a new function, we can specify a type constructor with too few type parameters and get back a partially applied type constructor.
  9. A typeclass is a sort of an interface that defines some behavior

  10. Recursive data structures

    • We can make types whose constructors have fields that are of the same type
  11. Types

    • data Bool = False | True
      • type = The different values that this type can have
    • if we add deriving (Show) at the end of a data declaration, that type become part of the Show typeclass
      • data Shape ...|... deriving (Show)
    • Intermediate data type
      • data Point = Point Float Float data Shape = Circle Point Float
  12. Typeclass

    • A typeclass defines some behavior like comparing for equality and then types that can behave in that way are made instances of that typeclass
    • class Eq a where...

Information

Description
Mind Map on Types and Typeclasses, created by SUAREZ HERNANDEZ SANTIAGO on 20/03/2019.
Views
0
Rating

More on Data Types and Typeclasses

Feedback

What is it about?

What do you think of the new look?

How do you like it?