Created
March 10, 2017 14:40
-
-
Save raichoo/7e2738734ab2c0968757ff28860b8dc1 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
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE CPP #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
module Main where | |
data Test = Test | |
{ testFoo :: Int | |
, testBar :: Bool | |
} | |
type family Key (a :: *) :: * where | |
Key Test = Int | |
data Entity a = | |
PersistField a => Entity | |
{ entityKey :: Key a | |
, entityVal :: a | |
} | |
class PersistField a | |
instance PersistField Test | |
main :: IO () | |
main = do | |
entries <- pure [ (Entity 1 (Test 1 True), Entity 2 (Test 2 False)) ] | |
case entries of | |
x:_ -> do | |
#ifdef BOOM | |
-- Couldn't match expected type ‘Test’ with actual type ‘Test’ | |
let (Entity eId eVal, Entity eId' eVal') = x | |
#else | |
let (Entity eId eVal, Entity eId' (eVal' :: Test)) = x | |
#endif | |
let y = testBar eVal' | |
return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment