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
(go (let [a (<! (async/map identity []))] | |
(println a))) | |
blocks instead of printing nil ? |
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
;; project.clj | |
(defproject bleh "0.0.1-SNAPSHOT" | |
:decription "bleh" | |
:dependencies [[org.clojure/clojure "1.5.1"] | |
[org.clojure/clojurescript "0.0-2024"] | |
[org.clojure/core.async "0.1.256.0-1bf8cf-alpha"]] | |
:plugins [[lein-cljsbuild "0.3.3"]] | |
:cljsbuild {:builds [{:source-paths ["src-cljs"] | |
:compiler {:output-to "main.js" | |
:optimizations :whitespace |
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
app.core> (let [maybe (fn [val fun] (if (nil? val) nil (fun val)))] | |
[(-> nil (maybe inc)) (-> 1 (maybe inc))]) | |
[nil 2] |
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 Rank2Types #-} | |
module Main where | |
import System.Random | |
import Control.Monad | |
import Control.Monad.State | |
import Data.List | |
data Player = Player { pHealth :: Int | |
, pAgility :: Int | |
, pStrength :: Int |
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 cara.type.core) | |
;(declare Nothing Just) | |
(defprotocol PDataType | |
(get-constructors [self])) | |
(defprotocol PConstructor | |
(get-datatype [self])) |
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
insertPerson :: MonadState MyDb m => Person -> m (Fact Person) | |
insertPerson = insertRecord personRel | |
--fillit :: MonadState MyDb m => m () | |
fillit = do | |
a <- insertPerson (Person "john") | |
b <- insertPerson (Person "paul") | |
return () | |
-- if i leave the type declaraion of fillit commented, i get this error : |
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
user> (defmacro bleh [body] | |
`(fn [{:keys [~'action]}] | |
~body)) | |
#'user/bleh | |
user> ((bleh action) {:action 12}) | |
12 |
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
user> (defmacro as-doubled-pair [v] | |
`(let [v# (mapv (partial * 2) ~v)] | |
[v# v#])) | |
#'user/as-doubled-pair | |
user> (macroexpand (as-doubled-pair [1 2 3])) | |
[[2 4 6] [2 4 6]] | |
user> (defmacro as-doubled-pair2 [v] | |
(let [v (mapv (partial * 2) v)] | |
`(do [~v ~v]))) |
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
user> (defmacro as-doubled-pair [v] | |
`(let [v# (mapv (partial * 2) ~v)] | |
[v# v#])) | |
#'user/as-doubled-pair | |
user> (macroexpand (as-doubled-pair [1 2 3])) | |
[[2 4 6] [2 4 6]] | |
user> (defmacro as-doubled-pair2 [v] | |
(let [v (mapv (partial * 2) v)] | |
`(do [~v ~v]))) |
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
;; the bug | |
(defn fetch-val | |
"Return a state-monad function that assumes the state to be a map and | |
returns the value corresponding to the given key. The state is not modified." | |
[key] | |
(domonad state-m | |
[s (fetch-state)] | |
(key s))) ;; only works for keyword keys |
NewerOlder