Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / foo.rs
Created January 24, 2015 03:53
use std::fmt;
use std::error::Error;
struct Foo;
impl Error for Foo {
fn description(&self) -> &str { "foo" }
}
impl fmt::Display for Foo {
@hesselink
hesselink / gist:3757658
Created September 20, 2012 18:53
Indexed functor and monad classes for common monad transformers
{-# LANGUAGE Rank2Types #-}
import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Reader
import Control.Monad.Trans.State
import Control.Monad.Trans.Writer
import Data.Monoid
@shtaag
shtaag / gist:3160513
Created July 22, 2012 17:58
Start_Haskell_2 exercise in chap.5
問題13
リストのリストを取って、要素のリストを連結する関数concat :: [[a]] -> [a]は 第6章の演習問題で定義した。これをfoldrを使って実装した関数concatRを 定義せよ。さらに、foldlを使って実装した関数concatLを定義せよ。
以下の実行例で自分の定義が正しいことを確認せよ。
> concatR [[1,2],[3],[],[4,5]]
[1,2,3,4,5]
> concatL [[1,2],[3],[],[4,5]]
[1,2,3,4,5]
> concatR []
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@VoQn
VoQn / Sethp.hs
Created December 13, 2011 03:32
Sample cabal configuration for HPC Test Coverage
import Distribution.Simple
main = defaultMain
@nathanmarz
nathanmarz / gist:1165885
Created August 23, 2011 17:11
Benchmark between HashMap with lock vs. persistent map with atom
(defn map-incr-unsafe []
(let [m (java.util.HashMap.)]
(.put m "a" 0)
(doseq [i (range 1000000)]
(let [a (.get m "a")]
(.put m "a" (inc a))
))))
(defn map-incr-safe []
(let [o (Object.)
;; pepijndevos's solution to Least Common Multiple
;; https://4clojure.com/problem/100
#(reduce(fn[n r](* r(numerator(/ n r))))%&)
;; answer to what I understood of http://d.hatena.ne.jp/fatrow/20100407/1270662784
;; your original code
(en/defsnippet lib-model "src/html/a.html" [:.library]
[{:keys [name description url category]}]
[:.name] (en/content name)
[:.descriptionj] (en/content description)
[:.site :a] (en/do-> (en/set-attr :href url)
(en/content url))