Skip to content

Instantly share code, notes, and snippets.

View aycanirican's full-sized avatar
💭
Lifelong learning

Aycan iRiCAN aycanirican

💭
Lifelong learning
View GitHub Profile
type ErrMsg = SomeException
data Stream el = EOF (Maybe ErrMsg)
| Chunk [el] deriving Show
type Intermediate a el = (a, Stream el)
-- | a: intermediate result
-- r: final result of the CPS computation
newtype ContM r el a = Cont { runCont ∷ (Intermediate a el → r) → r}
module Fold where
import Test.QuickCheck
op xs = go xs True 0 where
go [] _ acc = acc
go xs@(a:res) True acc = go res False (acc + a)
go xs@(a:res) False acc = go res True (acc - a)
prop_iso xs = foldr (-) 0 xs ≡ op xs
{-# LANGUAGE TypeFamilies #-}
module JS.Ann where
-- | annotated fixpoint combinator
data FixA (a ∷ (* → *) → (* → *))
(f ∷ (* → *))
= InA { outa ∷ a f (FixA a f) }
| InF { outf ∷ f (FixA a f) }
{-# LANGUAGE TypeFamilies #-}
module JS.Syntax where
import qualified JS.Ann as A
type Expr a = A.Fix (Expression a)
type LVal a = A.Fix (LValue a)
type Stmt a = A.Fix (Statement a)
-- | Js Syntax
#!/bin/sh
# Parameters
HOST="localhost"
USER="user"
PASS="pass"
DB="database"
DDIR="/home/username/dbbackup"
D=`date +%Y%m%d`
DUMP="mysqldump -h $HOST -u $USER -p $PASS $DB"
@aycanirican
aycanirican / manyN and manyNtoM
Created November 8, 2010 10:05
attoparsec additions
-- | Match a parser at least @N@ times.
manyN :: Int -> Parser a -> Parser [a]
manyN n p
| n <= 0 = return []
| otherwise = (++) <$> count n p <*> many p
{-# INLINE manyN #-}
-- | Match a parser at least @N@ times, but no more than @M@ times.
manyNtoM :: Int -> Int -> Parser a -> Parser [a]
manyNtoM n m p
@aycanirican
aycanirican / gist:1740098
Created February 4, 2012 20:55
dragonflybsd pkgsrc: esound-0.2.41 build failed.
===> Checking for vulnerabilities in esound-0.2.41
===> Building for esound-0.2.41
/usr/pkg/bin/bmake all-recursive
Making all in docs
/bin/sh ./libtool --tag=CC --mode=link cc -I/usr/include -I/usr/pkg/include
-I/usr/pkg/include -Wall -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr
/pkg/lib -o esd esd.o clients.o filter.o mix.o players.o proto.o samples.o l
ibesd.la -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -laudiofile -Wl,-R/usr/pkg/lib -L/usr
/pkg/lib -laudiofile
libtool: link: cc -I/usr/pkgsrc/audio/esound/work/.buildlink/include -Wall -Wl,-
@aycanirican
aycanirican / gist:1768136
Created February 8, 2012 10:48
ghc-7.4.1 on dragonflybsd failed.
"inplace/bin/ghc-stage1" -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Iincludes -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-fno-strict-aliasing -optc-fno-common -optc-fomit-frame-pointer -optc-DRtsWay=\"rts_v\" -H32m -O -Iincludes -Irts -Irts/dist/build -DCOMPILING_RTS -package-name rts -dcmm-lint -i -irts -irts/dist/build -irts/dist/build/autogen -Irts/dist/build -Irts/dist/build/autogen -optc-O2 -c rts/posix/TTY.c -o rts/dist/build/posix/TTY.o
rts/posix/Signals.c: In function 'stg_sig_install':
rts/posix/Signals.c:365:0:
error: 'SA_RESETHAND' undeclared (first use in this function)
rts/posix/Signals.c:365:0:
error: (Each undeclared identifier is reported only once
rts/posix/Signals.c:365:0:
@aycanirican
aycanirican / gist:1870743
Created February 20, 2012 19:01
autoconf generates bad test code...dfly3.1
configure:8124: checking for long long
configure:8124: /usr/bin/gcc -c -g -O2 -fno-stack-protector conftest.c >&5
configure:8124: $? = 0
configure:8124: /usr/bin/gcc -c -g -O2 -fno-stack-protector conftest.c >&5
conftest.c: In function 'main':
conftest.c:82: error: expected expression before ')' token
configure:8124: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "The Glorious Glasgow Haskell Compilation System"
@aycanirican
aycanirican / gist:1870827
Created February 20, 2012 19:15
autoconf fails...dfly demonstration...
% cat configure.ac
AC_INIT([dflytest1], [0.1], [iricanaycan@gmail.com], [dflytest1])
AC_CHECK_TYPES([long long])
# execute "autoconf" and then "./configure", see config.log