<div dir="ltr">I saw this in <i>The Little MLer</i>, a book on SML<div><br></div><div><font face="monospace">datatype 'a list = Empty | Cons of 'a * 'a list<br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">fun subst_c (pred)<br>    = fn (n,Empty) => Empty<br>         | (n,Cons(e,t)) => if pred (e)<br>                            then Cons (n,subst_c (pred) (n,t))<br>                            else Cons (e,subst_c (pred) (n,t))</font><br></div><div><br></div><div>The data type is just a homemade list, and the function <font face="monospace">subst_c</font> takes a predicate <font face="monospace">('a -> Bool)</font> and determines whether an incoming list's elements pass or fail. What is interesting is the <font face="monospace">fn ... => ...</font> part which takes in more parameters, namely an <font face="monospace">'a</font> and an <font face="monospace">'a list.</font> Technically this <font face="monospace">fn..</font>. is an anonymous, nameless function, and it seems bizarre to me that it's nested inside the named function but still taking in parameters as if it were at the top level. Here's a previous version showing all three parameters at the top level</div><div><br></div><div><font face="monospace">fun subst_c (pred) (n,Empty) = Empty<br></font></div><div><font face="monospace">...</font></div><div><br></div><div>The purpose of the first function was to demonstrate currying. IOW, what the second unnamed function is doing behind the scenes can be broken down to two-stages (currying) of the first with named, then unnamed functions. So my question is, is there anything like this in Haskell where a function inside a function -- named or anonymous -- can take incoming parameters as if it were top level?</div><div><br></div><div>LB</div><div><br></div><div><br></div></div>