
pennychase
Effective Haskell Chapter 11
@RebeccaSkinner
In Effective Haskell Chapter 11 (~ p 410 in ePub), when creating the Encode and Decode instances for String, pack and unpack are used, but given all the imports, ghci couldn’t resolve them so I needed to use the qualified names, BC.pack and BC.unpack.
Serializing FileMode (approx p. 413 in ePub) doesn’t work on Macs since CMode wraps a Word16, not Word32. I was baffled because the documentation on Hackage said CMode wraps a Word32, not realizing that the Hackage docs were probably generated on a Linux box. I ended up writing the encoding/decoding for Word16 so GHC could pick the right one.
When defining Encode to have encode and encodeWithSize (approx p 415 in ePub), the MINIMAL pragma is missing the # at the opening ( {-
instead of {-#
)
I assume there was some refactoring going on because the FileData type was defined with record fields: fileName, fileSize, filePermissions, and fileData, but the Encode instance uses packedFileName, packedFileSize, packedFilePermissions, and packedFileData.
The file pack example is a fun one for getting at these different data encodings.
Most Liked

RebeccaSkinner
Thanks for the comment and the PR. As I mentioned on the PR, I want to make some space to show off reader solutions and call out people who have found bugs so that future readers can be warned, and so the folks who find the bugs are getting public credit.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /centos
- /ash
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /textmate
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim