Skip to content

Instantly share code, notes, and snippets.

module Free where
import Control.Applicative (Applicative(..))
data Free f a = Pure a | Free (f (Free f a))
instance Functor f => Functor (Free f) where
fmap f (Pure a) = Pure (f a)
fmap f (Free fa) = Free (fmap (fmap f) fa)
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
module Objective where
import Data.Functor.Identity (Identity(Identity))
-- |
-- prop> runObject obj (fmap f m) = fmap (f *** id) (runObject obj m)
--
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableInstances #-}
module Fix where
-- Definitions:
--
-- If (μF,inF) is the initial F-algebra for some endofunctor F
import Data.Char (chr)
import Numeric (showIntAtBase)
repr :: Int -> Chr
repr n
| n < 10 = chr (48 + n)
| n < 36 = chr (65 + n - 10)
| n < 62 = chr (97 + n - 36)
numbase62 :: (Integral a, Show a) => a -> String
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
lga = log --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --abbrev-commit --date=local
#del = !"git status | grep -o 'deleted:.*' | sed 's/deleted:[\\t ]\\{1,\\}//g' | while read f; do git rm $f; done;"
del = !"git rm `git ls-files --deleted`"
sta = status
alias = !"if test -z $1; then loop=; for k in `git config --get-regexp ^alias\\. | sort | sed -e 's/^alias\\.\\(\\S*\\).*/\\1/g'`; do echo -n $k; loop="${loop}1"; if test ${#loop} -lt 5; then echo -n '\t'; else echo; loop=; fi; done; exit; fi; git config --list | grep ^alias\\.$1= | sed -e s/^alias\\.//; exit;"
[user]
email = メール
@yuga
yuga / cabal.md
Last active October 20, 2015 09:54
Cabal-1.20.0.2 を使ってビルドしたcabal-installだとcabal testで標準出力が文字化けする。
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
module ReflectionTest where
import Data.Proxy
import Unsafe.Coerce