Created
March 2, 2015 21:15
-
-
Save rblaze/7f60ee81139326e411a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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