Skip to content

Instantly share code, notes, and snippets.

View 23Skidoo's full-sized avatar

Mikhail Glushenkov 23Skidoo

View GitHub Profile
@23Skidoo
23Skidoo / HaddockListBug.hs
Last active August 29, 2015 14:04
Haddock list rendering bug
-- | The first list is incorrectly numbered as 1. 2. 1.; the second example
-- renders fine (1. 2. 3.).
--
-- See https://github.com/haskell/haddock/issues/313
module HaddockListBug
where
{- |
Some text.
@23Skidoo
23Skidoo / haddock-escape.el
Last active February 15, 2017 00:14
An Elisp function for escaping special characters in Haddock's @ code blocks
; See http://www.haskell.org/haddock/doc/html/ch03s08.html#idp1371070500
; and http://www.haskell.org/haddock/doc/html/ch03s08.html#idp1371060908
;
; Examples:
; \, /, ', `, ", @, < ===> \\, \/, \', \`, \", \@, \<
; foo `fmap` bar "/a/b" ===> foo \`fmap\` bar \"\/a\/b\"
(defun haddock-escape (start end)
"Escape symbols that have special meaning in Haddock comments."
(interactive "r")
(replace-regexp "\\([^\\\\]?\\)\\(`\\|'\\|\\\"\\|@\\|<\\|/\\|\\\\\\)" "\\1\\\\\\2" nil start end))
@23Skidoo
23Skidoo / .gitignore
Last active December 31, 2015 03:59
Internal custom preprocessor example.
dist
@23Skidoo
23Skidoo / after.txt
Last active December 26, 2015 22:09
Cabal/hsc2hs bug: silly command-line invocation (cabal_macros.h is repeated multiple times)
/home/gman/bin/ghc-7.6.3/bin/hsc2hs --cc=/usr/bin/gcc
--ld=/usr/bin/gcc --cflag=-Wl,--hash-size=31
--cflag=-Wl,--reduce-memory-overheads --lflag=-Wl,--hash-size=31
--lflag=-Wl,--reduce-memory-overheads
--cflag=-D__GLASGOW_HASKELL__=706 --cflag=-Dlinux_BUILD_OS=1
--cflag=-Di386_BUILD_ARCH=1 --cflag=-Dlinux_HOST_OS=1
--cflag=-Di386_HOST_ARCH=1 --cflag=-IDatabase/HSQL
--cflag=-I/usr/include/mysql
--cflag=-Idist/dist-sandbox-53474081/build/autogen
--cflag=-include
import Control.Monad
import Data.Word
import LLVM.Core
import LLVM.Util.File
-- prints out "hello world"
bldGreet :: String -> CodeGenModule (Function (IO ()))
bldGreet userName = do
puts <- newNamedFunction ExternalLinkage "puts" :: TFunction (Ptr Word8 -> IO Word32)
func <- withStringNul ("Hello, " ++ userName ++ "!") $ \greetz ->
@23Skidoo
23Skidoo / cabal_macros.h
Created October 17, 2013 14:31
cabal_macros.h with TOOL_VERSION
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package array-0.4.0.1 */
#define VERSION_array "0.4.0.1"
#define MIN_VERSION_array(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 4 || \
(major1) == 0 && (major2) == 4 && (minor) <= 0)
/* package base-4.6.0.1 */
@23Skidoo
23Skidoo / simple-constant.s
Last active December 24, 2015 00:39
Asm code for the TypeLits example: GHC 7.6 vs 7.8 See http://stackoverflow.com/questions/19020829/ghc-typelits-overhead/19035200
.data
.align 4
.align 1
.globl __stginit_main:Test
.type __stginit_main:Test, @object
__stginit_main:Test:
.data
.align 4
.align 1
.globl Test.test_closure
@23Skidoo
23Skidoo / setup-ec2.sh
Created September 5, 2013 21:07
A shell script for setting up a fresh EC2 Ubuntu 12.04 instance for GHC/Cabal development. Inspired by https://gist.github.com/rrnewton/6295246
#! /bin/sh
sudo aptitude update
sudo aptitude full-upgrade
sudo aptitude install build-essential git libgmp3-dev libgmp3c2 libgmp-dev pigz lbzip2 autoconf libtool zlib1g-dev libncurses-dev zile
wget http://www.haskell.org/ghc/dist/7.6.3/ghc-7.6.3-x86_64-unknown-linux.tar.bz2
tar xjvf ghc-7.6.3-x86_64-unknown-linux.tar.bz2
cd ghc-7.6.3
mkdir ~/bin/ghc-7.6.3
./configure --prefix /home/ubuntu/bin/ghc-7.6.3 && make install
@23Skidoo
23Skidoo / StackOverflow.hs
Created September 3, 2013 22:15
Incremental text processing in Haskell with lazy I/O.
-- See http://stackoverflow.com/questions/18601033/haskell-avoiding-stack-overflow-in-folds-without-sacrificing-performance/18602250.
{-# LANGUAGE OverloadedStrings, BangPatterns #-}
module Main where
import qualified Data.ByteString.Lazy.Char8 as L
import Data.Int (Int64)
genTweets :: L.ByteString -> L.ByteString