Live data from Hacker News

The Monad Challenges: Jump start your understanding of monads

mightybyte.github.io

21–30 of 51 posts

Re: The Monad Challenges: Jump start your understanding of monads

#21
post #11

Earlier quoted context omitted.

Something that doesn't help the Math->CS understanding of Functors is, for example, that languages like C++ use "Functor" to mean other things (function pointer in this case).

It's not though, in C++ a functor is generally something which defines the operator which lets you treat it as a callable. (a thing which acts like a function) Though the suppose the dissonance in naming point still applies.

> a functor is generally something which defines the operator which lets you treat it as a callable

In mathematics, those things are just called "functions". :P

Re: The Monad Challenges: Jump start your understanding of monads

#22
post #6
post #4

Earlier quoted context omitted.

Adjunctions aren't highly relevant to programming. Monads in programming have much less category theory than monads in math.

The significance of monads in programming is entirely because of the adjunction between the category of types and "pure" functions and the category of types and "monadic" functions (i.e., the Kleisli category of the monad). A monad is used to encode the latter in terms of the former via the Kleisli adjunction (whereby monadic maps from FX to FY correspond to pure maps from X to GFY, with the monad GF thus arising fro…

I really appreciate this description. Always nice to see the "actual" definitions instead of "it's like a thing you can map over."

I initially had problems understanding monads in Haskell having come from a math perspective.

Re: The Monad Challenges: Jump start your understanding of monads

#23
I have Haskell experience and would love to do these exercises, but I am struggling with the environment.

For example, Set1 tells me to make a function fiveRands and then "check my answers;" how do I do that? I know enough Haskell to do something like:

    main = putStrLn $ show fiveRands
but putStrLn is not part of MCPrelude so this doesn't compile, and the instructions say explicitly "Do not import any other modules."

I'm excited to try these. Please add some more hand-holding to get me and others over the tooling and environment issues.

Re: The Monad Challenges: Jump start your understanding of monads

#24
> Do I need to know Haskell? Yes.

This is enough for me to reject this blogpost.

No you don't need a specific language to implement any functionality that can be implemented by a turing-complete language.

I watched Crockford's monad talk [1]. He used javascript. The only problem with that talk is that he spent about 10 seconds or less explaining what a monad is (and the rest of the talk on implementation issues and his own perspective, etc, etc).

I'm still waiting for a good monad discussion without CT or Haskell. (this [2] and this [3] look promising, both in python)

[1] https://www.youtube.com/watch?v=b0EF0VTs9Dc

[2] http://www.valuedlessons.com/2008/01/monads-in-python-with-n...

[3] http://www.dustingetz.com/2012/04/07/dustins-awesome-monad-t...

Re: The Monad Challenges: Jump start your understanding of monads

#25
post #6

Earlier quoted context omitted.

The significance of monads in programming is entirely because of the adjunction between the category of types and "pure" functions and the category of types and "monadic" functions (i.e., the Kleisli category of the monad). A monad is used to encode the latter in terms of the former via the Kleisli adjunction (whereby monadic maps from FX to FY correspond to pure maps from X to GFY, with the monad GF thus arising fro…

I'm not very familiar with category theory and can't really make heads or tails of what you're writing there, but I think the idea behind the statement that "adjunctions aren't highly relevant in programming" is to say that there isn't a huge amount of immediate utility of adjunctions as a programmer. On the other hand, programmers use monads all the time (even if they don't realize it, which is the most common case,…

The purpose of that comment is to note precisely the same thing applying to adjunctions as you note applying to monads: programmers use adjunctions all the time even if they don't realize it.

"I've never heard of them so I'm assuming that's not the case"? Well, hey, most programmers have never heard about monads either. Explicitly having heard of a thing is, by definition, not a requirement for it to be something which one "use[s]... all the time (even if they don't realize it...)".

[I'm not saying everyone needs to go out and learn about adjunctions. But they're in exactly the same area as monads in terms of their applicability as a concept to programming. It's weird to consider the one a down-to-earth, comes-up-all-the-time notion and the other some airy-fairy academic construct.]

Re: The Monad Challenges: Jump start your understanding of monads

#26

I have Haskell experience and would love to do these exercises, but I am struggling with the environment. For example, Set1 tells me to make a function fiveRands and then "check my answers;" how do I do that? I know enough Haskell to do something like: main = putStrLn $ show fiveRands but putStrLn is not part of MCPrelude so this doesn't compile, and the instructions say explicitly "Do not import any other modules."…

it doesn't look like their prelude has any stdout printing functions, so it's probably easiest to test your code in a repl. you can check what functions they do give you by looking at the stuff before the "where" here: https://github.com/mightybyte/monad-challenges/blob/gh-pages...

as for verifying your results, they give you the product of the 5 numbers at the bottom of the page (since you're starting from a predetermined seed, the 5 numbers you generate are known)

Re: The Monad Challenges: Jump start your understanding of monads

#27

I have Haskell experience and would love to do these exercises, but I am struggling with the environment. For example, Set1 tells me to make a function fiveRands and then "check my answers;" how do I do that? I know enough Haskell to do something like: main = putStrLn $ show fiveRands but putStrLn is not part of MCPrelude so this doesn't compile, and the instructions say explicitly "Do not import any other modules."…

I started this challenges and just use GHCi to check/eval things. (> ghci set1.hs for example)

Re: The Monad Challenges: Jump start your understanding of monads

#28

I have Haskell experience and would love to do these exercises, but I am struggling with the environment. For example, Set1 tells me to make a function fiveRands and then "check my answers;" how do I do that? I know enough Haskell to do something like: main = putStrLn $ show fiveRands but putStrLn is not part of MCPrelude so this doesn't compile, and the instructions say explicitly "Do not import any other modules."…

Ignore the instructions and grab putStrLn if you need it in order to check your work. The instructions about not using other modules are there to avoid you "cheating". Looking at your work is definitely not cheating and will not prevent you from learning :).

Also, just typing "fiveRands" and hitting ENTER at the repl will show you the value of fiveRands (or any other expression).

Re: The Monad Challenges: Jump start your understanding of monads

#29
post #24

> Do I need to know Haskell? Yes. This is enough for me to reject this blogpost. No you don't need a specific language to implement any functionality that can be implemented by a turing-complete language. I watched Crockford's monad talk [1]. He used javascript. The only problem with that talk is that he spent about 10 seconds or less explaining what a monad is (and the rest of the talk on implementation issues and h…

It's true that you don't need to know Haskell in order to learn about monads, but Haskell is a perfectly reasonable language in which to write a monad introduction.

Haskell is good for learning about monads for the same reasons monads tend to be heavily used in Haskell, but not in other languages. Monads are both part of Haskell's standard library, and have very useful special syntax (do-notation). Writing out monadic code explicitly gets to be a huge pain when using monads in another language. Typeclasses also make it convenient & easy to write code that's generic over any monad.

Re: The Monad Challenges: Jump start your understanding of monads

#30
post #17

Earlier quoted context omitted.

If you're going to talk like that, stay far, far away from anyone who is trying to learn monads. I assert that most people coming to Haskell do so because "I hear Haskell and/or FP is cool, I'll try to learn it" rather than "Category theory is so cool, wouldn't it be awesome to program that way". What you said may be true, as the theoretical foundation for why monads are useful, but for someone trying to learn to pro…

That comment of mine wasn't the spiel I'd give to someone first trying to learn about the typical use of monads in a programming context, any more than I'd lecture a beginning programmer on the general theory of commutative rings while introducing integer and floating-point arithmetic (the latter not actually comprising a commutative ring...). But teaching the use of monads to unfamiliar programmers wasn't my goal in…

What if one simply says that a monad describes a pattern of morphisms composition ? Adjunctions being the plumbing ?

(honest question, just trying to find a simple, grokkable definition)

Post reply on HN