2015年技术黑客项目回顾
28 December 2015 (programming (https://gergo.erdi.hu/blog/tags/programming)haskell (https://gergo.erdi.hu/blog/tags/haskell)idris (https://gergo.erdi.hu/blog/tags/idris)javascript (https://gergo.erdi.hu/blog/tags/javascript)games (https://gergo.erdi.hu/blog/tags/jatek)electronics (https://gergo.erdi.hu/blog/tags/electronics)avr (https://gergo.erdi.hu/blog/tags/avr)fpga (https://gergo.erdi.hu/blog/tags/fpga)meta (https://gergo.erdi.hu/blog/tags/meta))
Encsé writes (http://csokavar.hu/blog/2015/12/mini-scheme/) in his blog that one of the reasons he created a tiny CPS-based Scheme interpreter (https://github.com/encse/sicp) was because he realized he hasn't done any fun side projects all year. So I thought I'd make an inventory of fun hacks I've done in 2015.
Bit-fiddling
• An FPGA implementation of the Commodore PET (https://gergo.erdi.hu/blog/2015-03-02-initial_version_of_my_commodore_pet/). This is still not fully finished: although I managed to hunt down the bug mentioned at the end of the blog post, I still haven't gotten around to implementing Datasette (tape) I/O.
• Viki & I put together a prototype for an AVR-based CHIP-8 (https://en.wikipedia.org/wiki/CHIP-8) handheld. This one has no web presence yet; we're hoping to finalize the design into a PCB-based one, before releasing the schematics and the code.
https://gergo.erdi.hu/blog/2015-12-28-hacks_of_2015/chip328.jpg
• Went to a hackerspace.sg (http://hackerspace.sg/) workshop/hackathon for the Fernvale (http://www.bunniestudios.com/blog/?p=4297) platform. Not much came out of that, I think I was the only person who at least got as far as running my own code on the device (reusing the low-level bitbanging from Fernly (https://github.com/xobs/fernly) of course). I ended up doing some lame but colourful animations on the screen that would have gotten me boo'd off the stage in a 1986 demo compo.
Games
• I wanted to do some old-school 8-bit hacking, and ended up reverse-engineering and then reimplementing in Inform 6 (http://inform-fiction.org/) the classic Hungarian text adventure game Időrégész (https://gergo.erdi.hu/blog/2015-06-05-idoregesz_2015/). This even got me my fifteen minutes (http://iddqd.blog.hu/2015/06/05/breking_idoregesz_bongeszoben) on Hungarian retro-gaming blog IDDQD.
• I managed to convince Viki to join me in participating in MiniLD #56 (http://ludumdare.com/compo/2015/01/07/minild-56-pick-n-mix-2/). We decided early on to go with only 2 keyboard keys, 4 colours, one game mechanic, and a dancing theme — so, a rhythm game! To make deployment easy, we wanted it to be playable via just a web browser, and ended up choosing Elm (http://elm-lang.org/) as our development platform. The end result, after a frantic weekend of hacking, is Two-Finger Boogie (https://gergo.erdi.hu/projects/tfb/).
Talks
• I gave an introductory talk on Kansas Lava (https://gergo.erdi.hu/blog/2015-12-28-hacks_of_2015/projects/lava/2015-05-sg-kansas-lava-talk.pdf) first at Haskell.SG (http://www.meetup.com/HASKELL-SG/) and then again at FP-BUD (http://www.meetup.com/fp-bud/) while visiting friends & family back in Hungary.
• Presented McBride's seminal paper on zippers (http://strictlypositive.org/diff.pdf) (that was sadly never published AFAIK) at Papers We Love's Singapore chapter (http://paperswelove.org/chapter/singapore/) (slides and Haskell implementation available here (https://gergo.erdi.hu/projects/talks/2015-06-zipper/)).
• Back in October, the self-interpreting in F ω (http://compilers.cs.ucla.edu/popl16/) paper started making huge waves in PLT circles. I was only three pages in when I knew I had to present it at Papers We Love. The eventual talk (https://gergo.erdi.hu/projects/talks/2015-11-fomega/FOmegaUnquote.pdf) took a couple weeks to prepare for, but it was worth it because it went really well.
Functional programming
• Fixed a long-standing bug in MetaFun (https://gergo.erdi.hu/projects/metafun/), the "Haskell"-to-C++ template metaprogram compiler: patterns in function definitions are now tried for matching in the correct order.
• Wrote a Bison summary parser (https://github.com/gergoerdi/bison-parser) that a co-worker wanted to use to generate exhaustive test cases for Bison-generated parsers. That project ended up not going anywhere as far as I know.
• If you use every GHC extension and then some, you can write a fairly nifty untyped-to-typed embedding of STLC (https://gergo.erdi.hu/blog/2015-02-05-typed_embedding_of_stlc_into_haskell/) that is almost as nice as doing it in a proper dependently typed language!
Stack Overflow highlights
Some of the answers I wrote this year on Stack Overflow (http://stackoverflow.com/) required me to learn just enough of something new to be able to answer the question:
• Learned just enough about Uniplate (http://community.haskell.org/~ndm/uniplate/) to figure out how to do out-of-band code generation (http://stackoverflow.com/a/31738169/477476).
• Learned just enough about Persistent (https://hackage.haskell.org/package/persistent) to figure out how entity keys are represented on SQL database backends (http://stackoverflow.com/a/31900417/477476).
• Learned just enough about Spock (https://www.spock.li/) to figure out how to store state between handler invocations (http://stackoverflow.com/a/31958855/477476) (spoiler alert: it's horrible).
• Learned just enough about data-reify (http://ku-fpg.github.io/software/data-reify/) to figure out how to observe sharing in a graph (http://stackoverflow.com/a/33337598/477476)
• Learned just enough about Pipes (https://hackage.haskell.org/package/pipes) to figure out not just how to generalize runEffect (http://stackoverflow.com/a/33293858/477476), but also a way to get notified about the end of the input (http://stackoverflow.com/a/34259646/477476).
• Learned just enough about Accelerate (https://github.com/AccelerateHS/accelerate/blob/master/README.md) to figure out marshalling of Array s (http://stackoverflow.com/a/33561048/477476).
• Learned just enough about Template Haskell (https://wiki.haskell.org/Template_Haskell) to figure out how to create and use custom annotations (http://stackoverflow.com/a/33563878/477476). OK, so maybe this isn't strictly true, as Template Haskell is something I've known already, but the annotations stuff was definitely new.
• Learned just enough about Euterpea (https://hackage.haskell.org/package/Euterpea), and the Karplus-Strong algorithm (https://en.wikipedia.org/wiki/Karplus%E2%80%93Strong_string_synthesis), to figure out how to synthesize a plucked string-like sound out of thin air and white noise (http://stackoverflow.com/a/33625848/477476).
• Learned just enough about GHCJS (https://github.com/ghcjs/ghcjs) to figure out how unboxed Vector s can be efficiently marshalled to Javascript (http://stackoverflow.com/a/34435530/477476).
• Learned just enough about GHC's RULES facility (https://wiki.haskell.org/GHC/Using_rules) to figure out how to wrangle it to submission when rewriting overloaded functions (http://stackoverflow.com/a/32133083/477476).
• Learned just enough about LLVM (http://llvm.org/) and GHC's run-time system to figure out how to present handwritten LLVM assembly to GHC as a prim-op (http://stackoverflow.com/a/34088207/477476).
Then, there were those where it turned out there was a bug to be found by scratching the surface of the question deep enough:
• I've found a bug in Idris's typechecker in the face of typeclass polymorphism (http://stackoverflow.com/a/28475296/477476)
• Even though Tardis (https://hackage.haskell.org/package/tardis) and rev-state (https://hackage.haskell.org/package/rev-state) should be mostly the same code (and they are even written by the same developer!), the latter's MonadFix instance had a one-character, fatal flaw (http://stackoverflow.com/a/34287498/477476).
Then there were the answers that were just too much fun to write:
• A small romp in integer arithmetic (http://stackoverflow.com/a/31265445/477476) to implement rational addition in Agda
• Reimplementing Parsec in Idris (http://stackoverflow.com/a/33448261/477476) because I was too lazy to look into Lightyear (https://github.com/ziman/lightyear).
• What is the codensity-like representation of MonadPlus? This paper (http://people.cs.kuleuven.be/~tom.schrijvers/Research/papers/ppdp2015.pdf) answers the question by wonderfully building up a generalization of DList and Codensity for something which is almost MonadPlus. I ended up writing a summary of the paper (http://stackoverflow.com/a/32333576/477476).
• Having worked on GHC two years ago to implement pattern synonyms (https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms), with the understanding of GHC's type checker internals still fresh in my mind, I was just the right person to explain the GHC code base's usage of the word zonking (http://stackoverflow.com/a/31890743/477476).
All in all, it seems this has been quite a productive year for me out of the office, even if you exclude the Stack Overflow part. I was actually surprised how long this list was while compiling it for this blog post. Maybe I should write a list like this every year from now...