Skip to content

Instantly share code, notes, and snippets.

@deech
Last active August 29, 2015 14:10
Show Gist options
  • Save deech/9d4eb66acd18b74cab6a to your computer and use it in GitHub Desktop.
Save deech/9d4eb66acd18b74cab6a to your computer and use it in GitHub Desktop.
{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
data A = A
data B = B
data Found a = Found a
data NotFound = NotFound
type family F x
type instance F A = Found (Int -> Int)
type family FindF x where
FindF f = CheckFoundF (F f)
type family CheckFoundF res where
CheckFoundF (Found f) = f
CheckFoundF notfound = NotFound
test :: FindF B
test = undefined
{-
*Main> test
<interactive>:150:1:
No instance for (Show (CheckFoundF (F B))) <==== Should be (Show NotFound)
arising from a use of ‘print’
In a stmt of an interactive GHCi command: print it
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment