From 94dee1332973f3b3b1bdf524cf681fa24c7939a9 Mon Sep 17 00:00:00 2001 From: Correl Date: Sat, 12 Mar 2022 18:33:26 -0500 Subject: [PATCH] updates --- ...34-algebraic_data_types_are_composable.org | 8 +++++++- 20220310115927-monad.org | 2 +- 20220312165500-semigroup.org | 7 +++++++ 20220312165629-monoid.org | 11 +++++++++++ WillKurt2718.org | 19 +++++++++++++++++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 20220312165500-semigroup.org create mode 100644 20220312165629-monoid.org diff --git a/20210929115234-algebraic_data_types_are_composable.org b/20210929115234-algebraic_data_types_are_composable.org index ffba333..9a9378a 100644 --- a/20210929115234-algebraic_data_types_are_composable.org +++ b/20210929115234-algebraic_data_types_are_composable.org @@ -1,7 +1,13 @@ :PROPERTIES: :ID: 67dab4eb-231f-4af0-bf26-b3cf6d83f9a3 +:ROAM_ALIASES: "Algebraic Data Types are composable" :END: -#+title: Algebraic Data Types are composable +#+title: Algebraic Data Types + +Algebraic Data Types are types built by composing other types. This is done in +one of two ways: +- Product Types :: Type T_1 /and/ T_2 /and/ T_n +- Sum Types :: Type T_1 /or/ T_2 /or/ T_n Because ADTs are separate from behavior, it's easy to combine them together to make more complex types. diff --git a/20220310115927-monad.org b/20220310115927-monad.org index 9c3ba90..8f749d8 100644 --- a/20220310115927-monad.org +++ b/20220310115927-monad.org @@ -4,5 +4,5 @@ #+title: Monad #+begin_quote -A monad is just a monoid in the category of endofunctors. +A monad is just a [[id:434ee61c-4461-424f-8dba-5c86ddb06c3c][monoid]] in the category of endofunctors. #+end_quote diff --git a/20220312165500-semigroup.org b/20220312165500-semigroup.org new file mode 100644 index 0000000..922c4d0 --- /dev/null +++ b/20220312165500-semigroup.org @@ -0,0 +1,7 @@ +:PROPERTIES: +:ID: b22a1c70-02a7-49ce-b5e7-407f1064cd0c +:END: +#+title: Semigroup + +A category of types such that two values of the type can be combined +associatively to create a new value of the same type. diff --git a/20220312165629-monoid.org b/20220312165629-monoid.org new file mode 100644 index 0000000..6779822 --- /dev/null +++ b/20220312165629-monoid.org @@ -0,0 +1,11 @@ +:PROPERTIES: +:ID: 434ee61c-4461-424f-8dba-5c86ddb06c3c +:END: +#+title: Monoid + +A [[id:b22a1c70-02a7-49ce-b5e7-407f1064cd0c][Semigroup]] with an identity value. + +* Examples +- List :: Combined with =append=, identity value is the empty list (=[]=) +- Number Addition :: Combined with =+=, identity value is =0= +- Number Multiplication :: Combined with =*=, identity value is =1= diff --git a/WillKurt2718.org b/WillKurt2718.org index c07b44e..662b2d9 100644 --- a/WillKurt2718.org +++ b/WillKurt2718.org @@ -4,6 +4,7 @@ :END: #+title: Notes on Will Kurt, Get Programming with Haskell +* [[id:68cedf67-0f59-4a06-9344-77d946129653][Functional Programming]] #+begin_quote John Backus, who led the team that created Fortran, asked in his Turing Award lecture, “Can programming be liberated from the von Neumann style?” @@ -12,5 +13,23 @@ This question leads to the second way to understand programming, which is the subject of the first unit in this book. [[id:68cedf67-0f59-4a06-9344-77d946129653][Functional programming]] attempts to liberate programming from the von Neumann style. #+end_quote +* [[id:67dab4eb-231f-4af0-bf26-b3cf6d83f9a3][Algebraic Data Types]] +#+begin_quote +The big problem is that you want a single type that represents both vinyl +records and books so you can make a searchable inventory. Because you can +compose types only by /and/, you need to develop an abstraction that describes +everything that records and books have in common. You’ll then implement only the +differences in the separate classes. This is the fundamental idea behind +/inheritance/. +#+end_quote +#+begin_quote +In theory, creating object hierarchies is elegant and captures an abstraction +about how everything in the world is interrelated. In practice, creating even +trivial object hierar- chies is riddled with design challenges. The root of all +these challenges is that the only way to combine types in most languages is with +an /and/. This forces you to start from extreme abstraction and move downward. +Unfortunately, real life is full of strange edge cases that make this much more +complicated than you’d typically want. +#+end_quote #+print_bibliography: