c 🐤
clojure 🍭
coffee ☕
cpp 🐔
css 🎨
eruby 💍
gitcommit 🔜
haml 🔨
help 👼
html 🌿
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
let g:Maybe = {"v": []} | |
function! g:MaybeReturn(v) | |
let maybe = deepcopy(g:Maybe) | |
let maybe.v = [a:v] | |
return maybe | |
endfunction | |
function! Just(x) | |
return MaybeReturn(a: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
function! expect.__custom_matcher__() | |
let custom_matcher = themis#suite('custom matcher') | |
function! custom_matcher.before() | |
call themis#helper#expect#define_matcher('to_be_one_bigger_than', 'a:1 ==# a:2 + 1', | |
\ '(a:not ? "Not e" : "E") . "xpect " . string(a:1) . " to equal " . string(a:2) . "+1"') | |
endfunction | |
function! custom_matcher.can_be_defined() | |
call s:expect(2).to_be_one_bigger_than(1) | |
endfunction | |
function! custom_matcher.provides_failre_message_definition() |
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
set noswapfile nobackup | |
filetype plugin indent on | |
set columns=400 | |
let s:option = themis#option() | |
let s:option.exclude = ["repos"] | |
let s:option.recursive = 1 | |
let s:option.reporter = "dot" | |
unlet s:option |
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
if !exists('g:added_here') | |
let &rtp .= ',' . expand('<sfile>:p:h') | |
let g:added_here = 1 | |
endif | |
let g:Closure = vital#of('cont').import('Data.Closure') | |
function! Fact(n, cont) | |
let cont = a:cont | |
if a:n <= 0 |
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
" similar to Ruby's detect or Haskell's find. | |
function! s:find_index(xs, expr) | |
for i in range(0, len(a:xs) - 1) | |
if eval(substitute(a:expr, 'v:val', string(a:xs[i]), 'g')) | |
return i | |
endif | |
endfor | |
return -1 | |
endfunction |
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
new | |
for i in range(1, 3) | |
if i%2 == 0 | |
insert | |
hoge | |
. | |
else | |
insert | |
oo | |
. |
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
let s:suite = themis#suite('agit#string#truncate') | |
let s:assert = themis#helper('assert') | |
function! s:suite.testtest() | |
call s:assert.equals(1 + 1, 2) | |
end |
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 MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-} | |
import Control.Monad | |
import Control.Monad.Trans | |
import Control.Monad.State | |
newtype MaybeT m a = MaybeT {runMaybeT :: m (Maybe a)} | |
instance (Monad m) => Monad (MaybeT m) where | |
return a = MaybeT $ return (Just a) | |
x >>= f = MaybeT $ runMaybeT x >>= maybe (return Nothing) (runMaybeT . f) |
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 FlexibleInstances, FunctionalDependencies #-} | |
newtype MyState s a = MyState {runMyState :: s -> (a, s)} | |
instance Monad (MyState a) where | |
return a = MyState $ \s -> (a, s) | |
(MyState mys) >>= f = MyState $ \s -> let (a, s') = mys s in runMyState (f a) s' | |
class (Monad m) => MonadMyState s m | m -> s where | |
put :: s -> m () | |
get :: m s |