Permalink
Browse files

- Weird results with Type Families.

  • Loading branch information...
1 parent 401031c commit 7c552a01ca2948e2486dfa00e1b77e4b4f9b7a31 @graninas committed Feb 19, 2014
View
@@ -69,8 +69,8 @@ library
GameLogic.Language.Parsers.RawToken,
GameLogic.Language.Translator,
Test.EitherMonadCallTest,
- Test.TypeFamilyTest,
- Test.TypeFamilyTest2
+ Test.TypeFamilyTest2,
+ Test.TypeFamilyTest1
executable Amoeba
build-depends: base >= 4
@@ -110,6 +110,6 @@ executable Amoeba
GameLogic.Language.Parsers.RawToken,
GameLogic.Language.Translator,
Test.EitherMonadCallTest,
- Test.TypeFamilyTest,
- Test.TypeFamilyTest2
+ Test.TypeFamilyTest2,
+ Test.TypeFamilyTest1
sers.ItemParser
File renamed without changes.
@@ -22,26 +22,47 @@ instance Show (PropertyToken Int) where
instance Show (PropertyToken (Int, Int)) where
show (IntResource _ i) = show i
-class Prop a where
- type Out a :: *
- getProperty :: a -> Out a
+class Show a => Prop a where
+ type Out a b :: *
+ getProperty :: a -> Out a ()
+ printProperty :: a -> String
instance Prop (PropertyToken a) where
- type Out (PropertyToken a) = a
+ type Out (PropertyToken a) a = a
getProperty (IntProperty _ k) = k
getProperty (IntResource _ k) = k
+ printProperty (IntProperty _ k) = show k
+ printProperty (IntResource _ k) = show k
+instance Show (PropertyToken a) where
+ show (IntProperty _ k) = show k
+ show (IntResource _ k) = show k
-token1 = IntProperty "int" 10
-token2 = IntResource "intResource" (10, 1000)
---tokens = [token1, token2]
+data Wrap = forall p. Prop p => MkWrap p
-main = do
- let res1 = getProperty (IntProperty "a" 10)
- let res2 = getProperty (IntResource "b" (20, 20))
+instance Show Wrap where
+ show (MkWrap p) = show p
+
+instance Prop Wrap where
+ --type Out Wrap a = PropertyToken a
+ getProperty (MkWrap p) = undefined
+ printProperty = undefined
+
+type PropList = [Wrap]
- print res1
- print res2
+token1 = MkWrap $ IntProperty "int" 10
+token2 = MkWrap $ IntResource "intResource" (10, 1000)
+tokens = [token1, token2] :: PropList
+
+main = do
+ print $ getProperty (IntProperty "a" 10)
+ print $ getProperty (IntResource "b" (20, 20))
+ print $ map show tokens
+ print tokens
+
+
+ let res1 = getProperty $ head tokens
+ -- putStrLn $ printProperty res1
putStrLn "Ok."

0 comments on commit 7c552a0

Please sign in to comment.