
andre
Effective Haskell: Chapter 10 - directorySummaryWithMetrics (B9 - PDF version)
On p.386, we have the final version of directorySummaryWithMetrics.
When running the code, we see the histogram results with empty characters.
It looks like this
Histogram Data:
: 9091
: 59
: 23
: 1
: 2
: 59
: 12900
: 643147
: 20
: 22
: 563
: 6
: 666771
!: 1476
": 137317
#: 7367
...
The non-printable characters do not display. You can see the empty fields above ASCII value 20 (a total of 666771 spaces here).
Here are the last few lines of the function:
histogram <- readIORef histogramRef
putStrLn "Histogram Data:"
for_ (Map.toList histogram) $ \(letter, count) ->
putStrLn $ printf " %c: %d" letter count
displayMetrics metrics
I suggest to add a check using isControl.
import qualified Data.Char as Char (isControl)
...
histogram <- readIORef histogramRef
putStrLn "\n\nHistogram Data:" -- Added "\n\n"
for_ (Map.toList histogram) $ \(letter, count) ->
if Char.isControl letter then -- Added if .. then ...
putStrLn $ printf " %d: %d" letter count
else
putStrLn $ printf " %c: %d" letter count
displayMetrics metrics
–
Andre
Popular Pragmatic Bookshelf topics

Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’.
In particula...
New

Hi Brian,
Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
New

When I try the command to create a pair of migration files I get an error.
user=> (create-migration "guestbook")
Execution error (Ill...
New

Dear Sophie.
I tried to do the “Authorization” exercise and have two questions:
When trying to plug in an email-service, I found the ...
New

#book-python-testing-with-pytest-second-edition
Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New

@noelrappin
Running the webpack dev server, I receive the following warning:
ERROR in tsconfig.json
TS18003: No inputs were found in c...
New

Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New

Hello @herbert ! Trying to get the very first “Hello, Bracket Terminal!" example to run (p. 53). I develop on an Amazon EC2 instance runn...
New

root_layout: {PentoWeb.LayoutView, :root},
This results in the following following error:
no “root” html template defined for PentoWeb...
New

@mfazio23
Android Studio will not accept anything I do when trying to use the Transformations class, as described on pp. 140-141. Googl...
New
Other popular topics

poll
poll
Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New

Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New

Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New

“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco
Ever wonder how authoring books compares to writing articles?...
New

Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New

API 4
Path:
/user/following/
Method:
GET
Description:
Returns the list of all names of people whom the user follows
Response
[
{ ...
New

Was just curious to see if any were around, found this one:
I got 51/100:
Not sure if it was meant to buy I am sure at times the b...
New

Author Spotlight
Jamis Buck
@jamis
This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New

Author Spotlight
Erin Dees
@undees
Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New

This is a very quick guide, you just need to:
Download LM Studio: https://lmstudio.ai/
Click on search
Type DeepSeek, then select the o...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /ash
- /vscode
- /opensuse
- /centos
- /php
- /deepseek
- /scala
- /html
- /zig
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /django
- /manjaro
- /spring
- /diversity
- /lua
- /nodejs
- /c
- /julia
- /slackware
- /neovim