
melston
Effective Haskell: Discussion of map (page 58 B2)
In the discussion of map on page 58 you present the example:
map ($ 10) [(+1), (*3), (`div` 5)]
This confuses me a lot. You introduces the function application operator ($) back on page 15 as a way of forcing validation of arguments prior to the evaluation of the function. In that case the $ comes after the function but before the arguments.
Here we have the $ 10 as the function. I look at this example and it seems to be completely backward. I know what you are doing but I just cannot make sense of how it works. In fact, the ‘div’ example is a great example of where I go off the rails trying to understand this. If I execute
div 5 $ 10
in ghci I get the result 0. And, of course, this doesn’t work at all:
$ 10 `div` 5 // or even $ 10 div 5
So what this does is
div 10 5
But, for the life of me, I cannot figure out how that happens from the given map command.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /react-native
- /v
- /wasm
- /django
- /security
- /nodejs
- /centos
- /rails
- /haskell
- /fable
- /gleam
- /swift
- /js
- /deno
- /tailwind
- /assemblyscript
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /c-plus-plus
- /preact
- /flutter
- /actix
- /java
- /angular
- /ocaml
- /kubuntu
- /zig
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /keyboards
- /html
- /emacs
- /vuejs
- /nim
- /nerves
- /elm