You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/05_typeclasses.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -256,7 +256,7 @@ class Show a where
256
256
257
257
This is for converting values to human-readable strings.The minimal requirement for custom instances: define `show`.
258
258
259
-
Derived `Show` produces a string that looks is a valid Haskell code.Custom instances can produce any string representation you want.Butthen you should preferably implement both ShowandRead, they should round-trip: `read (show x) == x`.General recommendation:donot abuse `show` for pretty-printing.
259
+
Derived `Show` produces a string that looks as a valid Haskell code.Custom instances can produce any string representation you want.Butthen you should preferably implement both ShowandRead, they should round-trip: `read (show x) == x`.General recommendation:donot abuse `show` for pretty-printing.
260
260
261
261
### Read — parsing from String
262
262
@@ -510,7 +510,7 @@ You already know some instances of `Monoid`:
510
510
511
511
Apart from basic `Monoid` from algebra, there are also other variants. You might find interesting to learn more about:
Right 10 -- changed, because "Either c" is functor for whatever "c" - it doesn't care
556
+
Right 15 -- changed, because "Either c" is functor for whatever "c" - it doesn't care
557
557
```
558
558
559
559
Just as with Monoid, you can take a look at the documentation of [Data.Functor](https://hackage.haskell.org/package/base/docs/Data-Functor.html). Again, there is an operator alias, in this case `(<$>)` for `fmap` (denoting a sort of "wrapped" or "inside" apply). There are two more -- `<$` and `$>` (just flipped `<$`). Flipped version of `(<$>)` is `(<&>)`.
@@ -672,9 +672,9 @@ class Applicative m => Monad m where
672
672
(>>)::ma->mb->mb-- compose two actions, discarding the result
673
673
return::a->ma-- inject a value into the monadic type.
674
674
675
-
-- (<**>):: f a -> f (a -> b) -> f b -- from Controll.Applicative
676
-
-- (*>) :: f a -> f b -> f b -- from Controll.Applicative
677
-
-- pure :: a -> f a -- from Controll.Applicative
675
+
-- (<**>):: f a -> f (a -> b) -> f b -- from Control.Applicative
676
+
-- (*>) :: f a -> f b -> f b -- from Control.Applicative
677
+
-- pure :: a -> f a -- from Control.Applicative
678
678
```
679
679
680
680
Function `return` works just as `pure` in `Applicative`. Why having two same functions? Historically; PureScript, for instance, has just `pure` both for the Applicative and Monad.
0 commit comments