Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Typelevel: the past, the present, the future

Lars Hupel
November 03, 2021

Typelevel: the past, the present, the future

The early 2010’s were exciting times for Scala. The language & ecosystem started to professionalize, both from a technical (binary compatibility) and a community point of view (many conferences were started). Not too long after Lightbend – then Typesafe – was founded, I registered the typelevel.org domain on a whim and put together a rudimentary website advertising a few FP-minded Scala libraries. Fast forward to today: Typelevel is known for a wealth of functional libraries, beginner-friendly educational resources, a series of conferences and a distinct ecosystem – including a custom compiler – within the Scala community. In this talk, I’d like to examine what got us there and how you could help shape the future.

Lars Hupel

November 03, 2021
Tweet

More Decks by Lars Hupel

Other Decks in Programming

Transcript

  1. T y p e l e v e l :

    t h e p a s t , t h e p r e s e n t , t h e f u t u r e L a r s H u p e l S c a l a C o n 2 0 2 1 - 1 1 - 0 3
  2. H u m b l e b e g i

    n n i n g s F o u n d e d i n 2 0 1 3 a t N o r t h e a s t S c a l a S y m p o s i u m
  3. H u m b l e b e g i

    n n i n g s F o u n d e d i n 2 0 1 3 a t N o r t h e a s t S c a l a S y m p o s i u m T o d a y : 7 0 + p r o j e c t s , v i b r a n t e c o s y s t e m
  4. T y p e l e v e l p

    r o j e c t s C e n t r a l t h e m e : S c a l a - i d i o m a t i c F u n c t i o n a l P r o g r a m m i n g
  5. T y p e l e v e l p

    r o j e c t s C e n t r a l t h e m e : S c a l a - i d i o m a t i c F u n c t i o n a l P r o g r a m m i n g • . . . w i t h a s l i t t l e h a s s l e a s p o s s i b l e
  6. T y p e l e v e l p

    r o j e c t s C e n t r a l t h e m e : S c a l a - i d i o m a t i c F u n c t i o n a l P r o g r a m m i n g • . . . w i t h a s l i t t l e h a s s l e a s p o s s i b l e • . . . w i t h a s l i t t l e r u n t i m e o v e r h e a d a s p o s s i b l e
  7. T y p e l e v e l p

    r o j e c t s C e n t r a l t h e m e : S c a l a - i d i o m a t i c F u n c t i o n a l P r o g r a m m i n g • . . . w i t h a s l i t t l e h a s s l e a s p o s s i b l e • . . . w i t h a s l i t t l e r u n t i m e o v e r h e a d a s p o s s i b l e • . . . a s s a f e a s p o s s i b l e
  8. T y p e c l a s s e

    s S u p r e m e l y u s e f u l t o o l , p i o n e e r e d i n H a s k e l l
  9. T y p e c l a s s e

    s S u p r e m e l y u s e f u l t o o l , p i o n e e r e d i n H a s k e l l class Semigroup a => Monoid a where mempty :: a mconcat :: [a] -> a mconcat = foldr mappend mempty
  10. T y p e c l a s s e

    s S u p r e m e l y u s e f u l t o o l , p i o n e e r e d i n H a s k e l l class Semigroup a => Monoid a where mempty :: a mconcat :: [a] -> a mconcat = foldr mappend mempty I t J u s t W o r k s ™ !
  11. T y p e c l a s s e

    s i n S c a l a . . . n o w w e j u s t n e e d t o e n c o d e t h e m i n S c a l a
  12. T y p e c l a s s e

    s i n S c a l a . . . n o w w e j u s t n e e d t o e n c o d e t h e m i n S c a l a • m u l t i p l e i n h e r i t a n c e ?
  13. T y p e c l a s s e

    s i n S c a l a . . . n o w w e j u s t n e e d t o e n c o d e t h e m i n S c a l a • m u l t i p l e i n h e r i t a n c e ? • s y n t a x ? ?
  14. T y p e c l a s s e

    s i n S c a l a . . . n o w w e j u s t n e e d t o e n c o d e t h e m i n S c a l a • m u l t i p l e i n h e r i t a n c e ? • s y n t a x ? ? • g l o b a l c o n f l u e n c e ? ? ?
  15. T y p e c l a s s e

    s i n S c a l a . . . n o w w e j u s t n e e d t o e n c o d e t h e m i n S c a l a • m u l t i p l e i n h e r i t a n c e ? • s y n t a x ? ? • g l o b a l c o n f l u e n c e ? ? ?
  16. T y p e c l a s s e

    s , e n c o d e d I n 2 0 1 5 , M i c h a e l P i l q u i s t s t a r t e d s i m u l a c r u m . G o a l : c o n s i s t e n t e n c o d i n g a c r o s s d i f f e r e n t p r o j e c t s , 0 b o i l e r p l a t e
  17. S i m u l a c r u m

    I n p u t import simulacrum._ @typeclass trait Semigroup[A] { @op("|+|") def append(x: A, y: A): A }
  18. S i m u l a c r u m

    O u t p u t object Semigroup { def apply[A](implicit instance: Semigroup[A]): Semigroup[A] = instance // ... }
  19. S i m u l a c r u m

    M o r e o u t p u t object Semigroup { trait Ops[A] { def typeClassInstance: Semigroup[A] def self: A def |+|(y: A): A = typeClassInstance.append(self, y) } }
  20. S i m u l a c r u m

    E v e n m o r e o u t p u t object Semigroup { trait ToSemigroupOps { implicit def toSemigroupOps[A](target: A)(implicit tc: Semigroup[A]): Ops[A] val self = target val typeClassInstance = tc } } object nonInheritedOps extends ToSemigroupOps }
  21. S i m u l a c r u m

    Y e t m o r e o u t p u t object Semigroup { trait AllOps[A] extends Ops[A] { def typeClassInstance: Semigroup[A] } object ops { implicit def toAllSemigroupOps[A](target: A)(implicit tc: Semigroup[A]): AllO val self = target val typeClassInstance = tc } } }
  22. B u t i t w o r k s

    ! S i m u l a c r u m s o l v e d a t o n o f i s s u e s W e c a n w r i t e x |+| y!
  23. B u t i t w o r k s

    ! S i m u l a c r u m s o l v e d a t o n o f i s s u e s W e c a n w r i t e x |+| y! U s e d b y C a t s a n d t o n s o f t h i r d - p a r t y l i b r a r i e s
  24. N u m e r i c s f o

    r S c a l a • s t a r t e d o u t a s a S I P i n 2 0 1 1 ( ! ) • e v o l v e d i n t o a d e d i c a t e d l i b r a r y • “ w h a t i f f u n c t i o n a l b u t a l s o f a s t ”
  25. W h a t a b o u t p

    e r f o r m a n c e ? S i m u l a c r u m d i d n ’ t s o l v e t h e p e r f o r m a n c e i s s u e o f t y p e c l a s s e s .
  26. W h a t a b o u t p

    e r f o r m a n c e ? S i m u l a c r u m d i d n ’ t s o l v e t h e p e r f o r m a n c e i s s u e o f t y p e c l a s s e s . I n p u t x |+| y
  27. W h a t a b o u t p

    e r f o r m a n c e ? S i m u l a c r u m d i d n ’ t s o l v e t h e p e r f o r m a n c e i s s u e o f t y p e c l a s s e s . O u t p u t Semigroup.ops.toAllSemigroupOps(x).|+|(y)
  28. E n t e r M a c h i

    n i s t S p l i t o u t o f S p i r e b y E r i k O s h e i m i n 2 0 1 4
  29. E n t e r M a c h i

    n i s t S p l i t o u t o f S p i r e b y E r i k O s h e i m i n 2 0 1 4 N o w ( 2 0 2 0 ) a r c h i v e d a n d r e - i n c o r p o r a t e d i n t o S p i r e
  30. • s t a r t e d o u

    t a s a s e r i e s o f t a l k s i n 2 0 1 1 ( ! ) • s c r a t c h e d a n i t c h : h o w t o a b s t r a c t o v e r d a t a ? • p i o n e e r e d “ t y p e c l a s s d e r i v a t i o n ” • m a n y c o n c e p t s i n c o r p o r a t e d i n t o S c a l a 3
  31. T y p e C l a s s D

    e r i v a t i o n P r o b l e m : Y o u w a n t t o s e r i a l i z e a b u n c h o f c a s e c l a s s e s t o J S O N . S o l u t i o n : B o i l e r p l a t e ?
  32. T y p e C l a s s D

    e r i v a t i o n P r o b l e m : Y o u w a n t t o c o m p a r e a b u n c h o f c a s e c l a s s e s . S o l u t i o n : B o i l e r p l a t e . . . a g a i n ? !
  33. case class Account(owner: Person, balance: Int) case class Person(name: String,

    address: Address) case class Address(lines: List[String], country: Country) case class Country(code: String)
  34. type Account = Person :: Int :: HNil type Person

    = String :: Address :: HNil type Address = List[String] :: Country :: HNil type Country = String :: HNil
  35. • f u l l h i s t o

    r y a l m o s t i m p o s s i b l e t o t r a c e • d r a w s f r o m m u l t i t u d e o f i n f l u e n c e s • s u p p o r t s t h e r i s e o f a s y n c h r o n o u s s o f t w a r e c o n s t r u c t i o n
  36. W h a t h a p p e n

    e d s i n c e 2 0 1 3 ? • i n 2 0 1 4 , w e f o r k e d S c a l a • i n 2 0 1 5 , E r i k s t a r t e d C a t s • i n 2 0 1 6 , w e o r g a n i z e d o u r f i r s t c o n f e r e n c e • i n 2 0 1 6 , L a r s j o i n e d t h e S c a l a C e n t e r A d v i s o r y B o a r d • i n 2 0 1 7 , w e s h u t d o w n t h e S c a l a f o r k • i n 2 0 1 7 , w e r e l e a s e d C a t s 1 . 0 . 0 • i n 2 0 1 9 , w e l a u n c h e d a d o n a t i o n c a m p a i g n • i n 2 0 2 0 , T y p e l e v e l l i b r a r i e s w e r e a t t h e f o r e f r o n t o f D o t t y
  37. s e r i o u s l y t

    h e a n s w e r i s a l m o s t a l w a y s . t r a v e r s e S o a r e w e n o t f l a t m a p p i n g t h a t s h i t a n y m o r e ? t r a v e r s e i s f l a t m a p p i n g t h a t s h i t o n o u r b e h a l f
  38. Q & A L a r s H u p

    e l � l a r s . h u p e l @ i n n o q . c o m � @ l a r s r _ h w w w . i n n o q . c o m
  39. L A R S H U P E L S

    e n i o r C o n s u l t a n t i n n o Q D e u t s c h l a n d G m b H L a r s i s k n o w n a s o n e o f t h e f o u n d e r s o f t h e T y p e - l e v e l i n i t i a t i v e w h i c h i s d e d i c a t e d t o p r o v i d i n g p r i n c i p l e d , t y p e - d r i v e n S c a l a l i b r a r i e s i n a f r i e n d l y , w e l c o m i n g e n v i r o n m e n t . A f r e q u e n t c o n f e r e n c e s p e a k e r , t h e y a r e a c t i v e i n t h e o p e n s o u r c e c o m - m u n i t y , p a r t i c u l a r l y i n S c a l a .
  40. S o u r c e s • https://pixabay.com/photos/people-business-meeting-1979261/ •

    https://unsplash.com/photos/FaNUdWGJqBg • https://twitter.com/bodil/status/1383908807588204552/photo/1 • https://twitter.com/milessabin/status/1364523756601937921 • https://www.manning.com/books/functional-programming-in-scala • https://impurepics.com/posts/2021-03-31-cats-effect-3.html • https://twitter.com/tpolecat/status/721019769869045760