[Haskell-beginners] fromIntegral

Brandon S Allbery KF8NH allbery at ece.cmu.edu
Sat Oct 2 20:41:11 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/2/10 19:59 , Russ Abbott wrote:
> So what are the other options? I still like the idea of saying that [ ] is a
> function that takes a type as an argument and generates a value. (I believe

The best way to think abut this isn't really in terms of functions.  The
whole point of functional programming is referential transparency:  in "let
xs = [] ...", xs can be seen as a sort of "macro" which stands for its
expansion.  So you can use xs anywhere you would use [] and it will always
behave as if you said [], including the polymorphism.  Anywhere you use a
binding, you are always able to substitute the bound expression.

(This is why we need "magic" for IO.  Conceptually, an IO "action" is a
partial function which won't run until passed the baton; this same partial
function can be substituted anywhere, but each substitution will be lazily
evaluated when the baton reaches it (if in fact it ever does).  The IO monad
hides the baton-passing and makes sure it's done in legitimate ways.  So in
fact IO "actions" are entirely referentially transparent.)

- -- 
brandon s. allbery     [linux,solaris,freebsd,perl]      allbery at kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university      KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyn0ScACgkQIn7hlCsL25WtkACgy5bTsmQJATu9zSL29v3uX5Pg
3GoAn2QfkWhfNU3cbl0/ZKLjnS9VzZFm
=I+TE
-----END PGP SIGNATURE-----


More information about the Beginners mailing list