Because of Haskell&#39;s type system, there are some expressions that you simply cannot compile.  Most of them you don&#39;t *want* to compile because they do bad things (like add two strings, for example).  Some things are legal in Lisp but don&#39;t typecheck in Haskell for exactly the reasons that Brent pointed out.  They might make sense in some contexts, but the compiler isn&#39;t able to reason about them.<br>

<br><div class="gmail_quote">On Tue, Jun 26, 2012 at 5:19 PM, Jay Sulzberger <span dir="ltr">&lt;<a href="mailto:jays@panix.com" target="_blank">jays@panix.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, 26 Jun 2012, Brent Yorgey &lt;<a href="mailto:byorgey@seas.upenn.edu" target="_blank">byorgey@seas.upenn.edu</a>&gt; wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, Jun 26, 2012 at 10:08:49PM +0200, Obscaenvs wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sorry if this is a less than stellar question.<br>
<br>
The problem:<br>
Given a function f :: a -&gt; a -&gt; a -&gt; b, make it work on a list<br>
instead: f `applyTo`[x,y,z] where [x,y,z] :: [a].<br>
My stab at a general solution was<br>
`<br>
applyTo f [] = error &quot;no arg&quot;<br>
applyTo f (x:xs) = go (f x) xs<br>
    where<br>
      go acc [] = acc<br>
      go acc (y:[]) = acc y<br>
      go acc (y:ys) = go (acc $ y) ys<br>
`<br>
<br>
I thought this would work, functions being &quot;first class citizens&quot; but<br>
ghci complains:<br>
    &quot;Occurs check: cannot construct the infinite type: t1 = t0 -&gt; t1<br>
    In the return type of a call of `acc&#39;<br>
    Probable cause: `acc&#39; is applied to too many arguments<br>
    In the expression: acc y<br>
    In an equation for `go&#39;: go acc (y : []) = acc y&quot;<br>
<br>
The &#39;probable cause&#39; isn&#39;t the real cause here, but something to do<br>
with the fact that it&#39;s impossible to accumulate functions in this<br>
way...<br>
Or am I just too tired too make it work? I can see that the type of<br>
`go` could be a problem, but is it insurmountable?<br>
</blockquote>
<br>
The type of `go` is exactly the problem.  In particular, the type of<br>
acc&#39;s first parameter.  In the third clause of go&#39;s definition, we can<br>
see that `acc` and (acc $ y) are both used as the first argument to<br>
go, hence they must have the same type.  However, this is impossible<br>
-- if acc has type (t0 -&gt; t1), then y must have type t0, and (acc $ y)<br>
has type t1, so it would have to be the case that t1 = t0 -&gt; t1 --<br>
hence the error message.<br>
<br>
It is not possible in Haskell to define `applyTo`.* I know this<br>
function gets used a lot in lisp/scheme, but Haskell style is<br>
different.  If you explain the context in which you wanted this<br>
function, perhaps we can help you figure out a better way to structure<br>
things so it is not needed.<br>
<br>
-Brent<br>
<br>
* At least not without crazy type class hackery.<br>
</blockquote>
<br></div></div>
What is the difficulty?<br>
<br>
Is the difficulty at the level of &quot;syntax&quot;?<br>
<br>
Or is it that the type &quot;Haskell expression&quot;, perhaps &quot;Haskell<br>
form&quot;, to use an old and often confusing Lisp term, does not<br>
exist in the Haskell System of Expression?  Here &quot;exist&quot; should be<br>
read as &quot;exist at the right level&quot;, right level for attaining<br>
some objective.<br>
<br>
These alternatives, I think, need not be disjoint.<br>
<br>
I am ignorant of Haskell, but sometimes I write Perl in Lisp, and<br>
the blurb for my last public rant mentioned a specific lambda<br>
expression:<br>
<br>
 <a href="http://lists.gnu.org/archive/html/gnu-misc-discuss/2012-03/msg00036.html" target="_blank">http://lists.gnu.org/archive/<u></u>html/gnu-misc-discuss/2012-03/<u></u>msg00036.html</a><br>
<br>
oo--JS.<div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<u></u>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/beginners</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Alec Story<br>Cornell University<br>Biological Sciences, Computer Science 2012<br>