Skip to content

Instantly share code, notes, and snippets.

View isovector's full-sized avatar

Sandy Maguire isovector

View GitHub Profile
@jasonreich
jasonreich / List.hs
Created December 27, 2010 13:30
List append associativity proof in Haskell's type system... perhaps
{-
Uses the She (Stathclyde Haskell Enhancement), which you
can get from http://bit.ly/gaVM8X.
-}
{-# OPTIONS_GHC -Wall -F -pgmF she #-}
{-# LANGUAGE GADTs, KindSignatures #-}
{-# LANGUAGE TypeFamilies, TypeOperators #-}
{-# LANGUAGE RankNTypes, FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
@parsonsmatt
parsonsmatt / mtl.hs
Last active October 27, 2017 23:20
`mtl` style enables reinterpretation of a monad, like `free`
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleContexts #-}
module Mtl where
import Control.Monad.State
import Control.Monad.Except
runMtl
:: Bool
@Lysxia
Lysxia / hkd-apply.hs
Created April 3, 2018 00:00
HKD deriving ToJSON by encoding quantified constraints
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
@chpatrick
chpatrick / Bake.hs
Last active September 15, 2018 04:20
Baked-in Storable Vectors Mark II
{-# LANGUAGE MagicHash, TupleSections, TemplateHaskell #-}
module Data.Vector.Storable.Bake(bake, unsafeFromAddrLen) where
import Data.Typeable
import qualified Data.Vector.Storable as VS
import Foreign
import GHC.Prim
import GHC.Ptr
import Language.Haskell.TH
@schell
schell / haskell-games.md
Last active October 1, 2018 21:28
haskellgames.com

what is it

The idea is to host haskell implementations of popular console/arcade titles as a blog series. The end goal being to ignite interest in writing games with haskell and possibly hosting a haskell game jam at some point in the future. For launch it would be nice to have 3-4 games already written.

Getting this off the ground is going to take a long time as my (schell's) free time is pretty limited ATM, so don't worry if you feel like committing to this is too much. You can commit any amount of time and write your game slowly as I figure out the details.

@KingoftheHomeless
KingoftheHomeless / Mo.hs
Last active November 15, 2018 20:42
The monad-to-comonad transformer
{-# LANGUAGE RankNTypes, GADTs #-}
module Mo where
import Control.Comonad
import Control.Comonad.Trans.Class
import Control.Monad
{-
The monad-to-comonad transformer.
Originally, Mo was defined as the simpler (and isomorphic):
data Mo m w a where
@PkmX
PkmX / loeb.md
Last active January 9, 2019 15:59
Löb with error handling

Löb with error handling

löb is a well-known function in Haskell for implementing spreadsheet-like behaviors and tying the knot. It is defined as:

loeb :: Functor f => f (f a -> a) -> f a
loeb fs = xs
  where xs = fmap ($ xs) fs
@malcolmocean
malcolmocean / geoff-yed-tips
Created April 19, 2015 05:40
Geoff's tips for setting up yEd
From Geoff Anders, of Leverage Research (http://www.leverageresearch.org/)
For people doing goal factoring - or for people making any sort of box-and-arrow diagram - I recommended the program yEd. It is available here: http://www.yworks.com/en/products_yed_about.html
After you install it, I highly recommend setting up the defaults in the following way:
1. Open yEd.
2. Create a new document.
3. Click the white background; a small yellow square should appear on the canvas.
4. Click the small yellow square so as to select it.
@Lysxia
Lysxia / GadtRead.hs
Created May 15, 2019 22:10
Generic parser for GADT with kind-generics
{-# LANGUAGE
AllowAmbiguousTypes,
TypeApplications,
ScopedTypeVariables,
GADTs,
DataKinds,
PolyKinds,
FlexibleContexts,
FlexibleInstances,
MultiParamTypeClasses,
@chshersh
chshersh / TypeError.hs
Last active July 15, 2019 06:53
Examples of custom type errors
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}