Skip to content

Instantly share code, notes, and snippets.

@lspitzner
lspitzner / a.txt
Created July 1, 2016 20:02
sublime3+ghcid setup for quick haskell coding feedback
sublime3 and ghcid setup for quick haskell coding feedback
tested on sublime 3
(you can omit the SublimeOnSaveBuild steps, as the result is not
completely reliable anyways. i still find it useful, though.)
steps:
- install https://github.com/lspitzner/SublimeOnSaveBuild
(original from alexnj; in his/her version the build-window gets closed
@lspitzner
lspitzner / A_multistate-benchmark.txt
Last active May 28, 2016 14:38
some basic multistate benchmarking
------------------
run-time: criterion results
------------------
benchmarking extensible-effects
time 1.337 s (1.308 s .. 1.387 s)
1.000 R² (1.000 R² .. 1.000 R²)
mean 1.314 s (1.304 s .. 1.322 s)
std dev 13.22 ms (0.0 s .. 14.55 ms)
variance introduced by outliers: 19% (moderately inflated)
@lspitzner
lspitzner / Setup.hs
Created May 25, 2016 19:21
haskell/Cabal/Setup.hs for buildnumber module auto-generation
import Distribution.Simple
import Distribution.PackageDescription
import Distribution.Simple.Program
import Distribution.Simple.Command
import Distribution.Simple.PreProcess
import Distribution.Simple.Setup
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.BuildPaths
import Distribution.Simple.BuildTarget
import System.Process
@lspitzner
lspitzner / nix-local-build.md
Last active July 29, 2018 23:46
nix-local-build
old-style new-style
install --only-dependencies part of new-build
install path-to-local-dir add a ./cabal.project file, add your local dependency, then use new-build (cabal.project syntax is described in the announcement)
install path-to-local-sdist does not exist yet
install remote-package-uri does not exist yet
install [--bindir=..] does not exist (yet)
configure new-configure
build (part of) new-build
clean does not exist yet; you have to remove ./dist-newstyle/ and ./cabal.project.local by hand, and potentially ./dist/ as well, i may have observed that it got touched by new-build (not sure, really). This needs to be done for each package referenced from the cabal.project as well.
@lspitzner
lspitzner / generate-qualified-imports.sh
Last active January 19, 2018 22:41
qualified imports in stackage package sources
#!/bin/bash
ls -1 stackage | xargs -I{} bash -c "find \"stackage/{}\" -type f -name \"*.hs\" -o -name \"*.lhs\"\
| xargs grep -h \"^import\" \
| grep \" as \" \
| sed \"s/ \+as//\" \
| sed \"s/^import \+\(qualified \+\)\?//\" \
| sort \
| uniq \
" \
@lspitzner
lspitzner / output.txt
Created February 23, 2016 20:27
Cabal:test on master (a98491440b7650609bbae0e3e264e5b14a246106)
Running 2 test suites...
Test suite unit-tests: RUNNING...
Test suite unit-tests: PASS
Test suite logged to: dist/test/Cabal-1.25.0.0-unit-tests.log
Test suite package-tests: RUNNING...
package-tests: We couldn't understand the build configuration. Try editing Cabal.cabal to have 'build-type: Custom' and then rebuild
ing, or manually specifying CABAL_PACKAGETESTS_* environment variables (see README.md for more details).
Original error: Saved package config file body is corrupt. Try re-running the 'configure' command.
Test suite package-tests: FAIL
@lspitzner
lspitzner / cabal-install-commands.txt
Created July 24, 2015 13:48
cabal-install common subcommands
The most common thing is to install a library (so your project can use it) or
an executable (like when you install `hoogle` so you can search documentation
locally). Behind the scenes, this involves a number of steps:
1. determine package version plan (a consistent Set (Library,Version))
2. download dependencies (i.e. their source)
3. install dependencies (i.e. do steps 1-6a for each dependency)
4. configure (think: what to build in which order, with which compiler flags etc.)
5. build
6a. register (libraries) in package repository
@lspitzner
lspitzner / Main.hs
Last active August 29, 2015 14:13
bad/wrong warning by ghc?
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
module Main where
data HList :: [*] -> * where
HNil :: HList '[]
@lspitzner
lspitzner / cmd.sh
Created January 19, 2015 23:38
sorted list of first element of haskell module identifiers from packages on haskell
#!/bin/bash
cabal list --simple-output | sed "s/ .*//" | uniq | xargs cabal info -v | grep "^ [^ ]" | sed "s/ //" | sed "s/\..*//" | sort | uniq -c | sort -bgr
# or full module names via
#cabal list --simple-output | sed "s/ .*//" | uniq | xargs cabal info -v | grep "^ [^ ]" | sed "s/ //" | sort
# (cannot post the latter; gists seem to have length limit on what you can paste :D)
@lspitzner
lspitzner / Main.hs
Created December 24, 2014 23:39
small example for Writer vs WriterT error message
module Main where
import Control.Monad.Trans.Writer
import Data.Monoid ( Sum(..) )
f :: Writer (Sum Int) ()
f = undefined
g :: Writer (Sum Int) Int
g = do