Skip to content

Instantly share code, notes, and snippets.

@rblaze
Created March 2, 2015 21:15
Show Gist options
  • Save rblaze/7f60ee81139326e411a7 to your computer and use it in GitHub Desktop.
Save rblaze/7f60ee81139326e411a7 to your computer and use it in GitHub Desktop.
[1 of 1] Compiling ZZ ( hang.hs, hang.o )
hang.hs:19:31:
Could not deduce (Foo' (Base a)) arising from a use of ‘setBase’
from the context (Foo' a)
bound by the type signature for setBase :: Foo' a => a
at hang.hs:16:12-32
In the expression: setBase
In an equation for ‘d’: d = setBase
In the expression:
let
d = setBase
v = setFooBase def d
in v
{-# 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 :: *
getFooBase :: Proxy a -> Maybe (Proxy (Base a))
setFooBase :: a -> Base a -> a
class (Foo a, Foo (Base a)) => Foo' 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