Skip to content

Instantly share code, notes, and snippets.

View alexpeits's full-sized avatar

Alex Peitsinis alexpeits

View GitHub Profile
@erochest
erochest / generate-html.sh
Created March 21, 2012 17:46
A script I wrote in Literate Haskell using Shelly
#!/bin/sh
# pandoc -f markdown+lhs -t html5 --smart --css https://raw.github.com/richleland/pygments-css/master/default.css s5topdf.lhs
# pandoc -f markdown+lhs -t html5 --smart --css s5topdf.css s5topdf.lhs
pandoc -f markdown+lhs -t html5 --smart s5topdf.lhs
@surajacharya
surajacharya / git-grep-dired.el
Created November 21, 2012 20:41 — forked from jglick/git-grep-dired.el
M-x git-grep-dired: Emacs command to search for text patterns in a Git repo à la find-grep-dired
(defun git-grep-dired (repo wildcards regexp)
"Find Git-controlled files in DIR with a name like WILDCARDS containing a regexp REGEXP and start Dired on output."
(interactive "DGit-grep (directory): \nsGit-grep (filename wildcard(s), e.g. *.xml): \nsGit-grep (grep regexp): ")
(setq repo (file-name-as-directory (expand-file-name repo)))
(switch-to-buffer (concat "*Git Grep " repo "*"))
(fundamental-mode)
(setq buffer-read-only nil)
(erase-buffer)
(setq default-directory repo)
(let ((cmd (format "git --git-dir %s/.git ls-files -z%s | xargs -0 grep -lZ -- %s | xargs -0 ls -l"
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active May 19, 2024 19:25
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

# Install a local copy of Hoogle (OS X, HP)
# Download
cd
cabal unpack hoogle
cd hoogle-4.2.26/
# Build
cabal sandbox init
cabal install -j --dependencies-only
@staltz
staltz / introrx.md
Last active June 18, 2024 06:15
The introduction to Reactive Programming you've been missing
@chrisdone
chrisdone / typing.md
Last active May 9, 2024 15:27
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology

import Control.Applicative
import Control.Monad.ST.Safe
import qualified Data.Vector.Unboxed as IU
import qualified Data.Vector.Unboxed.Mutable as U
-- Mutable world
data World s = World
{ _souls :: !(U.STVector s Int)
, _positions :: !(U.STVector s (Float,Float))
}
@nkpart
nkpart / Err.hs
Last active August 20, 2022 01:20
Lens, Prisms, and Errors.
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fwarn-missing-methods #-}
module Err where
import Control.Lens
import Control.Monad.Error
import Control.Monad.Error.Lens
-- Here is a fairly typical situation, where we have low level errors in certain
@CMCDragonkai
CMCDragonkai / free_monad_interpreter_pattern.md
Last active June 7, 2021 01:35
Haskell: Free Monad + Interpreter Pattern

Free Monad + Interpreter Pattern

It's like creating the front end and back end of a compiler inside Haskell without the need of Template Haskell!

Write your DSL AST as a Free Monad, and then interpret the monad any way you like.

The advantage is that you get to swap out your interpreter, and your main code

{-# language KindSignatures #-}
{-# language PolyKinds #-}
{-# language DataKinds #-}
{-# language TypeFamilies #-}
{-# language RankNTypes #-}
{-# language NoImplicitPrelude #-}
{-# language FlexibleContexts #-}
{-# language MultiParamTypeClasses #-}
{-# language GADTs #-}
{-# language ConstraintKinds #-}