Skip to content

How to write the code for chapter 3? #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nathanielvirgo opened this issue Dec 26, 2020 · 3 comments
Closed

How to write the code for chapter 3? #264

nathanielvirgo opened this issue Dec 26, 2020 · 3 comments

Comments

@nathanielvirgo
Copy link

nathanielvirgo commented Dec 26, 2020

The text of chapter 3 seems to be structured as if I'm meant to enter the AddressBook code into a file as I go through it. (e.g. it refers to "the code you wrote".) I think it would be helpful to work that way - I find it quite helpful to enter the code myself and experiment with it as I go along, much more so than just reading code that's already written.

However, the AddressBook.purs file already exists in the repo, and already contains the complete implementation. I tried commenting out the contents of that file so I can re-enter them myself, but then spago build and spago repl fail, because stuff in Test.NoPeeking.Solutions expects to find the already-existing implementation.

So I guess my question is, what's the intended way for the code in chapter 3 to be used? Should I just start my own entirely new project for my own AddressBook implementation? Or a separate MyAddressBook.purs file within the same folder? At this point in the learning process it's not obvious what the right solution is, so it would be helpful if there would be some guidance about that in the book.

@razcore-rad
Copy link

For the purposes of prototyping and playing around without the tests getting in your way you could edit spago.dhall to not include the tests:

{-
Welcome to a Spago project!
You can edit this file as you like.
-}
{ name = "my-project"
, dependencies = [ "console", "effect", "lists", "psci-support", "test-unit" ]
, packages = ./packages.dhall
-- , sources = [ "src/**/*.purs", "test/**/*.purs" ]
, sources = [ "src/**/*.purs" ]
}

To be honest I don't remember how I went about it, I probably just focused on the exercises and used the provided source files as a recap mostly, without directly changing them.

I generally would recreate some of the variables to play with the syntax and try things independent of the source files, just inside MySolutions.purs and the repl.

@milesfrain
Copy link
Member

milesfrain commented Dec 27, 2020

I find it quite helpful to enter the code myself and experiment with it as I go along

I completely agree that it's much easier to learn if you have some code to write as you go along. I think solving exercises is even better than transcribing code snippets. Most of the other chapters do a much better job at interleaving exercises, and so the starter-code (AddressBook.purs in this case) seems like less of a wasted opportunity.

It's a shame that Ch3 is probably the worst example of interleaved exercises. It just squishes everything at the end. #252 is a proposal to fix that chapter.

Perhaps the best way to learn material is by teaching it, and so I'd be grateful if you could help us improve Ch3 by suggesting some exercises that we could add after the earlier sections. I also believe that some of the best learning material for beginners is contributed by folks who are also currently in the beginner's mindset, so feel free to rewrite anything that lacks clarity.

@Zelenya
Copy link

Zelenya commented Jun 7, 2023

This should be addressed by #252 and other restructuring efforts

@Zelenya Zelenya closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants