Justin du Coeur (jducoeur) wrote,
Justin du Coeur

For those who want to walk on the wild side of programming...

I'm starting to dig more seriously into Scala's Shapeless library, and it occurs to me that some of my more intrepid readers might find this interesting.

One of the most powerful and scary websites you will ever find in programming is typelevel.org. This is a collection of the most fascinating and brain-breaking libraries you will find out there today. AFAIK, they all derive at some level from the old observation that Scala's type system is sufficiently complex, it is actually Turing-complex unto itself. And that means you can do remarkable, powerful, slightly insane things with it.

The best-known of the bunch is scalaz (pronounced "ScalaZed", I gather). While it is oversimplifying to say that scalaz is Haskell implemented in Scala, I believe that's a decent first-order approximation.

There is Shapeless, linked above, which implements "polytypic" generic programming. The part that everyone gets swept up by is the HList data structure -- basically a meta-type which is a "list" of arbitrary other types, combining the best aspects of lists and tuples in a type-safe way -- but I gather that that is basically an implementation detail. The real goal is being able to abstract over algorithms at a higher-kinded level: for example, abstracting out the concept of "tree traversal" without needing to depend upon any specific implementation of "tree". (I think: Shapeless was the topic of the latest episode of The Scalawags, which inspired today's surfing.)

Those are the best-known parts of typelevel, but I find that there is a lot more there now. There is ScalaCheck, which lets you describe the "properties" of your methods, and then generates randomized data to hammer at those methods and make sure your invariants are actually invariant. There's scodec, a functional library for working with binary protocols. There is Spire, a numeric library that is designed to let you write efficient numeric code that works for any implementation of "number".

Etc -- the typelevel page itself is a bit thin, but provides pointers for what to look for online. I expect to spend a number of months wrapping my head around the more-interesting bits and pieces here...
Tags: programming, scala

  • Adtech

    Here's an interesting article about "adtech" -- those automated algorithms that companies like Google and Facebook use to spy on you and serve up…

  • Chrome instability?

    For the past week or two, Chrome has become surprisingly unstable -- it's been crashing on me about once a day. Weirdly, it is usually when I'm not…

  • Did Media Literacy Backfire?

    Here's a fascinating exploration from Danah Boyd (one of the better thinkers about the Internet and society), about the ways in which the current…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded