Git Product home page Git Product logo

practical_haskell's Introduction

Practical Haskell

  • get the book here
  • repo (doesn't include solutions) is here

This has my solutions to some of the exercises in the book

Errata / Notes

Ch6

Pg 215 gives a kMeans implementation using state:

  • line t <- fmap threshold get can be replaced with t <- gets threshold
  • likely importing import qualified Control.Monad.State as S so everything is S.modify, S.get, S.State etc.

Pg 221 in the type Settings you don't need the user :: Person as it looks like cruft

Pg 223 Exercise 6-6 you need to implement Functor and Applicative in order to implement Monad. That's what the type error is going to tell you in this question.

Ch7

Pg 240 Exercise 7-3 should include InfoClientGender Male

Pg 241 Apriori Algorithm - I found this page for what the algorithm was doing

Pg 250 The referenced paper: Adventures in three monads by Edward Z. Yang. Note to self: has a good overview of MonadFail typeclass

Pg 254 Exercise 7-5 the signature for sequence is monad m => [m a] -> m [a]

Pg 262 This is a good introduction to monad transformers that is more clear than the book

Pg 263 Exercise 7.6 was very clear once I read a few exampls here in the monad transformers section

Pg 264 Exercise 7.7 This exercise is terrible and I have no idea what the author wants. I spent 6+ hours on this. Eventually came across this SO post from his firstbook although the solution crashes with an exception (!!!) around mzero in my ch7Transformers.hs file. I wrote a version using ReaderT / WriterT explicitly and it works although I find the lifting of the list monad using ask >>= msum . map return to be super confusing. I have no idea what the author wants and if anyone knows please open an issue and explain it or track me down on twitter in this discussion when I was asking the world about this question

Ch 8

Skipping. I've worked through a bunch of parallel and concurrent programming in haskell before so I'm moving onto the next chapter.

Ch 9

  • Accessing files pg 332 need to bring in package conduit-extra
  • winnersFile example on pg 333 make sure to concat <> BS.pack \n

Ch 10

Note: skipping most of the exercises in this chapter as they are tedious AF. Parsing is super interesting and there are more fun ways to play with them: see here and particularly this one

  • pg 359 you don't need the let c = part, you can just run parseOnly aClient b instead

  • Ex 10-1 skipped, Ex 10-2 skipped

  • Ex 10-3

This was a bit of a pita actually. The clientToJson written in the book is for the Integer type, the question uses the Int type so watch out for that Encoding doubles: need to use realToFrac. Encoding the list of products led me to this which led me to the fromList fn from GHC.Ext which isn't mentioned in the book.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.