Skip to content

hextriclosan/learn-fp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learn FP

Intro

This course was created with purpose to better understand functional programming idioms using Scala language. It covers typeclasses, monoids, functors, applicatives, monads, free monad.
Material is structured as set of stub/unimplemented functions/classes and tests for them. Your objective is to make all unit tests green. It is learn-by-doing course.

Inspiration

NICTA course was a great and interesting challenge for me to do in Haskell. I think Scala community will benefit from the similar course.

Target audience

The material in here is quite poor on theoretical/explanation part. I have tried to link material from other authors that I have found to be good into this course Readme to compensate for this. Some prior experience with functional idioms is recommended, but not neccessary.

How to start

Just git clone this repository and follow steps in progression section. You can use any ide and verify your results using sbt test. For me intellij works best - you can easily run individual tests out of it. In case if you got stuck - check answers branch.

Progression

It is important to keep the progression - a lot of things depend on each other. Implementing something = making all tests green for that thing.

Typeclasses

Monoids

  • Observe general monoid pattern in learnfp/monoid/Monoid.scala
  • Implement learn-fp/src/main/scala/learnfp/monoid/ListMonoid.scala
  • Implement learn-fp/src/main/scala/learnfp/monoid/SimpleMonoid.scala
  • Implement learnfp/monoid/PairMonoid.scala
  • Extra material:
    • Bartosz Milewski: Category Theory 3.1: Examples of categories, orders, monoids

Functors

Monads

  • Observe general monad pattern in learnfp/monad/Monad.scala
  • Implement learnfp/monad/Id.scala
  • Implement learnfp/monad/Maybe.scala
  • Implement learnfp/monad/List.scala
  • Implement learnfp/monad/Disjunction.scala
  • Implement learnfp/monad/Writer.scala
  • Implement learnfp/monad/State.scala
  • Extra material

Applicatives

Monad Transformers

  • Observe general monad transformer typeclass in learnfp/transformer/MonadTransformer.scala
  • Implement learnfp/transformer/IdT.scala
  • Implement learnfp/transformer/MaybeT.scala
  • Implement learnfp/transformer/WriterT.scala
  • Implement learnfp/transformer/StateT.scala
  • Extra material:

Free monad

Bonus

  • Implement Reader functor, monad, applicative and write unit tests for that
  • Implement ReaderT and write unit tests for that
  • Implement applicative for monad transformers
  • Implement applicative for Free

What wes left out

  • Reader/ReaderT
  • Cofunctors
  • Comonads
  • Eff

Bugs/Issues

In case if find a bug/issue - please report it to https://github.com/dehun/learn-fp/issues or e-mail me on [email protected] You also are very welcome to create PR.

Credits

  • Yuriy Netesov - initial implementation
  • Extra material references are owned by other authors

About

learn-by-doing course for functional programming on scala

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 100.0%