02-14 data, newtype, type (Introduction to Haskell)
We provide an overview of the Haskell language constructs for working with types: data as the general construct to define a new datatype that is different from all other datatypes so far; newtype as a special case of data where we wrap a single field in a single constructor; and type as a way to define new names (synonyms) to already existing types that can then be used interchangeably with the old names. Course site with self-test questions: https://teaching.well-typed.com/intro/datatypes-and-functions.html#video-214-data-newtype-type 00:00 The general syntax of the data construct 02:40 Another example datatype: binary trees 05:24 Deriving Show and Eq for trees 06:42 An example tree 07:59 Another example tree 10:03 Lists are trees 12:10 Interesting special cases of datatypes 12:42 Enumeration types 14:12 Product and record types 16:38 Record syntax 19:28 Constructing a record using record syntax 20:38 Using record field names as selector functions 23:11 Single-constructor, single-field datatypes 28:06 Converting between the outer and inner type 28:50 newtype 31:01 Type synonyms: type 34:44 newtype versus type 35:07 Conclusions
Download
0 formatsNo download links available.