Skip to content

Instantly share code, notes, and snippets.

View ReflectionTest.hs
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
module ReflectionTest where
import Data.Proxy
import Unsafe.Coerce
@yuga
yuga / cabal.md
Last active Oct 20, 2015
Cabal-1.20.0.2 を使ってビルドしたcabal-installだとcabal testで標準出力が文字化けする。
View cabal.md
View .gitconfig
[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 = メール
View numbase62.hs
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
View Fix.hs
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableInstances #-}
module Fix where
-- Definitions:
--
-- If (μF,inF) is the initial F-algebra for some endofunctor F
View Objective.hs
{-# 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)
--
View Free.hs
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)
@yuga
yuga / hackagedocs
Created Apr 16, 2015
maoeさんのを手元環境で動くようにしたバージョン。
View hackagedocs
#!/bin/bash
cabal configure && cabal build && cabal haddock --hyperlink-source \
--html-location='http://hackage.haskell.org/package/$pkg/docs' \
--contents-location='http://hackage.haskell.org/package/$pkg'
S=$?
if [ "${S}" -eq "0" ]; then
cd "dist/doc/html"
DDIR="${1}-${2}-docs"
cp -r "${1}" "${DDIR}" && tar -cvz --format=ustar -f "${DDIR}.tar.gz" "${DDIR}"
CS=$?
@yuga
yuga / read.hs
Created Feb 28, 2015
ByteString -> Double
View read.hs
toRealFloat . either error id . parseOnly Data.Attoparsec.ByteString.Char8.scientific :: ByteString -> Double
View query_orderby_sql-99.bnf.md

UNIONとORDER BYの組み合わせ

relational-record-examples の sql/6.4.1a.sh に対応するHaskellコードの説明を書いていて、何だか嘘を書いている気分になったので調査してみた。ちなみに書いていた説明は以下のようなもの。英語は雰囲気です。

-- | sql/6.4.1a.sh
--
-- MySQL allows the syntax of UNION that has an order clause at the
-- last of query. SQLite does not.
You can’t perform that action at this time.