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
case class Config(host: String, port: Int) { | |
def prettyPrint(prefix: String, msg: String): String = | |
List(prefix, ": ", msg, " on ", host, ":", port.toString).mkString | |
} | |
/** | |
* Passing a configuration with implicits is like | |
* working in the state monad. You can "put" a | |
* new configuration even though we don't want that | |
* to happen in this particular example. We don't |
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
module JSON | |
import Data.SortedMap | |
data JSONType: Type where | |
JSONArray : Vect JSONType n -> JSONType | |
JSONString : JSONType | |
JSONNumber : JSONType | |
JSONBool : JSONType | |
JSONObject : SortedMap String JSONType -> JSONType |
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
module Main where | |
import Control.Monad | |
import Data.List | |
import System.Random | |
import Data.Map (Map) | |
import Data.Bool | |
import Text.Read | |
import Data.Maybe | |
import qualified Data.Map as Map |
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
import Control.Applicative | |
import Control.Monad.Fix | |
data CounterRep = CounterRep { x :: Int } | |
data Counter = Counter { get :: Int, | |
set :: Int -> Counter, | |
inc :: Counter } | |
counterClass = \rep -> |
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
module Main | |
{- | |
Strictness always bothers me a little, since it forces you to do | |
things like fusion manually. This prohibits code reuse. I won't | |
elaborate on this too much since there is already a great blog | |
post about this: | |
http://augustss.blogspot.co.uk/2011/05/more-points-for-lazy-evaluation-in.html |
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
module Main | |
%lib Node "readline" | |
data ReadLine = MkReadLine Ptr | |
readlineClose : ReadLine -> IO () | |
readlineClose (MkReadLine rl) = | |
mkForeign (FFun "%0.close()" [FPtr] FUnit) rl |
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
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Prelude hiding (length, filter) | |
import Data.Text | |
-- Turn on optimizations (-O) to make this `False` | |
wat :: Text -> Bool | |
wat x = length (filter (== ',') x) == 1 |
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
module Main where | |
import Control.Monad | |
import Control.Concurrent | |
import Text.Printf | |
import Foreign.C.Types | |
foreign import ccall safe "getchar" c_getchar :: IO CChar |
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
{-# OPTIONS_GHC -Wall -fno-warn-incomplete-patterns #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE NPlusKPatterns #-} | |
module Main where |
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
function f (x) | |
print("f: " .. x) | |
return g (x + 1) | |
end | |
function g (x) | |
print("g: " .. x) | |
return f (x + 1) | |
end |
NewerOlder