Skip to content

Instantly share code, notes, and snippets.

@raichoo
Created March 10, 2017 14:40
Show Gist options
  • Save raichoo/7e2738734ab2c0968757ff28860b8dc1 to your computer and use it in GitHub Desktop.
Save raichoo/7e2738734ab2c0968757ff28860b8dc1 to your computer and use it in GitHub Desktop.
{-# 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