Skip to content

Instantly share code, notes, and snippets.

@acfoltzer
acfoltzer / gist:2926368
Created June 13, 2012 20:33
Listings settings for Haskell
\lstnewenvironment{code}
{\lstset{}%
\csname lst@SetFirstLabel\endcsname}
{\csname lst@SaveFirstLabel\endcsname}
\lstset{
language=Haskell,
basicstyle=\small\ttfamily,
flexiblecolumns=false,
basewidth={0.5em,0.45em},
% keywordstyle=\color{blue},
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ConstraintKinds #-}
import Control.Applicative
import Control.Monad.State
data Var = Var
{-# LANGUAGE NoMonomorphismRestriction #-}
import Data.Map as Map
import Prelude as P
-- When there's a name clash, you can use the qualifier
mapNull = Map.null
listNull = P.null
-- When a name is unambiguous, you can just use it
mapMember = member
@acfoltzer
acfoltzer / ConsList.hs
Created April 30, 2013 20:00
Example of view patterns + typeclasses for polymorphic "constructors"
{-# LANGUAGE ViewPatterns #-}
import Data.Vector (Vector)
import qualified Data.Vector as V
data ConsView a = Nil | Cons a (ConsView a)
deriving (Eq, Ord, Show)
class ConsList l where
viewCons :: l a -> ConsView a
% mv
File "/bin/mv", line 6
SyntaxError: Non-ASCII character '\xc2' in file /bin/mv on line 6, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
@acfoltzer
acfoltzer / gist:7188179
Last active December 26, 2015 17:39
Haskell.org Committee Self-Nomination

Dear Committee,

I'm writing to nominate myself for a position on the haskell.org committee.

As a working Haskell developer at Galois, having reliable infrastructure is deeply important to me, and I would like to help maintain it however I can. I have experience maintaining web, mail, and IRC servers, as well as acquiring and configuring SSL certificates for those services. I hope that these skills may prove of use to the committee.

I also believe this is a critical point in the growth of our community. As adoption of Haskell increases, the decisions we make now will shape how our community develops, for good or for bad. I was moved by Chung-chieh Shan's [Haskell 2013 Program Chair report][1]. As he says, it can be hard work to speak one's mind with compassion, but let me try so that you can know better my concerns and what I hope to work towards.

I believe that a lack of diversity is one of the primary problems facing the Haskell community today. Ashe Dryden recently spoke at Galois and gave an excellent

@acfoltzer
acfoltzer / gist:52055b418ef984e91faf
Created July 29, 2014 03:20
Examples from Haskell Office Hours
{-# LANGUAGE FlexibleInstances #-}
-- | A simple datatype similar to 'Bool'
data A = B | C
a :: A
a = B
-- | A more complicated datatype with values associated with each constructor.
data Foo = Bar Int String | Baz (Bool -> Bool)
@acfoltzer
acfoltzer / idris.rb
Last active August 29, 2015 14:13
Updated idris formula
require "language/haskell"
class Idris < Formula
include Language::Haskell::Cabal
homepage "http://www.idris-lang.org"
depends_on "ghc" => :build
depends_on "cabal-install" => :build
depends_on "gmp"
This file has been truncated, but you can view the full file.
Using a sandbox located at /private/tmp/stack/.cabal-sandbox
/Users/acfoltzer/.cabal/bin/alex --version
/Users/acfoltzer/.cabal/bin/c2hs --numeric-version
/usr/bin/gcc -dumpversion
/usr/local/bin/haddock --version
/Users/acfoltzer/.cabal/bin/happy --version
/usr/local/bin/hpc version
looking for tool hsc2hs near compiler in /usr/local/bin
found hsc2hs in /usr/local/bin/hsc2hs
/usr/local/bin/hsc2hs --version
// Constraining properties based on String-specific inputs
// In Cryptol, `String n` is just an alias for `[n][8]` (ASCII)
type IPv4String = String 15
// Print four octets as an IPv4-formatted string
printIp : [4][8] -> IPv4String
printIp ip = x # "." # y # "." # z # "." # w
where
[x, y, z, w] = [ printByte b | b <- ip ]