Skip to content

Instantly share code, notes, and snippets.

Gatlin Johnson gatlin

Block or report user

Report or block gatlin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gatlin
gatlin / uninstall-haskell-osx.sh
Created Oct 10, 2012
Uninstall Haskell from Mac OS X
View uninstall-haskell-osx.sh
#!/bin/bash
# source: http://www.haskell.org/pipermail/haskell-cafe/2011-March/090170.html
sudo rm -rf /Library/Frameworks/GHC.framework
sudo rm -rf /Library/Frameworks/HaskellPlatform.framework
sudo rm -rf /Library/Haskell
rm -rf .cabal
rm -rf .ghc
rm -rf ~/Library/Haskell
@gatlin
gatlin / gist:d89ee5442c10ca59ac9a8b621392ed10
Created May 1, 2019
Oleg's CK machine macro system - ever so slightly easier to find cross device here
View gist:d89ee5442c10ca59ac9a8b621392ed10
; Composable syntax-rules macros via the CK abstract machine
;
; We demonstrate (mutually-) recursive, higher-order applicative
; macros with clausal definitions, defined in the style that looks very
; much like that of ML or (strict) Haskell.
; We write composable, call-by-value--like macros without
; resorting to the continuation-passing-style and thus requiring no
; macro-level lambda. The syntax remains direct-style, with
; nested applications.
View free-compiler.hs
{-|
- Example of using free constructions to build a flexible little compiler.
-
- The goal here is not necessarily efficiency but readability and flexibility.
-
- The language grammar is represented by an ADT; however, instead of
- recursively referring to itself it instead references a type variable.
-
- We derive instances of 'Functor' and 'Traversable' for this type.
-
@gatlin
gatlin / monads.lhs
Created Nov 25, 2012
My explanation of monads
View monads.lhs
It's said that all Haskell programmers eventually write a blog post explaining
Monads. Today I fulfill my destiny. The basic format is ripped from "Learn You A
Haskell For Great Good," but these are my own crappy examples.
This blog post is literate Haskell; you can get it
[here](https://gist.github.com/4145341). You can import it into ghci and type
the functions to see their output (`ghci monads.lhs`). For this to work, we'll
need to import one module for use later:
> import Control.Applicative
@gatlin
gatlin / typed-racket-monads.md
Last active Nov 25, 2018
A simple definition and demonstration of monads in Typed Racket
View typed-racket-monads.md

What the fuck is a monad?

Or: functor? I 'ardly know 'er!

Monads are difficult to explain without sounding either patronizing or condescending: I would sound patronizing if I came up with some facile analogy and I would be condescending to describe it categorically.

Instead, I'll frame a problem and piece-by-piece solve the problem with what will turn out to be a monad.

@gatlin
gatlin / yet-another-conway.hs
Last active Aug 20, 2018
Yet Another Comonadic Game of Life implementation in Haskell, in response to a Reddit thing. Much love to those who have done similar things previously. I'm really just a messenger here.
View yet-another-conway.hs
{-# LANGUAGE DeriveFunctor #-}
import Control.Applicative
import Control.Comonad
import Control.Monad (forM_)
-- These two typeclasses probably make some people groan.
class LeftRight t where
left :: t a -> t a
@gatlin
gatlin / psilo-typeclass.sl
Last active Aug 13, 2018
Hask-- I mean, psilo with zero real typeclasses and one virtual typeclass
View psilo-typeclass.sl
;; Hask-- I mean, psilo with no real typeclasses and one virtual typeclass.
; Inspired by [1], this is an exploration of representing all typeclasses
; through one distinguished class.
;
; This version of psilo does not have "real" typeclasses. However faking them
; with explicit dictionary passing does seem to correctly infer and check the
; constraints.
;
; The goal then is to figure out how best to represent "real" typeclasses as a
; distinguished feature in the language implementation given that we are
@gatlin
gatlin / sat.hs
Created Feb 6, 2012
SAT Solver in Haskell
View sat.hs
-- This is going to be on Hackage soon! https://github.com/gatlin/surely
{-# LANGUAGE BangPatterns #-}
-- |
-- Module : AI.Surely
-- Copyright : 2012 Gatlin Johnson
-- License : LGPL 3.0
-- Maintainer : rokenrol@gmail.com
-- Stability : experimental
View haskell-billing-server.lhs
Writing a billing system in Haskell, using Stripe and Heroku
===
*This post is written in literate Haskell, meaning the source can be turned
into a blogpost or a working program. You can view the [source][source].
[source]: https://gist.github.com/gatlin/7754289
Normally clients pay me with checks, but recently one informed me that they
really really really like *really really* super prefer some kind of online
View io.hs
{-# LANGUAGE RankNTypes #-}
import Prelude hiding (IO, getLine)
import qualified Prelude as P
import System.IO.Unsafe
-- * The Foreign Function Interface
-- | FFI values permit interfacing with foreign functions, such as low-level IO
-- operations, memory management operations, or bindings to other user-level
You can’t perform that action at this time.