This assumes familiarity with kinds and GADTs. Here's the extensions you're gonna need:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE ExplicitForAll #-}
This assumes familiarity with kinds and GADTs. Here's the extensions you're gonna need:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
module Playground4 where | |
import Data.Kind (Constraint) | |
import qualified Data.List as List | |
class GFunctor (c :: * -> Constraint) (f :: * -> *) | f -> c where |
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE TypeInType #-} | |
module LevNum where | |
import GHC.Prim | |
import GHC.Exts (TYPE) | |
class LevNum (a :: TYPE r) where | |
levAdd :: a -> a -> a |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE ExplicitForAll #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
module Playground where |
import scala.io.StdIn._ | |
object CustomIO extends App { | |
/** | |
* Slides: https://docs.google.com/presentation/d/15O8fzIEa85a8S_vk6N3b_S8F4IYbrFkLOXmtwbcy0cQ | |
*/ | |
case class IO[A](unsafeRun: () => A) { | |
def map[B](f: A => B): IO[B] = |
import io.circe.syntax._ | |
// hypothesis: ∀ x∈X, x.asJson.as[X] == Right(x) | |
// counterexample, nested options: | |
type X = Option[Option[Int]] | |
val x: X = Some(None) | |
x.asJson.as[X] == Right(x) |
// Exercises: https://gist.github.com/hugoferreira/21f1f0ec23186adb5e6832e6aee618d6 | |
const eq = require('lodash').isEqual | |
const fold = (as, base) => (f) => { | |
let result = base | |
for (let i = 0; i < as.length; i++) | |
result = f(result, as[i]) | |
return result | |
} |
import monix.execution.Scheduler.Implicits.global | |
import monix.eval._ | |
import io.circe._ | |
import io.circe.generic.semiauto._ | |
import de.heikoseeberger.akkahttpcirce.ErrorAccumulatingCirceSupport._ | |
/** | |
POST localhost:9999/mock | |
{ |
/* | |
* useful links | |
* | |
* https://github.com/rickynils/scalacheck/blob/master/doc/UserGuide.md | |
* http://www.scalatest.org/user_guide/generator_driven_property_checks | |
* | |
*/ | |
import org.scalacheck._ | |
import org.scalacheck.Arbitrary._ |