Code Monkey home page Code Monkey logo

learn-fp's Introduction

Learn Functional Programming course/tutorial on Scala Build Status Build Status

Intro

This course/tutorial was created with purpose to better understand functional programming idioms using Scala language. It covers type classes, monoids, functors, applicatives, monads, traversable/foldable, monad transformers, 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.

Example session

Example session

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 necessary.

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.

Type classes

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/PairAdditiveMonoid.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

Foldable

  • Implement foldable in learnfp/foldable/Foldable.scala

Applicatives

Traversable

  • Implement learnfp/traversable/Traversable.scala

Nested

  • Implement learnfp/nested/Nested.scala

IO

  • Implement learnfp/io/IO.scala

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

Contravariant functor

  • Observe general contravariant functor pattern in learnfp/contravariant/ContravariantFunctor.scala
  • Implement learnfp/contravariant/Show.scala
  • Implement learnfp/contravariant/Predicate.scala

CoMonads

  • Observe general comonad pattern in learnfp/comonad/CoMonad.scala
  • Implement learnfp/comonad/Id.scala
  • Implement learnfp/comonad/Env.scala

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 was left out

  • Reader/ReaderT
  • 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

learn-fp's People

Contributors

crystaltreeconcept avatar dehun avatar hextriclosan avatar hmemcpy avatar izhangzhihao avatar mszczygiel avatar nandotorterolo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.