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 BangPatterns #-} | |
module Main where | |
-- This is constant space. Haste's Inlining (via GHC frontend) seems to | |
-- be able to combine even+odd to give us a single, tail-recursive loop. | |
even' :: Int -> Bool | |
even' 0 = True | |
even' !x = odd' (x - 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
;match.clj 1764 | |
(defn to-pattern-row | |
"Take an unprocessed pattern expression and an action expression and return | |
a pattern row of the processed pattern expression plus the action epxression." | |
[pat action] | |
(let [ps (map emit-pattern (map macroexpand (group-keywords pat)))] | |
(pattern-row ps action))) | |
(defmacro single-jeopardy [c-idx q-idx] |
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
mkdir ~/.haste | |
cp -r include ~/.haste/ | |
haste-pkg update libraries/rts.pkg | |
ghc-pkg describe Cabal | haste-pkg update - --force | |
# ... in 'libraries/ghc-prim' | |
haste-inst --unbooted configure | |
&& haste-inst build --unbooted --install-jsmods --ghc-options=-DHASTE_HOST_WORD_SIZE_IN_BITS=64 | |
&& haste-install-his ghc-prim-0.3.0.0 dist/build |
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
behave1 = ...//some FRP behaviour of Number | |
behave2 = ...//some FRP behaviour of Number | |
behave3 = ReaCtx.with(function(re) { | |
if (re.val(behave1) < 50) { | |
return re.val(behave2) + 1000; | |
} else { | |
return 3; | |
} | |
}); |
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
(ns parse2 | |
(:refer-clojure :exclude [char]) | |
(:require [clojure.core :as core] | |
[clojure.string :as str] | |
[clojure.java.io :as io] | |
[zetta.core :as z] | |
[zetta.parser.seq :as s] | |
[zetta.combinators :as c]) | |
(:use [zetta.core :only [<$> <* *> <|> do-parser]])) |
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
(ns blah | |
(:use [zetta.parser.seq :only (whitespace number char)] | |
[zetta.combinators :only (choice around)] | |
[zetta.core :only (*>, <*)]) | |
(:require [zetta.core :as z])) | |
(def whitespaces (many whitespace)) | |
(def id4 | |
(around |
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
;Hrm... I actually tried a similar approach before but: | |
(def identifier2 | |
(around | |
whitespaces | |
(choice | |
[(*> (string "#") | |
(<* number (string "#"))) | |
(*> (string "#") | |
(<* number (string "=")))]))) |
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
(def identifier | |
(around | |
whitespaces | |
(choice | |
[(<$> (partial apply vector) | |
(*> (string "#") | |
(<* number (string "#")))) | |
; ^ I think you should be using just number here right? | |
; you are trying to parse (many1 digit) | |
(<$> (partial apply vector) |
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
(def identifier | |
(around | |
whitespaces | |
(choice | |
[(<$> (partial apply vector) | |
(*> (string "#") | |
(<* (many1 number) (string "#")))) | |
(<$> (partial apply vector) | |
(*> (string "#") | |
(<* (many1 number) (string "="))))]))) |