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
{-# LANGUAGE DeriveFunctor #-} | |
module Main where | |
import Control.Monad.Free | |
data DockerAction a = Add String a | |
| EntryPoint String a | |
| Run String a | |
deriving (Functor) |
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
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
module Main where | |
import Data.Aeson |
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 com.twitter.util._ | |
// import scala.concurrent.Future | |
// import scala.concurrent.ExecutionContext.Implicits.global | |
// Prints 'future' once. | |
Future{println("future")} | |
// Lets give that action a name | |
lazy val printLoop = Future{println("future")} | |
// Now lets evaluate it. |
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
$ cabal install cabal-helper-0.3.6.0 | |
Resolving dependencies... | |
Notice: installing into a sandbox located at | |
/private/tmp/ghc-mod/.cabal-sandbox | |
Configuring lifted-base-0.2.3.6... | |
Building lifted-base-0.2.3.6... | |
Installed lifted-base-0.2.3.6 | |
Configuring io-choice-0.0.5... | |
Building io-choice-0.0.5... | |
Installed io-choice-0.0.5 |
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
{-# LANGUAGE RecursiveDo #-} | |
import Control.Monad.Tardis | |
import qualified Data.Map as M | |
-- Language that lets you dereference variable names and assign to names, | |
-- but assignment must happen *after* dereference! | |
data ReverseLang = Assign String Int -- Assign to a name. | |
| Var String -- Dereference a name. |
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
{-# LANGUAGE DeriveFunctor #-} | |
import Control.Concurrent.Timer | |
import Control.Concurrent.Suspend.Lifted | |
import Control.Monad.Free | |
import GHC.Int (Int64) | |
import Control.Monad.Writer.Lazy | |
-- Timer type to be lifted into Free. | |
data TimerM r = TimerM Int64 (IO ()) r deriving (Functor) |
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
scala> def fix[A](f: (=> A) => A): A = f(fix(f)) | |
fix: [A](f: (=> A) => A)A | |
scala> def fact(f: => (Int => Int))(n: Int): Int = if (n>0) n * f(n-1) else 1 | |
fact: (f: => Int => Int)(n: Int)Int | |
scala> fix(fact)(10) | |
res19: Int = 3628800 |
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.SBV | |
sched :: SInteger -> SInteger -> SInteger -> SInteger -> SInteger -> SInteger -> SBool | |
sched t_11 t_12 t_21 t_22 t_31 t_32 = (t_11 .>= 0) &&& (t_12 .>= t_11 + 2) &&& (t_12 + 1 .<= 8) &&& | |
(t_21 .>= 0) &&& (t_22 .>= t_21 + 3) &&& (t_22 + 1 .<= 8) &&& | |
(t_31 .>= 0) &&& (t_32 .>= t_31 + 2) &&& (t_32 + 3 .<= 8) &&& | |
((t_11 .>= t_21 + 3) ||| (t_21 .>= t_11 + 2)) &&& | |
((t_11 .>= t_31 + 2) ||| (t_31 .>= t_11 + 2)) &&& | |
((t_21 .>= t_31 + 2) ||| (t_31 .>= t_21 + 3)) &&& | |
((t_12 .>= t_22 + 1) ||| (t_22 .>= t_12 + 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
object Main { | |
// NonEmpty because the constructor forces you to provide at least one | |
// instance of A. | |
case class NonEmptyList[A](a: A, as: List[A]) { | |
def map[B](f: A => B): NonEmptyList[B] = { | |
NonEmptyList[B](f(a), as.map(f)) | |
} | |
def flatMap[B](f: A => NonEmptyList[B]): NonEmptyList[B] = flatten(map(f)) | |
} |
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
{-# LANGUAGE DeriveDataTypeable #-} | |
import Data.SBV | |
import Control.Monad.IO.Class | |
import Data.Foldable | |
import Data.Generics | |
------------------------------------------------------------------------------- | |
-- Rot13 over an array of 8 bit words. | |
-- |