Skip to content

Instantly share code, notes, and snippets.

@sinelaw
sinelaw / gen_files_json.hs
Created January 13, 2015 11:16
Generates a json file describing the directory structure
module Main where
import System.Directory (getDirectoryContents)
import Control.Monad (forM_)
import Data.Functor ((<$>))
import System.Posix.Files (getSymbolicLinkStatus, isDirectory)
withIsLast :: [a] -> [(a, Bool)]
withIsLast [] = []
withIsLast [x] = [(x, True)]
#include <rfftw.h>
#include <math.h>
#include <stdio.h>
/* the out format is: */
/* r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1 */
void fft(int n, fftw_real in[n], fftw_real power_spectrum[n/2+1])
{
fftw_real out[n];
rfftw_plan p;
;;(load "/local-home/user18/repos/thirdparty/emacs-haskell-config/init.el")
(add-to-list 'load-path "~/repos/thirdparty/emacs-haskell-config/packages/haskell-mode/")
(require 'haskell-mode-autoloads)
(add-to-list 'Info-default-directory-list "~/repos/thirdparty/emacs-haskell-config/packages/haskell-mode/")
(require 'cl)
(add-to-list 'load-path "~/.emacs.d/lisp")
(require 'cask "~/.cask/cask.el")
{-# OPTIONS -Wall #-}
{-# LANGUAGE TypeFamilies, FlexibleInstances #-}
import Data.Map
class Indexable a where
type Index a
type Result a
index :: a -> Index a -> Result a
@sinelaw
sinelaw / indexable.hs
Created February 25, 2015 00:31
Associated types without type families - why can't this work?
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
class Indexable a where
instance Indexable (String, Int, Char) where
instance Indexable ([(String, a)], String, a) where
test1 :: Indexable (a,b,c) => a -> b -> c
@sinelaw
sinelaw / OptionalArg.hs
Last active August 29, 2015 14:19
OptionalArguments from ML in Haskell - see http://mlton.org/OptionalArguments
-- see http://mlton.org/OptionalArguments
module OptionalArg where
data Product a b = a :& b deriving Show
end (a, f) = f a
fold (a, f) g = g (a, f)
step0 h (a, f) = fold (h a, f)
step1 h (a, f) b = fold (h (b, a), f)
@sinelaw
sinelaw / ordArray.js
Last active August 29, 2015 14:22
ordArray generated function from GHCJS
var ordArray = function (__dict_Ord_9) {
return {
"__superclasses": {
"Prelude.Eq_0": function (_) {
return eqArray(__dict_Ord_9["__superclasses"]["Prelude.Eq_0"]({}));
}
},
compare: function (_20) {
return function (_21) {
if (_20.length === 0) {
@sinelaw
sinelaw / superlamda.py
Last active August 29, 2015 14:23
Next-generation IDE for functional programming
# Next-generation IDE for functional programming
# Run it, and press any key to start writing code.
# It will automatically exit when you're done writing your function.
# Work in progress, currently supports factorial
import sys
factorial = 'fac n = if n > 1 then n * (fac (n - 1)) else 1'.split()
@sinelaw
sinelaw / gc.hs
Last active August 29, 2015 14:26
{-# LANGUAGE MagicHash #-}
module Main where
import Control.Monad
import Data.Word (Word64)
import qualified Data.ByteString.Char8 as BS8
import Control.DeepSeq
import qualified Data.Text.Array as A
import GHC.Prim
import GHC.Base (Int(..))
-- |
module Bidirectional where