Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Haskell
Wiki community
Recent changes
Random page
HaskellWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Talk:Constant applicative form
(section)
Add topic
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Add topic
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Q&A discussion from HaWiki=== :''What is the difference between ''<hask>((+) 4)</hask>'' and ''<hask>\x -> (+) 4 x</hask>'', apart from the obvious difference in notation? (I have braced the + to make the expressions compliant with Haskell syntax.)'' ::One is an application that returns a function and may imply some work in general, the other is a syntactic value (a lambda abstraction). :''If notation really happens to matter so much, then what about ''<hask>(4 +)</hask>'' and ''<hask>(+ 4)</hask>''? Are '''both''' of these CAFs? If we take away the nifty syntax, how do we express ''<hask>(+ 4)</hask>'' then? Or is it no longer a CAF? ;)'' ::It depends on how they desugar. `(4 +)` presumably desugars to `((+) 4)` and so is a CAF. If (+ 4) desugars to `\x -> x + 4` it isn't, if it desugars to `flip (+) 4` it is. -- DerekElkins :::''--- Rambler'' ''I'm afraid I still don't get it (or maybe I do, but I secretly wish it didn't mean '''that'''...) To the best of my understanding of the matter, `flip (+) 4` should return something that should behave exactly as `\x -> x + 4` would. Moreover, even if I take it for granted that `flip (+) 4` differs dramatically from `\x -> x + 4`, what happens when we expand the former? :::'''''There is no difference in ''behavior'' as far as meaning is concerned. They are just treated differently. -- DerekElkins''''' :::Suppose `flip` is defined as `\f x y -> f y x` (which it probably is, anyway,) then `flip (+) 4 where flip = \f x y -> f y x` is obviously not a CAF, according to the definition. :::What about `flip (+) 4 where flip f x y = f y x`???'' ::::''I believe that FOLDOC is incorrect here. A better way of thinking about CAFs is that a CAF is anything that can be let floated (see [[lifting pattern]]) to the top level. So a CAF can not only call other CAFs, but also other [[super combinator]]s.'' :::::I believe that's already granted, according to the definition of a [[super combinator]]. A CAF may reference any [[super combinator]] simply by virtue of being one. ::::''The difference between <hask>flip (+) 4</hask> and <hask>\x -> x + 4</hask> is that in a pure lambda calculus implementation, the former can be reduced but the latter cannot. Remember that <hask>\f x y -> f y x</hask> is a shorthand for <hask>\f -> (\x -> (\y -> f y x)))</hask>, which means if given two arguments, it can be reduced. --AndrewBromage'' :::::Fine, is it then irreducibility that makes CAFs special? If so, then the current formulation of the definition clearly misses the point. If not, then why is this distinction relevant in the context of the definition? :::::In any case, I am left wondering 1) why irreducible expressions might be of such interest (apart from the trivially imaginable,) and 2) whatever happened to the proverbial [[referential transparency]]. It just struck me lately that my difficulty may be due to the fact that I am trying to make sense of CAFs in a broad theoretical context, whereas they may be simply an implementation instrument -- is this the case? --Rambler :'''You've inverted it slightly (or it reads that way): it's ''reducibility'' that makes CAFs special. Since they are reducible they may imply work; work that could be saved. Nevertheless, yes, one typically doesn't care whether something's a CAF or not as far as meaning goes. Read the relevant parts of the book I linked to below, if you haven't already. As for ReferentialTransparency, whether or not something is viewed as a CAF doesn't change it's meaning, i.e. it is just a different ''implementation'' of the ''same'' function. -- DerekElkins''' ::''OK, it definitely makes sense now, thanks to everyone for the explanations and references. --Rambler''
Summary:
Please note that all contributions to HaskellWiki are considered to be released under simple permissive license (see
HaskellWiki:Copyrights
for details). If you don't want your writing to be edited mercilessly and redistributed at will, then don't submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!
Cancel
Editing help
(opens in new window)
Toggle limited content width