• Stars
    star
    3,391
  • Rank 13,197 (Top 0.3 %)
  • Language
    Scala
  • License
    Apache License 2.0
  • Created almost 13 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generic programming for Scala

shapeless: generic programming for Scala

shapeless is a type class and dependent type based generic programming library for Scala. It had its origins in several talks by Miles Sabin (@milessabin), given over the course of 2011, on implementing scrap your boilerplate and higher rank polymorphism in Scala. Since then it has evolved from being a resolutely experimental project into a library which, while still testing the limits of what's possible in Scala, is being used widely in production systems wherever there are arities to be abstracted over and boilerplate to be scrapped.

Discord Gitter Maven Central Scala.js

Projects which use shapeless

There is a wide variety of projects which use shapeless in one way or another ... see the incomplete list of projects for ideas and inspiration. If you are using shapeless and your project isn't listed yet, please add it.

Finding out more about the project

The feature overview for shapeless-2.0.0 provides a very incomplete introduction to shapeless. Additional information can be found in subsequent release notes. If you are upgrading from shapeless-2.0.0 you will find the migration guide useful. We're not satisfied with the current state of the documentation and would love help in improving it. You can find an excellent guide to Shapeless here: The Type Astronaut's Guide to Shapeless.

shapeless is part of the Typelevel family of projects. It is an Open Source project under the Apache License v2, hosted on github. Binary artefacts are published to the Sonatype OSS Repository Hosting service and synced to Maven Central.

Most discussion of shapeless and generic programming in Scala happens on the #shapless channel of the Typelevel Discord. There is also a mailing list and Gitter, but these are largely dormant now that most activity has moved to Discord. Questions about shapeless are often asked and answered under the shapeless tag on StackOverflow. Some articles on the implementation techniques can be found on Miles's blog, and Olivera, Moors and Odersky, Type Classes as Object and Implicits is useful background material.

Participation

The shapeless project supports the Scala Code of Conduct and wants all of its channels (mailing list, Gitter, IRC, github, etc.) to be welcoming environments for everyone.

Whilst shapeless is a somewhat "advanced" Scala library, it is a lot more approachable than many people think. Contributors are usually available to field questions, give advice and discuss ideas on the #shapeless Discord channel, and for people wanting to take their first steps at contributing we have a selection of open issues flagged up as being good candidates to take on. No contribution is too small, and guidance is always available.

Using shapeless

Binary release artefacts are published to the Sonatype OSS Repository Hosting service and synced to Maven Central. Snapshots of the main branch are built using GitHub actions and automatically published to the Sonatype OSS Snapshot repository.

Try shapeless with an Ammonite instant REPL

The quickest way to get to a REPL prompt with the latest version of shapeless on the class path is to run the provided "try shapeless" script, which has no dependencies other than an installed JDK. This script downloads and installs coursier and uses it to fetch the Ammonite REPL and the latest version of shapeless. It then drops you immediately into a REPL session,

% curl -s https://raw.githubusercontent.com/milessabin/shapeless/main/scripts/try-shapeless.sh | bash
Loading...
Compiling (synthetic)/ammonite/predef/interpBridge.sc
Compiling (synthetic)/ammonite/predef/replBridge.sc
Compiling (synthetic)/ammonite/predef/DefaultPredef.sc
Compiling /home/miles/projects/shapeless/(console)
Welcome to the Ammonite Repl 1.6.8
(Scala 2.13.1 Java 1.8.0_212)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ 23 :: "foo" :: true :: HNil 
res0: Int :: String :: Boolean :: HNil = 23 :: "foo" :: true :: HNil

@ Bye!
%

shapeless-2.3.3 with SBT

To include the Sonatype repositories in your SBT build you should add,

resolvers ++= Seq(
  Resolver.sonatypeRepo("releases"),
  Resolver.sonatypeRepo("snapshots")
)

Builds are available for Scala 2.11.x, 2.12.x and 2.13.x. The main line of development for shapeless 2.3.3 is Scala 2.13.2.

scalaVersion := "2.13.5"

libraryDependencies ++= Seq(
  "com.chuusai" %% "shapeless" % "2.3.3"
)

For using snapshots of Shapeless you should add,

scalaVersion := "2.13.5"

libraryDependencies ++= Seq(
  "com.chuusai" %% "shapeless" % "2.4.0-SNAPSHOT"
)

shapeless-2.3.3 with Maven

shapeless is also available for projects using the Maven build tool via the following dependency,

<dependency>
  <groupId>com.chuusai</groupId>
  <artifactId>shapeless_2.13</artifactId>
  <version>2.3.3</version>
</dependency>

Older releases

Please use a current release if possible. If unavoidable, you can find usage information for older releases on the shapeless wiki.

Building shapeless

shapeless is built with SBT 1.3.10 or later, and its main branch is built with Scala 2.13.2 by default but also cross-builds for 2.11.12 and 2.12.12.

Contributors

More Repositories

1

export-hook

Minimal infrastructure for type class providers to support the inclusion of derived, subclass and other orphan instances in their implicit scope.
Scala
89
star
2

macro-compat

macro-compat is a small library which allows you to compile macros with Scala 2.10.x which are written to the Scala 2.11/2 macro API.
Scala
86
star
3

si2712fix-plugin

Fix for SI-2712 implemented as a compiler plugin for Scala 2.11.8 and 2.10.6
Scala
47
star
4

shapeless-type-class-derivation-2015-demo

Example code from my presentation on shapeless type class derivation
Scala
29
star
5

si2712fix-demo

This repository contains a minimal SBT project for experimenting with a fix for SI-2712
Scala
19
star
6

tls-philly-rbtree-2016

Scala
16
star
7

shapeless-macros

Experiments with implicit macros from scalamacros/kepler.
Scala
14
star
8

spray-json-shapeless

Magical Shapeless JsonFormats for spray-json
Scala
12
star
9

strangeloop-2013

Scala demo code from my/Edwin Brady's talk "Scala vs. Idris: Dependent types now and in the future" at Strange Loop 2013
Scala
10
star
10

scala-cont-jvm-coro-talk

Scala LiftOff London 2011
Scala
10
star
11

shapeless-workshop-scaladayssf-2015

Skeleton SBT project for shapeless workshop @ ScalaDays SF 19/3/2015
Shell
4
star
12

shapeless-workshop-paris

Skeleton SBT project for shapeless workshop @ Scala.IO 24/10/2013
2
star
13

flatmap-si2712-2016

Slides from my talk at flatMap(Oslo) 2016 on fixing SI-2712.
HTML
2
star
14

sbtb-typelevel-2016

Slides from my talk "Typelevel in 2016" at Scala By the Bay
HTML
1
star
15

shapeless-type-class-derivation-2015

Slides from my presentation on shapeless type class derivation
HTML
1
star
16

checkout

Scala
1
star
17

scala-exchange-2017

Slides from my talk at Scala eXchange London, 2017
HTML
1
star
18

tls-demo

Project demonstrating Typelevel Scala features
XSLT
1
star
19

scaladays-typelevel-2016

HTML
1
star
20

shapeless-workshop-scalax-2014

Skeleton SBT project for shapeless workshop @ after Scala eXchange 2014
Shell
1
star
21

scala-days-2014

Demo code from my/Jon Pretty's talk at Scala Days 2014 in Berlin.
Scala
1
star