Skip to content

Instantly share code, notes, and snippets.

@frasertweedale
frasertweedale / Poly.hs
Last active April 26, 2018 05:17
type coercion with poly-kinded phantom type
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
module Poly where
data Mode = Mode1 | Mode2
data Action ctx a = Action
-- | Coerce the phantoms (poly-kinded)
@frasertweedale
frasertweedale / Foo.hs
Last active October 20, 2017 04:17
switching mode phantom
{-# LANGUAGE ScopedTypeVariables #-}
class HasMode a where
mode :: Proxy a -> Mode
instance HasMode 'BrowseMail where
mode _ = BrowseMail
-- | instantiate this class to specify a valid mode transition
class ModeTransition a b where
./stack install hprotoc
~/.local/bin/hprotoc ./gtfs-realtime.proto
The proto file needed to be hacked in 4 ways:
* comment out/delete the 'syntax = "proto2";' line.
* insert line breaks before end curly braces:
extensions 1000 to 1999;
}