Skip to content

Instantly share code, notes, and snippets.

@notae
notae / MultiTypeMap.hs
Last active August 29, 2015 14:03
[Haskell] Example of storing multiple types into single Map using Enum
-- Example of storing multiple types into single Map using Enum
import Control.Monad.State (State)
import Control.Monad.State (runState)
import Control.Monad.State (evalState)
import Control.Monad.State (gets)
import Control.Monad.State (modify)
import Control.Monad (liftM2)
import Data.Map (Map)
import Data.Maybe (fromMaybe)
@notae
notae / CFPFD.hs
Created July 10, 2014 16:17
Constraint Programming over Finite Domain in Haskell (and Sudoku example)
{-|
Module : CFPFD
Description : Constraint Functional Programming over Finite Domain
Copyright : (c) notae@me.com, 2014
License : BSD-style
Maintainer : notae@me.com
Stability : experimental
Portability : POSIX
This module provides interfaces for constraint programming
@notae
notae / ListTExample.hs
Created July 15, 2014 18:31
ListT Example
-- ListT Example
import Control.Monad.List (ListT(..))
import Control.Monad.State (State)
import Control.Monad.State (modify)
import Control.Monad.Trans (lift)
import Control.Monad.Writer (Writer)
import Control.Monad.Writer (tell)
liftList :: (Monad m) => [a] -> ListT m a
@notae
notae / STMonad.hs
Created July 20, 2014 16:36
ST Monad Example
-- ST Monad Example
import Control.Monad.ST (ST)
import Control.Monad.ST (runST)
import Data.STRef (STRef)
import Data.STRef (modifySTRef)
import Data.STRef (newSTRef)
import Data.STRef (readSTRef)
prog :: Int -> ST s Int
@notae
notae / HList.hs
Created July 22, 2014 05:24
HList: Heterogeneous List
{-
Heterogeneous List Example
from
Strongly Typed Heterogeneous Collections
http://okmij.org/ftp/Haskell/HList-ext.pdf
(This HList definition is different from the version in Hackage)
-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
@notae
notae / CFPFD1.hs
Last active August 29, 2015 14:04
Constraint Programming over Multiple Finite Domain (with class Enum)
{-|
Module : CFPFD1
Description : Constraint Functional Programming over Multiple Finite Domain
Copyright : (c) notae@me.com, 2014
License : BSD-style
Maintainer : notae@me.com
Stability : experimental
Portability : POSIX
This module provides interfaces for constraint programming
@notae
notae / example.log
Last active August 29, 2015 14:05
bindings-portaudio test
# with GHC 7.8.3 (Haskell Platform 2014.2.0.0) on Mac OS X 10.9.4
$ cabal sandbox init
$ cabal install bindings-DSL
$ cabal configure -fCoreAudio
$ cabal install -fCoreAudio
$ cd example/
$ cabal --sandbox-config-file=../cabal.sandbox.config configure
$ cabal --sandbox-config-file=../cabal.sandbox.config build
@notae
notae / ghc_setup_home.sh
Last active August 29, 2015 14:05
GHC/Cabal initial setup script for home directory
#!/bin/sh -e
#
# Module : ghc_setup_home.sh
# Description : GHC/Cabal initial setup script for home directory
# Copyright : (c) notae@me.com, 2014
# License : BSD-style
# Maintainer : notae@me.com
# Stability : experimental
# Portability : POSIX
@notae
notae / setup_music-suite_sandbox.sh
Created September 19, 2014 22:12
Script to setup sandbox for music-suite
#!/bin/sh -xe
WORKDIR=~/Documents/Haskell
MWORKDIR=~/Documents/Haskell/music-suite
cabal sandbox delete
cabal sandbox init
cabal sandbox add-source \
${WORKDIR}/cpfd \
${WORKDIR}/muse \
@notae
notae / bashcheck.log
Last active August 29, 2015 14:07
bashcheck on Mac OS X Mavericks before / after OS X bash Update 1.0
Before:
$ ./bashcheck
Vulnerable to CVE-2014-6271 (original shellshock)
Vulnerable to CVE-2014-7169 (taviso bug)
./bashcheck: line 18: 2839 Segmentation fault: 11 bash -c "true $(printf '<<EOF %.0s' {1..79})" 2> /dev/null
Vulnerable to CVE-2014-7186 (redir_stack bug)
Test for CVE-2014-7187 not reliable without address sanitizer
Variable function parser still active, likely vulnerable to yet unknown parser bugs like CVE-2014-6277 (lcamtuf bug)