Skip to content

Instantly share code, notes, and snippets.

@scalolli
Created May 31, 2018 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scalolli/ffec4c40999f963f198ea81099001aa4 to your computer and use it in GitHub Desktop.
Save scalolli/ffec4c40999f963f198ea81099001aa4 to your computer and use it in GitHub Desktop.
Either traverse cats
import cats.implicits._
def parseInt(s: String): Either[NumberFormatException, Int] = Either.catchOnly[NumberFormatException](s.toInt)
List("1", "2", "3").traverse(parseInt)
@scalolli
Copy link
Author

This fails with compilation errors:

<console>:16: error: no type parameters for method traverse: (f: String => G[B])(implicit evidence$1: cats.Applicative[G])G[List[B]] exist so that it can be applied to arguments (String => Either[NumberFormatException,Int])
 --- because ---
argument expression's type is not compatible with formal parameter type;
 found   : String => Either[NumberFormatException,Int]
 required: String => ?G[?B]

@scalolli
Copy link
Author

Just put -Ypartial-unification in scalacOptions dumb ass !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment