andre

andre

Effective Haskell:Chapter 13 (B9 - PDF version) - infinite loop when running the ClassyArchiver code

Refer to pages 508-511

I get an infinite loop when running the original parseArchive function, after adding a variable called "archiveDef, which codifies the example given on p.491.


archiveDef :: Text
archiveDef = Text.unlines $
  [ "archive \"example.archive\":"
  , ""
  , "import \"./extras/example1.txt\""
  , ""
  , "new-file \"inline-example.txt\":"
  , "     this is some text"
  , "     it can have newlines"
  , "     but it needs to be indented"
  , ""
  , "import \"./extras/example2.txt\""
  ]

λ> runArchiver archiveDef parseArchive

I’ve changed the parseArchive function by removing “parseBlock”.
I commented out the original line and added the modification under it.


parseArchive :: Archiver Archive
parseArchive = do
    expectText "archive"
    dropSpaces
    archiveName <- quotedString
    expectText ":\n"
    -- files <- parseBlock parseArchiveStatements
    files <- parseArchiveStatements               -- CHANGE HERE
    pure $ Archive archiveName files

The infinite loop disappears when using this modified version.

0 411 0

Popular Prag Prog topics Top

brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
2 1374 2
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
22 1618 20
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
2 1425 11
New
rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
9 1256 4
New
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
17 1370 9
New
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
0 1757 6
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
2 1004 2
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
1 3024 5
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
8 1085 4
New

Other popular topics Top

foxtrottwist
Here’s our thread for the Keyboardio Atreus. It is a mechanical keyboard based on and a slight update of the original Atreus (Keyboardio ...
9 3083 6
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
118 6889 30
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
88 5068 32
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
24 3384 24
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
10 5357 8
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
78 3397 24
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
21 10832 7
New
PragmaticBookshelf
A Hero’s Journey with Chris Pine @chrispine Chris Pine, author of Learn to Program, Third Edition, discusses his journey to beco...
81 3229 26
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
37 2988 14
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
41 2556 20
New

Latest in PragProg

View all threads ❯