<div dir="auto">Let's start with the basics: lambda expressions.<div dir="auto"><br></div><div dir="auto">ML says</div><div dir="auto"><br></div><div dir="auto">fn x => blah blah</div><div dir="auto"><br></div><div dir="auto">Haskell spells that</div><div dir="auto"><br></div><div dir="auto">\x -> blah blah</div><div dir="auto"><br></div><div dir="auto">Suppose you want to pattern match on the argument. If you only need one pattern, that's cool:</div><div dir="auto"><br></div><div dir="auto">\(x,y) -> blah blah</div><div dir="auto"><br></div><div dir="auto">But what if you need more than one pattern? Well, standard ("Report") Haskell makes you use a case expression:</div><div dir="auto"><br></div><div dir="auto">\mx -> case mx of</div><div dir="auto"> Just x -> blah</div><div dir="auto"> Nothing -> etcetera</div><div dir="auto"><br></div><div dir="auto">But GHC has a widely used language extension to get something more like ML. If you put</div><div dir="auto"><br></div><div dir="auto">-- The "language" is case insensitive.</div><div dir="auto">-- The LambdaCase is case sensitive.</div><div dir="auto">{-# language LambdaCase #-}</div><div dir="auto"><br></div>at the very tippy top of your .hs file, or pass -XLambdaCase to GHCi, then you can write that last one<div dir="auto"><br></div><div dir="auto">\case</div><div dir="auto"> Just x -> blah</div><div dir="auto"> Nothing -> etcetera</div><div dir="auto"><br></div><div dir="auto">There has been some discussion of trying to expand that syntax to support anonymous functions of multiple arguments, but no proposal has been accepted as yet.<br><div dir="auto"><div dir="auto"><br></div><div dir="auto">On Fri, Mar 26, 2021, 1:27 AM Galaxy Being <<a href="mailto:borgauf@gmail.com" target="_blank" rel="noreferrer">borgauf@gmail.com</a>> wrote:<br></div><div dir="auto"><div class="gmail_quote" dir="auto"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm sure you've answered my question, but I'm too much of a beginner to fathom it. If you could explain, that would be great, but I could also go off and try to grok it myself. Again, thanks.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 26, 2021 at 12:09 AM Ignat Insarov <<a href="mailto:kindaro@gmail.com" rel="noreferrer noreferrer" target="_blank">kindaro@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Galaxy Being!<br>
<br>
You can do this:<br>
<br>
module Y where<br>
<br>
substitute ∷ (α → Bool) → (α, [α]) → [α]<br>
substitute predicate = \ thing → case thing of<br>
(_, [ ]) → [ ]<br>
(substitution, (x: xs)) →<br>
let remainder = substitute predicate (substitution, xs) in<br>
if predicate x<br>
then substitution: remainder<br>
else x: remainder<br>
<br>
It is even nicer since we can factor out the common part of the `if`<br>
block into a `let … in`. You can also enable the `LambdaCase` language<br>
extension and it will let you elide the `thing` thing.<br>
<br>
I am not sure if this is what your question is really about… In<br>
principle, of course Haskell has currying. Actually, functions are<br>
usually written in curried form in Haskell. Please let me know if I<br>
missed the substance of your question!<br>
</blockquote></div>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div></div></div></div></div>