Skip to content

Instantly share code, notes, and snippets.

FROM debian:jessie
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y ghc cabal-install libghc-hakyll-dev --fix-missing
RUN cabal update && cabal install hakyll-4.5.4.0 --reinstall
ENV PATH /root/.cabal/bin:$PATH
@kosmikus
kosmikus / gist:c411abf4390dfd1adbcc16f6b665eb43
Created June 30, 2016 10:46
count-conflicts-2 on universe
[ghc-7.0.4-plain] andres@neli:~/repos/universe (git:master) $ rm -rf dist-newstyle && ~/bin/cabal-cc2 new-configure --max-backjumps=-1 --dry-run +RTS -t
Resolving dependencies...
In order, the following would be built (use -v for more details):
base-orphans-0.5.4
binary-0.8.2.1
deepseq-1.3.0.2
Cabal-1.20.0.4
deepseq-1.4.2.0
bytestring-builder-0.10.8.1.0
stm-2.4.4.1
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.Either
type PermApi1 =
"a" :> "b" :> "c" :> Get '[JSON] ()
:<|> "b" :> "a" :> "c" :> Get '[JSON] ()
:<|> "a" :> "c" :> "b" :> Get '[JSON] ()
:<|> "c" :> "a" :> "b" :> Get '[JSON] ()
:<|> "b" :> "c" :> "a" :> Get '[JSON] ()
:<|> "c" :> "b" :> "a" :> Get '[JSON] ()
Output:
<root>
|- greet
| v
| `-*
| v
| `- <dyn>
| `-*
`- hello
`- <dyn>
`-*
@kosmikus
kosmikus / TypeError.hs
Created January 9, 2016 16:33
Strange TypeError behaviour
{-# LANGUAGE TypeInType, TypeFamilies, UndecidableInstances #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Kind
import GHC.TypeLits (TypeError, ErrorMessage(..))
type family Resolve (t :: Type -> Type) :: Type -> Type where
Resolve _ = TypeError (Text "ERROR")
-- testOK :: Resolve [] Int
@kosmikus
kosmikus / Fold.hs
Created December 3, 2015 08:09
Regensburg Haskell Meetup December 2015
{-# LANGUAGE GADTs, InstanceSigs, TypeFamilies #-}
{-# LANGUAGE FlexibleContexts, RankNTypes, PatternSynonyms #-}
module Fold where
import Prelude hiding (foldr, take, all)
---------------------------------------------------------------------------
-- "foldr" on lists, Maybe, Bool, and binary trees
---------------------------------------------------------------------------
module FromInteger
import Data.Vect
-- This is inspired by the fromInteger definition for Fin.
IntegerToElem :
DecEq a => (i : Integer) -> (x : a) -> (xs : Vect n a)
-> Maybe (Elem x xs)
IntegerToElem i x [] = Nothing
{-# LANGUAGE DeriveGeneric, FlexibleInstances, ScopedTypeVariables, FlexibleContexts, DataKinds, TypeFamilies #-}
module SwaggerExample where
import Data.Proxy
import qualified GHC.Generics as G
import Generics.SOP
data Todo = Todo {
created :: Int
, description :: String
@kosmikus
kosmikus / TinyServant.hs
Created November 1, 2015 20:30
Implementation of a small Servant-like DSL
{-# LANGUAGE DataKinds, PolyKinds, TypeOperators #-}
{-# LANGUAGE TypeFamilies, FlexibleInstances, ScopedTypeVariables #-}
{-# LANGUAGE InstanceSigs #-}
module TinyServant where
import Control.Applicative
import GHC.TypeLits
import Text.Read
import Data.Time