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 GADTs, StandaloneDeriving, RankNTypes #-} | |
type Var = String | |
data RecT a | |
data SendT a | |
data RepT a | |
data ParT a b | |
data NilT | |
data NuT a |
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
Elm.Native.EltMouse = function(elm){ | |
'use strict'; | |
elm.Native = elm.Native || {}; | |
if (elm.Native.EltMouse) return elm.Native.EltMouse; | |
var Utils = Elm.Native.Utils(elm); | |
function EltClicks(input) { | |
this.id = Utils.guid(); |
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 Main | |
apply2 : (a -> b -> c) -> a -> b -> IO c | |
apply2 {a} {b} {c} f x y = | |
let funTy = FFunction (FAny a) (FFunction (FAny b) (FAny c)) -- What is the right FTy here? | |
in mkForeign (FFun "apply2" [funTy, FAny a, FAny b] (FAny c)) f x y | |
-- This works | |
apply1 : (a -> b) -> a -> IO b | |
apply1 {a} {b} f x = |
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
abstract | |
data Js : Type -> Type -- In the style of js_of_ocaml | |
wrap : (a -> b) -> Js (a -> b) | |
wrap {a} {b} f = unsafePerformIO ( | |
mkForeign (FFun "wrapIdrisUncurried" [FAny (a -> b)] (FAny (Js (a -> b)))) f) | |
-- You can use it like so: | |
apply2 : Js (a -> b -> c) -> a -> b -> IO c | |
apply2 {a} {b} {c} f x y = |
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 State ( State | |
, return | |
, join | |
, map | |
, bind | |
, (>!=) | |
, run | |
, eval | |
, exec | |
, get |
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
let check_merkle_lookup | |
: type a. | |
depth:int | |
-> root:Hash.Var.t | |
-> entry:Hash.Var.t | |
-> Bool_var.t list | |
-> ((hash, a) Merkle_tree.t, unit) T.t | |
= | |
fun ~depth ~root ~entry addr -> | |
let initial_path = |
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
ps = [] : map parts [1..] | |
where parts n = [n] : [x : p | x <- [1..n], p <- ps !! (n - x), x <= head p] |
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 LambdaCase, DeriveGeneric, NamedFieldPuns, RecordWildCards, OverloadedStrings #-} | |
module Main where | |
import Pipes | |
import qualified Pipes.Prelude as P | |
import Pipes.Network.TCP | |
import qualified Data.ByteString as B | |
import qualified Data.HashTable.IO as H | |
import System.IO.Unsafe | |
import Data.Serialize |
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 LambdaCase #-} | |
import Control.Applicative | |
import Control.Monad.State | |
import System.Random | |
data Tree a = Empty | Bin a (Tree a) (Tree a) | |
deriving Show | |
-- O(n) |
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 GADTs #-} | |
import Data.Char (digitToInt) | |
data Nil | |
data Cons a b | |
data Pipeline ts a c where | |
(:>) :: (a -> b) -> Pipeline ts b c -> Pipeline (Cons (a -> b) ts) a c | |
Id :: Pipeline Nil t t |