Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

learn-by-doing course/tutorial for functional programming on scala

License

NotificationsYou must be signed in to change notification settings

dehun/learn-fp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 usingsbt 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 inlearnfp/monoid/Monoid.scala
  • Implementlearn-fp/src/main/scala/learnfp/monoid/ListMonoid.scala
  • Implementlearn-fp/src/main/scala/learnfp/monoid/SimpleMonoid.scala
  • Implementlearnfp/monoid/PairAdditiveMonoid.scala
  • Extra material:
    • Bartosz Milewski: Category Theory 3.1: Examples of categories, orders, monoids

Functors

Monads

  • Observe general monad pattern inlearnfp/monad/Monad.scala
  • Implementlearnfp/monad/Id.scala
  • Implementlearnfp/monad/Maybe.scala
  • Implementlearnfp/monad/List.scala
  • Implementlearnfp/monad/Disjunction.scala
  • Implementlearnfp/monad/Writer.scala
  • Implementlearnfp/monad/State.scala
  • Extra material

Foldable

  • Implement foldable inlearnfp/foldable/Foldable.scala

Applicatives

Traversable

  • Implementlearnfp/traversable/Traversable.scala

Nested

  • Implementlearnfp/nested/Nested.scala

IO

  • Implementlearnfp/io/IO.scala

Monad Transformers

  • Observe general monad transformer typeclass inlearnfp/transformer/MonadTransformer.scala
  • Implementlearnfp/transformer/IdT.scala
  • Implementlearnfp/transformer/MaybeT.scala
  • Implementlearnfp/transformer/WriterT.scala
  • Implementlearnfp/transformer/StateT.scala
  • Extra material:

Free monad

Contravariant functor

  • Observe general contravariant functor pattern inlearnfp/contravariant/ContravariantFunctor.scala
  • Implementlearnfp/contravariant/Show.scala
  • Implementlearnfp/contravariant/Predicate.scala

CoMonads

  • Observe general comonad pattern inlearnfp/comonad/CoMonad.scala
  • Implementlearnfp/comonad/Id.scala
  • Implementlearnfp/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 tohttps://github.com/dehun/learn-fp/issues or e-mail me onyuriy.netesov@gmail.com
You also are very welcome to create PR.

Credits

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

[8]ページ先頭

©2009-2025 Movatter.jp