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

Scala <> Haskell

Scala <> Haskell

An introduction and comparison of Scala and Haskell using examples.

Anler

May 06, 2017
Tweet

More Decks by Anler

Other Decks in Programming

Transcript

  1. The Basics 1. Two FP styles 2. Sum types 3.

    Pattern matching 4. Functions 5. Imperative constructions 6. Evaluation
  2. A sum/co-product type There is only one type: - Boolean

    and two constants: - True’ - False’
  3. Functions only accept one argument and return one result. Let’s

    see how can we emulate functions that receive more than one argument.
  4. Type-level programming 1. Type inference 2. Kind inference 3. Type

    classes 4. Multi-param type classes 5. Monad transformers
  5. Things that make Scala’s type system more powerful (hence less

    type inference): - sub typing polymorphism - type lambdas - … Recommended reading (the comments section): 
 http://pchiusano.blogspot.com.es/2011/05/making-most-of- scalas-extremely-limited.html
  6. The expression problem Operation\Data Data1 Data2 New data easy in

    OOP / difficult in FP Operation1 Operation2 Operation3 New operation easy in FP / hard in OOP
  7. Type-level programming 1. Type inference 2. Kind inference 3. Type

    classes 4. Multi-param type classes 5. Monad transformers
  8. scala world, lambda world, scalar, lambda conf, scala days, lx

    scala, typelevel submit, scala swarm, scala up north, scala exchange, scala io, compose, ICFP , …
  9. My view is that both languages are fantastic, Scala sacrifices

    type inference and some type safety in exchange of more power. Haskell tries to keep a core with good type inference and type safety even if that incurs in a less powerful type system