Created
May 3, 2017 08:20
-
-
Save alexarchambault/11f9d28b293b1085db303dc0e377dd76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Requires jupyter-scala with TLS enabled (see the [jupyter-scala launch script](https://github.com/alexarchambault/jupyter-scala/blob/master/jupyter-scala)), or using scala 2.11.11" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"kernel.compiler.settings.YpartialUnification.value = true" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n", | |
"\n", | |
"\u001b[39m\n", | |
"\u001b[32mimport \u001b[39m\u001b[36mcats._\n", | |
"\u001b[39m\n", | |
"\u001b[32mimport \u001b[39m\u001b[36mcats.syntax.either._\n", | |
"\u001b[39m\n", | |
"\u001b[32mimport \u001b[39m\u001b[36mcats.syntax.functor._\n", | |
"\u001b[39m\n", | |
"\u001b[32mimport \u001b[39m\u001b[36mcats.instances.list._\n", | |
"\u001b[39m\n", | |
"\u001b[32mimport \u001b[39m\u001b[36mcats.instances.either._\n", | |
"\n", | |
"\u001b[39m\n", | |
"defined \u001b[32mfunction\u001b[39m \u001b[36maddOne\u001b[39m" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import $ivy.`org.typelevel::cats:0.9.0`\n", | |
"\n", | |
"import cats._\n", | |
"import cats.syntax.either._\n", | |
"import cats.syntax.functor._\n", | |
"import cats.instances.list._\n", | |
"import cats.instances.either._\n", | |
"\n", | |
"def addOne[F[_] : Functor](f: F[Int]) = f.map(_ + 1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\u001b[36mres2\u001b[39m: \u001b[32mEither\u001b[39m[\u001b[32mString\u001b[39m, \u001b[32mInt\u001b[39m] = \u001b[33mRight\u001b[39m(\u001b[32m11\u001b[39m)" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"addOne(10.asRight[String])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "TLS", | |
"language": "scala", | |
"name": "typelevel-scala" | |
}, | |
"language_info": { | |
"codemirror_mode": "text/x-scala", | |
"file_extension": ".scala", | |
"mimetype": "text/x-scala", | |
"name": "scala211", | |
"nbconvert_exporter": "script", | |
"pygments_lexer": "scala", | |
"version": "2.11.8" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment