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
let jsarray xs = (Array.apply null xs) | |
let length xs = (jsarray xs).length | |
let empty xs = (length xs) == 0 | |
let concat xs ys = (jsarray xs).concat ys | |
let cons x xs = concat [x] xs | |
let head xs = xs@0 | |
let tail xs = (jsarray xs).slice 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
let ioMonad = { | |
return: \x -> (\() -> x) | |
bind: \action f -> (\() -> | |
let value = action () | |
let action2 = f value | |
action2 () | |
) | |
} | |
let putStrLn line = (\() -> console.log line) |
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
let ioMonad = { | |
return: \x -> (\() -> x) | |
bind: \action f -> (\() -> | |
let value = action () | |
let action2 = f value | |
action2 () | |
) | |
} | |
let putStrLn line () = console.log line |
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
let ioMonad = { | |
return: \x -> (\() -> x) | |
bind: \action f -> (\() -> | |
let value = action () | |
let action2 = f value | |
action2 () | |
) | |
} | |
let putStrLn line = (\() -> console.log line) |
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 Reactive.Banana | |
import Control.Concurrent | |
main = do | |
-- Create handles for pushing values into events | |
(addHandler1, push1) <- newAddHandler | |
(addHandler2, push2) <- newAddHandler | |
-- Create event network | |
network <- compile $ do | |
-- Actual events from AddHandlers |
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
package com.karma.cache | |
import collection.immutable.HashMap | |
trait Cache[K, V] { | |
def get(key : K, fetch : (K => V)) : V | |
} | |
class NoCache[K, V] extends Cache[K, V] { | |
def get(key : K, fetch : (K => V)) : V = fetch(key) |
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 Text.Regex.XMLSchema.String(match, sed) | |
clean :: String -> String | |
clean = sed (const "><") ">\\s*<" . trim | |
where trim = dropWhile whitespace . reverse . dropWhile whitespace . reverse | |
whitespace c = match "\\s" [c] |
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, DeriveDataTypeable, NoMonomorphismRestriction #-} | |
module AesonTest where | |
import qualified Data.Aeson.Generic as A | |
import qualified Data.ByteString.Lazy as L8 | |
import Data.Data | |
import Data.Typeable | |
import Codec.Binary.UTF8.String as U8 | |
import Data.Maybe |
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 android.accounts.Account; | |
import android.accounts.AccountManager; | |
import android.app.Activity; | |
import android.app.AlertDialog; | |
import android.app.Dialog; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.util.Log; |
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 Transactional(Transactional, Connection, transactionally, getConnection) where | |
data Connection = Connection | |
data Transactional a = Transactional (Connection -> IO a) | |
instance Monad Transactional where | |
(>>=) op toNext = Transactional $ \conn -> perform conn op >>= perform conn . toNext | |
return a = Transactional $ return . const a | |
getConnection :: Transactional Connection |