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
import Keyboard | |
import List | |
import Window | |
import Color | |
import Random | |
input = dropRepeats Keyboard.space | |
ticks = fps 30 |
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
module Main where | |
import Pipes | |
import qualified Pipes.Prelude as P | |
import Pipes.Network.TCP | |
import qualified Data.ByteString as B | |
main :: IO () | |
main = | |
-- "serve" is from Network.Simple.TCP |
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
(* These types are just used as indices for nlist. *) | |
type z = Z_ | |
type 'a suc = S_ | |
(* A term of type (n, m, k) add is a proof that n + m = k *) | |
type (_, _, _) add = | |
| AddZ : (z, 'n, 'n) add | |
| AddS : ('n, 'm, 'k) add -> ('n suc, 'm, 'k suc) add | |
(* An (n, 'a) nlist is a list of 'a of length 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
import qualified Data.Map as M | |
import Data.List (nub, sort) | |
import qualified Data.Set as S | |
import Control.Applicative | |
-- problem 19 code | |
counts :: Ord a => [a] -> M.Map a Int | |
counts = foldl incr M.empty | |
where incr m x = M.insertWith (+) x 1 m |
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 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
{-# 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
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(); |