|
|
|
|
|
by rrgok
440 days ago
|
|
Yes, I really need a real word Haskell project simple enough to understand all the math concept. Like, I don't know when to implement the Monad type-class to my domain data types. For example, taking the twitter example, if I have Tweet data type: - should I implement the Monad, Applicative or Functor type class? - How would that help in the big picture? - What if I don't do it? All these funny example of boxes, burritos or context doesn't not help me solve problems. Take for example Monoid, I understand (partially maybe) that it useful for fold (or reduce) a list to a single value. |
|
There actually is a book with precisely that title, which provides what you're asking for: https://book.realworldhaskell.org/
> Like, I don't know when to implement the Monad type-class to my domain data types
A concrete type (such as your Tweet type) can't be a Monad. Monad is implemented on generic types (think: `MyType a`, where `a` can be filled in with a concrete type to produce e.g. `MyType Int` or `MyType String`).
Most monads are data structures like list `[a]` or structures which provide context to computations like `State s a` or `Reader r a`