X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=JVM%2FCommon.hs;h=1b0e5eb022e012076f6605712d9e2538aefe0b57;hb=368ce628bdf8a7fa772a6860aed12f00baea3906;hp=7271e469eabf7cb603af0c54c92125aea4f4c427;hpb=736d0e920159839bf89dff10cc27583b91fc7216;p=hs-java.git diff --git a/JVM/Common.hs b/JVM/Common.hs index 7271e46..1b0e5eb 100644 --- a/JVM/Common.hs +++ b/JVM/Common.hs @@ -1,19 +1,26 @@ {-# LANGUAGE TypeFamilies, StandaloneDeriving, FlexibleInstances, FlexibleContexts, UndecidableInstances #-} --- | This module declares `high-level' data types for Java classes, methods etc. -module JVM.Common where +-- | This module declares some commonly used functions and instances. +module JVM.Common + (toCharList, + poolSize, + (!), + showListIx, + byteString + ) where -import Codec.Binary.UTF8.String hiding (encode, decode) import Data.Binary import Data.Binary.Put import qualified Data.ByteString.Lazy as B -import Data.Char -import Data.String import qualified Data.Map as M +import Data.Default import JVM.ClassFile -instance IsString B.ByteString where - fromString s = B.pack $ map (fromIntegral . ord) $ encodeString s +instance Default B.ByteString where + def = B.empty + +instance Default Word16 where + def = 0 toCharList :: B.ByteString -> [Int] toCharList bstr = map fromIntegral $ B.unpack bstr