Skip to content

Instantly share code, notes, and snippets.

@rblaze
Created March 2, 2015 07:51
Show Gist options
  • Save rblaze/ba10cb8693a937f77ebd to your computer and use it in GitHub Desktop.
Save rblaze/ba10cb8693a937f77ebd to your computer and use it in GitHub Desktop.
{-# LANGUAGE ScopedTypeVariables, TypeFamilies, FlexibleContexts #-}
module ZZ where
import Data.Proxy
class Def a where
def :: a
class Def a => Foo a where
type Base a :: *
class (Foo a, Foo (Base a)) => Foo' a where
getFooBase :: Proxy a -> Maybe (Proxy (Base a))
setFooBase :: a -> Base a -> a
setBase :: forall a. Foo' a => a
setBase = case getFooBase (Proxy :: Proxy a) of
Nothing -> def
Just p -> let d = setBase
v = setFooBase def d
in v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment