Javascript to Elm

63: Getting Haskell Unit 3 (part 2)

Informações:

Synopsis

Rounding off algebraic data types! Monoids So like we talked last week, about Semigroup, now we’re gonna add a little bit to that, requiring an identity element for the type changes a semigroup to a monoid! That’s it Well, it might seem like a little change, but it has a pretty sizable effect. Summarize identity x id = x as well as id x = x > function that always returns the same value that was used as its argument. In equations, the function is given by f(x) = x. I’ve mentioned it a few times previously. fold is possible because monoid has this identity function. Example. if you want to combine or mconcat a list of lists. Like say a list of Strings, which we know under the covers a String is a List of Char [Char] what if the list is empty ? Do we have to check for that possibility and handle that? That doesn’t seem very helpful. If you try to mconcat an Empty List, bc of the Identity function, f(x) = x, you’ll just get back an empty list! It totally knows what to do. And the best part is, we don’t have