[Haskell-beginners] Help with Why Do Monads Matter blog post understanding

Matt Ford matt at dancingfrog.co.uk
Fri Jun 29 10:57:42 CEST 2012


Hi,

I've been reading the following blog post

https://cdsmith.wordpress.com/2012/04/18/why-do-monads-matter/

And I think I like it.  But there's a part that I don't get.

"For a set A, we will define the set Pref(A) to be the set of functions
from application settings to the set A. Now watch closely: a function in
context from A to B is just an ordinary function from A to Pref(B). In
other words, you give it a value from the set A, and it gives you back
another function that maps from application settings to the set B."

This is in the "functioning with dependency" section and is talking about a
procedure that uses outside info from preferences or application settings.

If I set my prefs as follows

configvar = 3

and define a function as follows

add x = configvar + 6

So add’s signature is

add: int -> int

What does prefs(int) look like? Is that even the right thing to ask?
What happens to the add function? 

By substituting the B for Prefs(B) and returning now only functions from
Pref(B) don't we lose the rest of the mapping for add i.e., " + 6"?

Matt.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120629/f25ef77d/attachment.pgp>


More information about the Beginners mailing list