Skip to content

Instantly share code, notes, and snippets.

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)
@cohama
cohama / emoji.md
Last active August 29, 2015 14:06

c 🐤
clojure 🍭
coffee ☕
cpp 🐔
css 🎨
eruby 💍
gitcommit 🔜
haml 🔨
help 👼
html 🌿

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()
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
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
" 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
new
for i in range(1, 3)
if i%2 == 0
insert
hoge
.
else
insert
oo
.
@cohama
cohama / test_test.vim
Created July 1, 2014 13:54
FATAL ERROR になるテストコード (endfunction ではなく end になっている)
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
{-# 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)
{-# 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