Thursday, March 14, 2013

[draft]The single critical haskell skill: Reducing code to the smallest testable/Hoogleable/REPL'able bit

OK, so you have code that doesn't typecheck, or you have code that compiles/works, but can't grok it. You have combinators, data structures, GHC language extension, you don't understand. You need to

- GHCi REPL: write minimal bits of functionality to ":load" into GHCi, [TODO, examples]

- compiler errors/warnings: read error messages you get on minimal bits (or wreck code that compiles and see what typecheck errors you get)

- type signatures read/search these in hoogle, Work on your google-fu and stackoverflow-fu.

- read Core : (save this for later) This is how you really dig in and see what's going on, but like debugging scala with "javap" bytecode, not easy.

- unit tests/BDD, QuickChecking: When you get something that works, decide what the appropriate testable unit is for your preferred style of tests


This means you need to have internalized lazy eval, associativity/precedence, and namespace/scoping rules.

Throw in extra parens if you like, to simplify associativity/precedence.


Also need to understand how GHCi operates in the IO monad and has a few syntactic differences.

- Use the GHCi page for your installed release, if not 7.6.2: haskell.org/ghc/docs/7.6.2/html/users_guide/ghci.html

- "let" without "in" for data declarations,

- you can do any top level declarations, as of 7.4.1

- GHCi keeps command history in ~/.ghc folder , ghci_history file. I haven't found an easy way to save and rerun pieces of a GHCi session, i.e. capture a transcript/log, this indicates it can't be done easily

- read you some Stackoverflow: 200+ threads tagged "GHCi"