arliss_obsidian/fp/Language/Expressions/Lambda Functions.md
Orion Kindel 3ee2a9bbbd
update
2024-09-24 17:52:08 -05:00

23 lines
425 B
Markdown

lambda functions are anonymous functions (as opposed to [[Functions|top-level functions]]) that can be written anywhere:
```haskell
\ <params> -> <body>
```
```haskell
prependHello a = "hello, " <> a
appendName = \a -> a <> "henry!"
str = appendName $ prependHello ""
-- hello, henry!
```
their parameters can destructure their arguments:
```haskell
let
getFoo = \{foo} -> foo
in
getFoo {foo: "hello"}
-- "hello"
```