This file contains 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
module RomanConvert exposing (..) | |
import Dict exposing (Dict, fromList) | |
import List.Extra exposing (find) | |
import Set exposing (..) | |
-- Elm implementation of converting to and from Integer and a string representation of a Roman Numeral | |
-- (C)2018 Justin Heyes-Jones | |
-- These are the valid characters that make up Roman Numerals |
This file contains 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
// Functor | |
trait JFunctor[F[_]] { | |
def map[A,B](fa: F[A])(f: A => B) : F[B] | |
} | |
trait JMapFunctor[K] extends JFunctor[({type LT[V] = Map[K, V]})#LT] { | |
def map[A, B](fa: Map[K,A])(f: A => B): Map[K,B] = { |
This file contains 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
# http://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html | |
# Colours | |
print "\u001b[30m A \u001b[31m B \u001b[32m C \u001b[33m D \u001b[0m\n" | |
print "\u001b[34m E \u001b[35m F \u001b[36m G \u001b[37m H \u001b[0m\n" | |
print "\n" | |
# Bright colours |
This file contains 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
import Data.List | |
-- Graham Scan | |
-- Direction data type | |
data Direction = Left | |
| Right | |
| Straight | |
deriving (Eq, Show) |
This file contains 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
import java.util.concurrent.TimeoutException | |
import java.util.{Timer, TimerTask} | |
import scala.concurrent.duration._ | |
import scala.concurrent.{Await, ExecutionContext, Future, Promise} | |
import scala.language.postfixOps | |
import scala.util.{Failure, Success, Try} | |
object FutureUtil { |
This file contains 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
package examples | |
import scalaz._, Scalaz._ | |
object ContravariantMap { | |
// Example of contravariant using Scalaz | |
trait Printable[A] { | |
def format(value: A): String | |
} |
This file contains 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
/* | |
val CatsMTLVersion = "0.4.0" | |
val CatsVersion = "1.4.0" | |
val CatsEffectVersion = "1.0.0" | |
libraryDependencies ++= Seq( | |
"org.typelevel" %% "cats-core" % CatsVersion, | |
"org.typelevel" %% "cats-effect" % CatsEffectVersion, | |
"org.typelevel" %% "cats-mtl-core" % CatsMTLVersion, | |
*/ |
This file contains 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
// Tuples, integers and maps all have monoid | |
// instances we can easily combine them | |
@ val data = "Hello Hello This is some data data data yo" | |
data: String = "Hello Hello This is some data data data yo" | |
@ def step(word: String) = (1, word.length, Map(word -> 1)) | |
defined function step | |
@ def run(data: String) = data.split(" ").toList.map(step).combineAll |
This file contains 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
// Comonad is the dual of Monad | |
// example for non empty list, extract is the head of the list | |
// coflatMap gives you successive lists from the whole list, the tail, the tail of that | |
// and you must return a single value for each list... | |
@ Comonad[NonEmptyList].extract(NonEmptyList.of(1,2,3)) | |
res26: Int = 1 | |
@ Comonad[NonEmptyList].extract(NonEmptyList.of(1)) | |
res27: Int = 1 |
This file contains 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
import zio._ | |
import zio.console._ | |
import zio.{Queue, UIO} | |
import akka.actor._ | |
import com.typesafe.config.ConfigFactory | |
import java.util.concurrent.Executors | |
import scala.concurrent.{ExecutionContext} | |
import scala.concurrent.duration.FiniteDuration | |
import java.util.concurrent.{Executors, TimeUnit} | |
import java.util.concurrent.{ExecutorService, Executors, ThreadFactory} |