Skip to content

Instantly share code, notes, and snippets.

@davegurnell
Last active October 21, 2016 02:55
Show Gist options
  • Save davegurnell/7d6c578be55698a41659 to your computer and use it in GitHub Desktop.
Save davegurnell/7d6c578be55698a41659 to your computer and use it in GitHub Desktop.
ScalaDays Shapeless Workshop Notes

Shapeless Gitter

Keep in touch and up-to-date with the latest shapeless news here:

https://gitter.im/milessabin/shapeless

Shapeless Code and Material

The shapeless codebase is on Miles' Github:

https://github.com/milessabin/shapeless

The demo codebase we used in the workshop is here:

https://github.com/milessabin/shapeless-type-class-derivation-2015-demo

The slides Miles used at the beginning are here:

https://github.com/milessabin/shapeless-type-class-derivation-2015

The font used in the code in the slides is available here ;)

http://dejavu-fonts.org/wiki/Main_Page

Finally, here are some notes I made at Miles' previous shapeless workshop at Scala Exchange 2014. That workshop focused more on the inner workings of the code and introduced some of the non-type-class-related utilities like Nats and Polys:

https://github.com/davegurnell/shapeless-workshop-scalax-2014/blob/master/README.md

Case Study: Arbitrary Values

Here's Team Arbitrary's code from the workshop:

https://github.com/bsadeh/shapeless-type-class-derivation-2015-demo

Here's a link to Alexandre Archambault's Scalacheck Shapeless library that does similar things for Scalacheck, including generating Arbitrary instances to generate values and Shrink instances to reduce failing tests to simple inputs. This makes similar use of the Length typeclass to produce unbiased distributions across Coproducts:

https://github.com/alexarchambault/scalacheck-shapeless

Case Study: Readers and Writers

Here's Team Reader/Writer's code from the workshop:

https://gist.github.com/rcavalcanti/60e492abfcff2e2e7860

Here are some good examples of readers and writers written using shapeless. Alexandre's Shapeless Argonaut codebase, in particular, is short, focused, and very readable. Note the use of LabelledGeneric in situations where the library needs access to the type and field names in Coproducts and HLists:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment