Skip to content

Instantly share code, notes, and snippets.

@Peaker
Peaker / hangman.hs
Last active October 4, 2015 11:08 — forked from ToJans/hangman.hs
A haskell implementation of the hangman game
{-# OPTIONS -Wall #-}
import Control.Monad (when, unless)
import Data.Char (toLower)
import Data.List (transpose)
import System.Random (randomIO)
wordsPath :: FilePath
wordsPath = "/usr/share/dict/words"
addHangImage :: [String] -> [String]
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE GADTs #-}
module KTuple where
type family Fst (xs :: (a, b)) :: a where
@Peaker
Peaker / indexable.hs
Last active August 29, 2015 14:16 — forked from sinelaw/indexable.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
class Indexable a where
instance c ~ Char => Indexable (String, Int, c) where
instance Indexable ([(String, a)], String, a) where
-- my implementation of this: http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
import qualified Data.PSQueue as DQ
insertThenDel k p pq = DQ.deleteMin $ DQ.insert k p pq
minPriority pq =
case DQ.findMin pq of
(Just m) ->
let mp = DQ.prio m
@Peaker
Peaker / test.hs
Created June 4, 2012 00:35 — forked from dtchepak/test.hs
Illegal instance declaration, flexible instances?
{-# LANGUAGE TypeFamilies #-}
class Collection c where
type Element c
insert :: Element c -> c -> c
instance Collection [a] where
type Element [a] = a
insert = (:)
@Peaker
Peaker / lisp.hs
Created May 1, 2011 11:51
Minimal Lisp in Haskell
{-# LANGUAGE OverloadedStrings #-}
{- To Run:
Load in ghci
:set -XOverloadedStrings (for convenience)
Execute repl expr -}
import Control.Applicative
import Control.Monad.State.Strict
import Data.Function
:leyal@leyal-desktop:~/personal/devel/haskell/irc$ hlint rovar.hs
rovar.hs:15:1: Error: Redundant do
Found:
do loadDir "basic_types" >> loadDir "complex" >>
loadDir "single_types"
Why not:
loadDir "basic_types" >> loadDir "complex" >>
loadDir "single_types"
rovar.hs:18:20: Warning: Redundant brackets