Skip to content

Instantly share code, notes, and snippets.

@ch3pjw
ch3pjw / TyFam.hs
Created January 30, 2019 16:28
Unpacking using type family
{-# LANGUAGE TypeFamilies #-}
module Main where
type family Sneaky a where
Sneaky (Maybe x) = x -> IO (Maybe x)
go :: Sneaky (Maybe Char)
go = return . Just
@ch3pjw
ch3pjw / Main.hs
Created January 24, 2019 15:48
Preventing return of a resource from a bracket
{-# LANGUAGE
RankNTypes
#-}
module Main where
data MyResource a = MyResource {unMyResource :: String}
withMyResource :: String -> (forall a. MyResource a -> IO r) -> IO r
@ch3pjw
ch3pjw / Test.hs
Created May 16, 2018 14:00
Trying to handle constraints flexibly with existentials
{-# LANGUAGE
ConstraintKinds
, ExistentialQuantification
, FlexibleContexts
, FlexibleInstances
, KindSignatures
, MultiParamTypeClasses
, Rank2Types
, ScopedTypeVariables
, TypeApplications
@ch3pjw
ch3pjw / Test.hs
Created May 12, 2018 23:41
Mashing together type-class constraints inside a parameterised existential datatype
{-# LANGUAGE
ConstraintKinds
, ExistentialQuantification
, FlexibleInstances
, MultiParamTypeClasses
, TypeOperators
, UndecidableSuperClasses
#-}
module Test where
@ch3pjw
ch3pjw / gist:a49b45b0506c093abea2
Created February 12, 2016 15:30
Convox linked container gets no HOST env var
With the following `docker-compose.yml`:
sonar:
build: ./sonar
environment:
- SONAR_DB_URL
ports:
- 9000
links:
- sonar_db
@ch3pjw
ch3pjw / gist:5e2d1522802a84d6db13
Created February 12, 2016 14:59
`convox start` vs `docker-compose up` stdout interleaving
`docker-compose up` of a simple `echo hello world` container gives me
Recreating dockerrig_sonar_1
Attaching to dockerrig_sonar_1
sonar_1 | hello world
whereas `convox start` of the same environment gives me
RUNNING: docker build -t vdlpyobjtp /Users/paul/src/wipro/docker-rig/sonar
Sending build context to Docker daemon 4.096 kB