GithubHelp home page GithubHelp logo

scalatypeclasses's Introduction

scalatypeclasses

Scala type classes workshop

License

See the LICENSE file.

Exercise 1: Comparable

  1. Define the ComparatorInt instance.
  2. Define the min method, which should calculate the smallest collection element.
  3. Define the max method, which should calculate the greatest collection element.
  4. Define the ComparatorString instance.
  5. Define the ComparatorAbsInt instance (which compares absolute values).
  6. Define the ComparatorStringIgnoreCase instance (which ignores the distinction between uppercase and lowercase characters).
  7. Add the + method to the Tree class.
  8. Add the contains method to the Tree class.

Exercise 2: Monoid

  1. Define the MonoidString instance.
  2. Define the msum method, which has the following signature: def msum[T](list: T*)(implicit m: Monoid[T]): T
  3. Define the MonoidSum instance.
  4. Define the MonoidProduct instance.
  5. Define the MonoidAnything instancee.
  6. Define the MonoidAll instance.
  7. Define the MonoidList instance.
  8. Define the MonoidTuple2 instance.
  9. Define the MonoidMap instance.

Exercise 3: Functor

  1. Define the FunctorOption instance.
  2. Define the FunctorList instance.
  3. Define the FunctorTree instance.

Exercise 4: Foldable

  1. Define the FoldableList instance.
  2. Define the FoldableTree instance.
  3. Define the fold method, which has the following signature: def fold[A:Monoid,F[A]:Foldable](f: F[A]): A
  4. Define the toList method converting a foldable into a list.
  5. Define the size method calculating the foldable size.

Exercise 5: Applic

  1. Define the ApplicId instance.
  2. Define the ApplicOption instance.
  3. Implement the map method.
  4. Define the lift2 method, which has the following signature: def lift2[F[_],A,B,C](a: F[A], b: F[B])(g: (A,B) => C)(implicit applic: Applic[F]): F[C]
  5. Define the lift3 method, which has the following signature: def lift3[F[_],A,B,C,D](a: F[A], b: F[B], c: F[C])(g: (A,B,C) => D)(implicit applic: Applic[F]): F[D]
  6. Define the ApplicList instance.
  7. Define the ApplicZipList instance.

Exercise 6: Monad

  1. Define the MonadOption instance.
  2. Implement the map method.
  3. Implement the ap method.
  4. Define the foldM method, which has the following signature: def foldM[M[_],A,B](list: List[A])(v: B)(g: (B,A) => M[B])(implicit m: Monad[M]): M[B]
  5. Define the MonadList instance.
  6. Define the join method, which has the following signature: def join[M[_],A,B](mm: M[M[A]])(implicit m: Monad[M]): M[A]

Exercise 7: Travers

  1. Define the TraversId instance.
  2. Implement the map method.
  3. Define the TraversOption instance.
  4. Define the sequence method, which has the following signature: def sequence[T[_]:Travers,F[_]:Applic,A](t: T[F[A]]): F[T[A]]
  5. Define the TraversList instance.
  6. Implement the foldMap method.

scalatypeclasses's People

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.