Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE Arrows, TemplateHaskell #-}
module Main where
import Prelude hiding (id, init, (.))
import Control.Arrow
import Control.Category
@lspitzner
lspitzner / Djinn-env
Last active August 29, 2015 14:10
post correspondence problem in djinn env, assuming that recursive data types are allowed
-- a djinn environment that encodes an instance of the
-- post correspondence problem. it requires recursive data
-- types.
data Foo a b x y = Foo (Bar a b (a x) (b (a (a y))))
(Bar a b (a (b x)) (a (a y)))
(Bar a b (b (b (a x))) (b (b y)))
-- we need duplicate to enforce N>=1
data Bar a b x y = Bar (Bar a b (a x) (b (a (a y))))
@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
@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
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 / 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 / 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 / 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 / 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 / MainReflex.hs
Created April 19, 2017 13:37
reflex design
brickWrapper
:: forall n t
. (Ord n, R.ReflexHost t, MonadIO (R.PushM t), MonadIO (R.HostFrame t))
=> R.Event t ()
-> R.Dynamic t [Widget n]
-> R.Dynamic t ([CursorLocation n] -> Maybe (CursorLocation n))
-> R.Dynamic t AttrMap
-> RH.AppHost
t