-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | GHCi as a Hex Calculator interactive
--   
--   This package defines operations for an interactive hex-caluclator
--   using GHCi. This is a simple and casual interactive tool like Perl and
--   Excel for daily work.
@package ghci-hexcalc
@version 0.1.0.2


-- | This module defines operations for an interactive hex-caluclator using
--   GHCi. This is a simple and casual interactive tool like Perl and Excel
--   for daily work.
--   
--   Interactive oriented features:
--   
--   <ul>
--   <li>Short-named operators and functions</li>
--   <li>Show values in hexadecimal format by default</li>
--   <li>Suppress type annotation of numeric literals by type
--   inference</li>
--   <li>Postfix-notation available</li>
--   <li>Highlight available</li>
--   </ul>
--   
--   Example of use:
--   
--   <pre>
--   ghci&gt; (1 .&lt;&lt; 16) .| 0xf .&amp; 3
--   0x0000_0000_0001_0003
--   </pre>
--   
--   <pre>
--   ghci&gt; 0xff .@dec
--   "255"
--   </pre>
--   
--   See also <a>web page</a>.
module Data.GHex

-- | Basic type
--   
--   <pre>
--   &gt;&gt;&gt; 255 :: Hex
--   0x0000_0000_0000_00ff
--   </pre>
data Hex

-- | Bitwise "and"
--   
--   <pre>
--   &gt;&gt;&gt; 0x1234 .&amp; 0xff
--   0x0000_0000_0000_0034
--   </pre>
(.&) :: Hex -> Hex -> Hex
infixl 7 .&

-- | Bitwise "or"
--   
--   <pre>
--   &gt;&gt;&gt; 0xf000 .| 0xa
--   0x0000_0000_0000_f00a
--   </pre>
(.|) :: Hex -> Hex -> Hex
infixl 5 .|

-- | Bitwise "xor"
--   
--   <pre>
--   &gt;&gt;&gt; 0xf .^ 0xa
--   0x0000_0000_0000_0005
--   </pre>
(.^) :: Hex -> Hex -> Hex
infixl 6 .^

-- | Bitwise "not"
--   
--   <pre>
--   &gt;&gt;&gt; inv 1
--   0xffff_ffff_ffff_fffe
--   </pre>
inv :: Hex -> Hex

-- | Integer div
--   
--   <pre>
--   &gt;&gt;&gt; 0x1000 ./ 16
--   0x0000_0000_0000_0100
--   </pre>
(./) :: Hex -> Hex -> Hex
infixl 7 ./

-- | Integer mod
--   
--   <pre>
--   &gt;&gt;&gt; 18 .% 16
--   0x0000_0000_0000_0002
--   </pre>
(.%) :: Hex -> Hex -> Hex
infixl 7 .%

-- | Negate
--   
--   <pre>
--   &gt;&gt;&gt; neg 1
--   0xffff_ffff_ffff_ffff
--   </pre>
neg :: Hex -> Hex

-- | Sign extention
--   
--   <pre>
--   &gt;&gt;&gt; signext 0x80 7
--   0xffff_ffff_ffff_ff80
--   
--   &gt;&gt;&gt; signext 0x7fff 15
--   0x0000_0000_0000_7fff
--   </pre>
signext :: Hex -> Int -> Hex

-- | Logical left shift
--   
--   <pre>
--   &gt;&gt;&gt; 1 .&lt;&lt; 16
--   0x0000_0000_0001_0000
--   </pre>
(.<<) :: Hex -> Int -> Hex
infixl 8 .<<

-- | Logical right shift
--   
--   <pre>
--   &gt;&gt;&gt; 0x0f00 .&gt;&gt; 4
--   0x0000_0000_0000_00f0
--   </pre>
(.>>) :: Hex -> Int -> Hex
infixl 8 .>>

-- | Set a bit
--   
--   <pre>
--   &gt;&gt;&gt; bit1 15
--   0x0000_0000_0000_8000
--   </pre>
bit1 :: Int -> Hex

-- | Set bits from n1 to n2
--   
--   <pre>
--   &gt;&gt;&gt; bits 15 8
--   0x0000_0000_0000_ff00
--   </pre>
bits :: Int -> Int -> Hex

-- | Set bits with List
--   
--   <pre>
--   &gt;&gt;&gt; bitList [15, 8, 1]
--   0x0000_0000_0000_8102
--   </pre>
bitList :: [Int] -> Hex

-- | Set a byte
--   
--   <pre>
--   &gt;&gt;&gt; byte1 2
--   0x0000_0000_00ff_0000
--   </pre>
byte1 :: Int -> Hex

-- | Set bytes from n1 to n2
--   
--   <pre>
--   &gt;&gt;&gt; bytes  3 2
--   0x0000_0000_ffff_0000
--   </pre>
bytes :: Int -> Int -> Hex

-- | Mask bits from 0 to n
--   
--   <pre>
--   &gt;&gt;&gt; mask 7
--   0x0000_0000_0000_00ff
--   </pre>
mask :: Int -> Hex

-- | Extract bits from n1 to n2
--   
--   <pre>
--   &gt;&gt;&gt; gets 0xabcd 15 12
--   0x0000_0000_0000_000a
--   </pre>
gets :: Hex -> Int -> Int -> Hex

-- | Replace bits from n1 to n2
--   
--   <pre>
--   &gt;&gt;&gt; puts 0xabcd 15 12 0b111
--   0x0000_0000_0000_7bcd
--   </pre>
puts :: Hex -> Int -> Int -> Hex -> Hex

-- | Extract a bit
--   
--   <pre>
--   &gt;&gt;&gt; getBit1 (bit1 6) 6
--   0x0000_0000_0000_0001
--   </pre>
getBit1 :: Hex -> Int -> Hex

-- | Extract a byte
--   
--   <pre>
--   &gt;&gt;&gt; getByte1 0x12345678 2
--   0x0000_0000_0000_0034
--   </pre>
getByte1 :: Hex -> Int -> Hex

-- | Synonym to gets
getBits :: Hex -> Int -> Int -> Hex

-- | Extract bytes from n1 to n2
--   
--   <pre>
--   &gt;&gt;&gt; getBytes 0x12345678 2 1
--   0x0000_0000_0000_3456
--   </pre>
getBytes :: Hex -> Int -> Int -> Hex

-- | Replace a bit
--   
--   <pre>
--   &gt;&gt;&gt; putBit1 0 7 1
--   0x0000_0000_0000_0080
--   </pre>
putBit1 :: Hex -> Int -> Hex -> Hex

-- | Synonym to puts
putBits :: Hex -> Int -> Int -> Hex -> Hex

-- | Replace bytes from n1 to n2
--   
--   <pre>
--   &gt;&gt;&gt; putBytes 0x12345678 3 2 0xfedc
--   0x0000_0000_fedc_5678
--   </pre>
putBytes :: Hex -> Int -> Int -> Hex -> Hex

-- | Set bits from n1 to n2 of x1
--   
--   <pre>
--   &gt;&gt;&gt; sbits 0x1234 11 8
--   0x0000_0000_0000_1f34
--   </pre>
sbits :: Hex -> Int -> Int -> Hex

-- | Clear bits from n1 to n2 of x1
--   
--   <pre>
--   &gt;&gt;&gt; cbits 0x1234 7 4
--   0x0000_0000_0000_1204
--   </pre>
cbits :: Hex -> Int -> Int -> Hex

-- | Get bit positions asserted with 1
--   
--   <pre>
--   &gt;&gt;&gt; pos1 0x0080
--   [7]
--   </pre>
pos1 :: Hex -> [Int]

-- | Get bit positions asserted with 0
--   
--   <pre>
--   &gt;&gt;&gt; pos0 $ inv 0x0100
--   [8]
--   </pre>
pos0 :: Hex -> [Int]

-- | Get upper and lower boundaries of asserted bits
--   
--   <pre>
--   &gt;&gt;&gt; range1 0x0f000000
--   (27,24)
--   </pre>
range1 :: Hex -> (Int, Int)

-- | Count bit-1
--   
--   <pre>
--   &gt;&gt;&gt; count1 0b11001
--   3
--   </pre>
count1 :: Hex -> Int

-- | Count bit-0
--   
--   <pre>
--   &gt;&gt;&gt; count0 0xf
--   60
--   </pre>
count0 :: Hex -> Int

-- | Reverse bits
--   
--   <pre>
--   &gt;&gt;&gt; bitrev 0x00a1
--   0x8500_0000_0000_0000
--   </pre>
bitrev :: Hex -> Hex

-- | Reverse bytes
--   
--   <pre>
--   &gt;&gt;&gt; byterev 0x12341111cdef
--   0xefcd_1111_3412_0000
--   </pre>
byterev :: Hex -> Hex

-- | Gather bits
--   
--   <pre>
--   &gt;&gt;&gt; gather 0x12345678 0x0ff000f0
--   0x0000_0000_0000_0237
--   </pre>
gather :: Hex -> Hex -> Hex

-- | Scatter bits
--   
--   <pre>
--   &gt;&gt;&gt; scatter 0x12345678 0xff00ff00 0xabcd
--   0x0000_0000_ab34_cd78
--   </pre>
scatter :: Hex -> Hex -> Hex -> Hex

-- | Split bits to List
--   
--   <pre>
--   &gt;&gt;&gt; splitBits 0xa
--   [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0]
--   </pre>
splitBits :: Hex -> [Int]

-- | Split bytes to List
--   
--   <pre>
--   &gt;&gt;&gt; splitBytes 0xff10
--   [0,0,0,0,0,0,255,16]
--   </pre>
splitBytes :: Hex -> [Int]

-- | Merge bits from List
--   
--   <pre>
--   &gt;&gt;&gt; mergeBits [1,0,1,0,0,0,0,0]
--   0x0000_0000_0000_00a0
--   </pre>
mergeBits :: [Int] -> Hex

-- | Merge bytes from List
--   
--   <pre>
--   &gt;&gt;&gt; mergeBytes [0xff, 0x1, 0xa]
--   0x0000_0000_00ff_010a
--   </pre>
mergeBytes :: [Int] -> Hex

-- | Split bits to pair of (length,Hex)
--   
--   <pre>
--   &gt;&gt;&gt; splitSized [2,4,4] 0xabcd
--   [(2,0x0000_0000_0000_0003),(4,0x0000_0000_0000_000c),(4,0x0000_0000_0000_000d)]
--   </pre>
splitSized :: [Int] -> Hex -> [(Int, Hex)]

-- | Merge bits from pair of (length,Hex)
--   
--   <pre>
--   &gt;&gt;&gt; mergeSized [(2,0x3),(4,0xc),(4,0xd)]
--   0x0000_0000_0000_03cd
--   </pre>
mergeSized :: [(Int, Hex)] -> Hex

-- | Concatinate pairs of (length,Hex)
--   
--   <pre>
--   &gt;&gt;&gt; (3,0b101) .++ (2,0b11)
--   (5,0x0000_0000_0000_0017)
--   
--   &gt;&gt;&gt; (4,0xa) .++ (4,0xb) .++ (8,0xcd)
--   (16,0x0000_0000_0000_abcd)
--   
--   &gt;&gt;&gt; (4,0xe) .++ (4,0xf) .@snd
--   0x0000_0000_0000_00ef
--   </pre>
(.++) :: (Int, Hex) -> (Int, Hex) -> (Int, Hex)
infixl 5 .++

-- | Ei: 2^60
exa :: Hex

-- | Pi: 2^50
peta :: Hex

-- | Ti: 2^40
tera :: Hex

-- | Gi: 2^30
giga :: Hex

-- | Mi: 2^20
mega :: Hex

-- | Ki: 2^10
kilo :: Hex

-- | 0x0
zero :: Hex

-- | 0x1
one :: Hex

-- | 0x0
all0 :: Hex

-- | inv 0x0
all1 :: Hex

-- | Bit size of Hex type. It's 64 on x86_64.
hexBitSize :: Int

-- | Number sequence. [hexBitSeq-1, hexBitSeq-2, .. 0]
hexBitSeq :: [Int]

-- | Byte size of Hex type. It's 8 of x86_64.
hexByteSize :: Int

-- | Number sequence. [hexByteSeq-1, hexByteSeq-2, .. 0]
hexByteSeq :: [Int]

-- | Operator for postfix notation (same as Data.Function.(&amp;))
--   
--   <pre>
--   &gt;&gt;&gt; 255 .@hex
--   "0x0000_0000_0000_00ff"
--   
--   &gt;&gt;&gt; 0xf1 .@bin
--   "0b1111_0001"
--   
--   &gt;&gt;&gt; 2^12 .@dec
--   "4096"
--   
--   &gt;&gt;&gt; 4 * giga .@pos1
--   [32]
--   </pre>
--   
--   <pre>
--   0x0 .@color (bits 31 24)
--   0b0000_0000_0000_0000_0000_0000_0000_0000_1111_1111_0000_0000_0000_0000_0000_0000
--                                             ^^^^ ^^^^
--   </pre>
(.@) :: a -> (a -> b) -> b
infixl 0 .@

-- | Hexadecimal formatting with maximum-bit length
hex :: Hex -> String

-- | Hexadecimal formatting with N-bit length
hexN :: Int -> Hex -> String

-- | Hexadecimal formatting with 8-bit length
hex8 :: Hex -> String

-- | Hexadecimal formatting with 16-bit length
hex16 :: Hex -> String

-- | Hexadecimal formatting with 32-bit length
hex32 :: Hex -> String

-- | Hexadecimal formatting with 64-bit length
hex64 :: Hex -> String

-- | Binary formatting with auto-adjusted length
bin :: Hex -> String

-- | Binary formatting with N-bit length
binN :: Int -> Hex -> String

-- | Binary formatting with 8-bit length
bin8 :: Hex -> String

-- | Binary formatting with 16-bit length
bin16 :: Hex -> String

-- | Binary formatting with 32-bit length
bin32 :: Hex -> String

-- | Binary formatting with 64-bit length
bin64 :: Hex -> String

-- | Decimal formatting
dec :: Hex -> String

-- | Decimal formatting with exa unit
decE :: Hex -> String

-- | Decimal formatting with pata unit
decP :: Hex -> String

-- | Decimal formatting with tera unit
decT :: Hex -> String

-- | Decimal formatting with giga unit
decG :: Hex -> String

-- | Decimal formatting with mega unit
decM :: Hex -> String

-- | Decimal formatting with kilo unit
decK :: Hex -> String

-- | Signed decimal formatting
signed :: Hex -> String

-- | Strip strings
strip :: String -> String -> String

-- | Hexadecimal formatting for pair of (length,Hex)
--   
--   <pre>
--   &gt;&gt;&gt; (8,254) .@hexSized
--   "0xfe"
--   </pre>
hexSized :: (Int, Hex) -> String

-- | Binary formatting for pair of (length,Hex)
--   
--   <pre>
--   &gt;&gt;&gt; (8,0x71) .@binSized
--   "0b0111_0001"
--   </pre>
binSized :: (Int, Hex) -> String

-- | Highlight the specified bit
--   
--   <pre>
--   ghci&gt; 0xff .@color (bits 7 4)
--   0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_1111_1111
--                                                                           ^^^^
--   </pre>
--   
--   <pre>
--   ghci&gt; 0xffffffff .@color mega
--   0b0000_0000_0000_0000_0000_0000_0000_0000_1111_1111_1111_1111_1111_1111_1111_1111
--                                                          ^
--   </pre>
--   
--   <pre>
--   ghci&gt; 0 .@color (bitList [54,53,4,3,2])
--   0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000
--                ^^                                                            ^ ^^
--   </pre>
color :: Hex -> Hex -> IO ()

-- | Output value by IO (not String)
--   
--   <pre>
--   &gt;&gt;&gt; 0xf0 .@ppr bin
--   0b1111_0000
--   </pre>
ppr :: (Hex -> String) -> Hex -> IO ()

-- | Input hexadecimal string and convert to Hex type
--   
--   It reads only hexadecimal characters, [0-9a-fA-F]. That is, other
--   characters, such as ',',<tt>:</tt>,<a>-</a>, are ignored. It is useful
--   for reading from various command output, such as od, hexdump and etc.
--   
--   <pre>
--   ghci&gt; inputRawHexIO
--   ff aa  (your input)
--   ghci&gt;x = it
--   ghci&gt;x
--   0x0000_0000_0000_ffaa
--   </pre>
--   
--   <pre>
--   ghci&gt; inputRawHexIO
--   0123:abcd:ffff  (your input)
--   ghci&gt;x = it
--   ghci&gt;x
--   0x0000_0123_abcd_ffff
--   </pre>
inputRawHexIO :: IO Hex

-- | Clear screen with ANSI sequences
cls :: IO ()

-- | Show simple usage
usage :: IO ()
instance Data.Bits.FiniteBits Data.GHex.Hex
instance Data.Bits.Bits Data.GHex.Hex
instance GHC.Real.Integral Data.GHex.Hex
instance GHC.Enum.Bounded Data.GHex.Hex
instance GHC.Real.Real Data.GHex.Hex
instance GHC.Enum.Enum Data.GHex.Hex
instance GHC.Num.Num Data.GHex.Hex
instance GHC.Read.Read Data.GHex.Hex
instance GHC.Classes.Ord Data.GHex.Hex
instance GHC.Classes.Eq Data.GHex.Hex
instance GHC.Show.Show Data.GHex.Hex
