Skip to content

forketyfork/learn-you-a-haskell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learn You a Haskell

Build status MIT License Haskell

Code examples and exercises from the "Learn You a Haskell for Great Good!" tutorial.

Structure

The repository is organized by chapters:

  • ch1/ - Starting out
  • ch2/ - Believe the type
  • ch3/ - Syntax in functions
  • ch4/ - Recursion
  • ch7/ - Modules
  • ch8/ - Input and output
  • ch9/ - More input and more output
  • ch10/ - Functionally solving problems
  • ch11/ - Functors, applicative functors and monoids
  • ch13/ - For a few monads more
  • ch14/ - Zippers
  • ch15/ - Conclusion

Prerequisites

  • Nix with flakes enabled. If flakes are not enabled on your system, you can use the one‑shot form:
nix --extra-experimental-features 'nix-command flakes' develop

Quick start (Nix flakes)

Enter the development shell:

nix develop

Run examples inside the shell:

ghci ch1/baby.hs
ghc ch1/baby.hs && ./baby

Not using Nix? See Running the Code (without Nix) below.

Project scripts

All scripts are meant to run inside nix develop so they match CI:

  • ./scripts/compile.sh — typecheck every ch*/*.hs with ghc --make -fno-code, wiring include paths so inter-file imports resolve.
  • ./scripts/lint.sh — run hlint and ormolu --mode check over all Haskell files.
  • ./scripts/clean.sh — remove GHC artefacts (*.hi, *.o) and executables produced alongside the sources.

Formatting

Format Nix files via the flake formatter:

nix fmt

Editor integration

Haskell Language Server works inside the nix develop shell. Optionally use direnv to auto‑enter the dev shell in your editor.

Running the Code (without Nix)

You can compile and run individual Haskell files using GHC:

ghc filename.hs
./filename

Or load them interactively in GHCi:

ghci filename.hs

About

Code examples and exercises from the "Learn You a Haskell for Great Good!" book

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •