Simplify some instances.
authorIlya Portnov <portnov84@rambler.ru>
Sun, 2 Oct 2011 13:12:42 +0000 (19:12 +0600)
committerIlya Portnov <portnov84@rambler.ru>
Sun, 2 Oct 2011 13:12:42 +0000 (19:12 +0600)
JVM/Builder/Monad.hs
JVM/ClassFile.hs
JVM/Converter.hs

index 85aaa5e11b9ea565169d35fad3c5608cb83f519e..01e93f16c675b756c092765c0d563f74f2c9d1c7 100644 (file)
@@ -72,7 +72,7 @@ lookupPool :: Constant Direct -> Pool Direct -> Maybe Word16
 lookupPool c pool =
   fromIntegral `fmap` findIndex (== c) (M.elems pool)
 
-addNT :: Binary (Signature a) => NameType a -> Generate Word16
+addNT :: HasSignature a => NameType a -> Generate Word16
 addNT (NameType name sig) = do
   let bsig = encode sig
   x <- addItem (CNameType name bsig)
index 0359320592a9ab1cf10aa464f795423ade56ebf4..2b7e1e7f965add890444ee4ad1511439c4121cbf 100644 (file)
@@ -128,7 +128,8 @@ data AccessFlag =
   deriving (Eq, Show, Ord, Enum)
 
 -- | Fields and methods have signatures.
-class HasSignature a where
+class (Binary (Signature a), Show (Signature a), Eq (Signature a))
+    => HasSignature a where
   type Signature a
 
 instance HasSignature Field where
@@ -142,12 +143,12 @@ data NameType a = NameType {
   ntName :: B.ByteString,
   ntSignature :: Signature a }
 
-instance Show (Signature a) => Show (NameType a) where
+instance (HasSignature a) => Show (NameType a) where
   show (NameType n t) = toString n ++ ": " ++ show t
 
-deriving instance Eq (Signature a) => Eq (NameType a)
+deriving instance HasSignature a => Eq (NameType a)
 
-instance (Binary (Signature a)) => Binary (NameType a) where
+instance HasSignature a => Binary (NameType a) where
   put (NameType n t) = putLazyByteString n >> put t
 
   get = NameType <$> get <*> get
index 777bac62b85ab2816406339553cde633ecbc7c30..5993d54388026e22a4a484cc4376c1d3f2aac902 100644 (file)
@@ -175,7 +175,7 @@ constantPoolArray ps = pool
 
     n = fromIntegral $ M.size ps
 
-    convertNameType :: (HasSignature a, Binary (Signature a)) => Word16 -> NameType a
+    convertNameType :: (HasSignature a) => Word16 -> NameType a
     convertNameType i =
       let (CNameType n s) = pool ! i
       in  NameType n (decode s)