Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE FlexibleContexts #-}
-- | A section: Parser and printer.
-- See <https://en.wikipedia.org/wiki/Section_(category_theory)>
--
-- It's like an isomorphism, except one side is not a complete mapping
-- i.e. the parsing side, but the printing side is complete (anything
-- that is printed can be parsed).
module Yesod.Form.FieldSection where
@chrisdone
chrisdone / headerimg.png
Created April 26, 2016 19:54
Redesigned /r/haskell design
headerimg.png
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-
showVar :: DynFlags -> Var -> String
showVar df var =
case var of
$(conPat ''Var "TyVar" [p|() varName _ varType|]) ->
@chrisdone
chrisdone / Expose.hs
Created May 12, 2016 16:18
Expose constructors haskell
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-
showVar :: DynFlags -> Var -> String
showVar df var =
case var of
$(conPat ''Var "TyVar" [p|() varName _ varType|]) ->
@chrisdone
chrisdone / FastWalk.hs
Created June 8, 2016 09:13
Fast walking over a file
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-
- Nothing : 40,960 bytes allocated in the heap
- Open file and close file : 64,768 bytes allocated in the heap
- Walk the whole file with a buffer : 151,456 bytes allocated in the heap
- Counting and reporting chunks : 163,440 bytes allocated in the heap
- Peek each one into a Word16 : 163,448 bytes allocated in the heap
@chrisdone
chrisdone / hoogle.md
Created June 27, 2016 14:27
stack hoogle

Introducing the stack hoogle feature!

With the release of hoogle5, we can now hoogle all packages referenced by our packages in our stack.yaml. This feature is on the master branch of stack, but is not yet on a stack release. We'd like you to try it out before we do!

To upgrade to the latest stack from git, use:

$ stack upgrade --git

@chrisdone
chrisdone / hoogle.md
Last active September 6, 2022 20:33
stack hoogle

Introducing the stack hoogle feature!

With the release of hoogle5, we can now hoogle all local packages.

This let us implement stack hoogle, which is on the master branch of stack, but is not yet on a stack release. We'd like you to try it out before we do!

To upgrade to the latest stack from git, use:

@chrisdone
chrisdone / BinaryView.hs
Last active April 4, 2019 17:14
BinaryView - Dump binary a bit like a hex editor, but in decimal on the left.
{-# OPTIONS_GHC -Wall #-}
-- | Dump binary a bit like a hex editor, but in decimal on the left.
--
-- 01 01 00 5C 00 00 01 00 . . . \ . . . .
-- 16 00 00 00 12 00 00 00 . . . . . . . .
-- 02 00 00 00 00 00 00 00 . . . . . . . .
-- 00 01 00 00 00 00 0A 00 . . . . . . . .
-- 73 00 65 00 6C 00 65 00 s . e . l . e .
-- 63 00 74 00 20 00 27 00 c . t . . ' .
/* The Computer Language Benchmarks Game
* http://benchmarksgame.alioth.debian.org/
*
* Contributed by Mr Ledrug
*/
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
@chrisdone
chrisdone / Clang
Last active August 1, 2016 08:44
pidigits: ghc vs gcc
bash-3.2$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
bash-3.2$ cat > main.c
/* The Computer Language Benchmarks Game
* http://benchmarksgame.alioth.debian.org/
*
* Contributed by Mr Ledrug