memorable-bits-0.1.0.0: Generate human memorable strings from binary data.

Safe HaskellNone
LanguageHaskell2010

Data.Memorable.Internal

Synopsis

Documentation

data a :| b Source #

Choice between two sub patterns. It's not safe to use this directly. Use .| instead.

Also, if you are parsing back rendered phrases, you must make sure that the selected word is enough to choose a side. That is, a and b must have unique first words. This is NOT checked, as it causes a HUGE compile-time performance hit. If we can make it performant it may be checked one day.

Instances

(MemRender k1 a, MemRender k b) => MemRender * ((:|) k k1 a b) Source # 

Methods

render :: Proxy ((k :| k1) a b) a -> Coding Get String Source #

parser :: Proxy ((k :| k1) a b) a -> ExceptT String (State ([String], Coding PutM ())) () Source #

data a :- b Source #

Append two patterns together by doing the first, then the second. See also .-

Instances

(MemRender k1 a, MemRender k b) => MemRender * ((:-) k k1 a b) Source # 

Methods

render :: Proxy ((k :- k1) a b) a -> Coding Get String Source #

parser :: Proxy ((k :- k1) a b) a -> ExceptT String (State ([String], Coding PutM ())) () Source #

(.|) :: Depth a ~ Depth b => Proxy a -> Proxy b -> Proxy (a :| b) Source #

Proxy version of :|. It also constraints the two subpatterns to being the same depth. Use this to add an extra bit to the pattern depth, where the bit chooses to proceed down either the left or right side.

>>> :set -XTypeApplications
>>> :set -XDataKinds
>>> import Data.Word
>>> let myPattern = padHex (Proxy @"foo" .| Proxy @"bar")
>>> renderMemorable myPattern (0x00 :: Word8)
"bar-00"
>>> renderMemorable myPattern (0xff :: Word8)
"foo-7f"

See also ToTree

WARNING: Each side of the split must be unique. See the warning about :|.

(.-) :: Proxy a -> Proxy b -> Proxy (a :- b) Source #

Proxy version of :-. The new pattern depth is the sum of the two parts. >>> import Data.Word >>> import Data.Memorable.Theme.Words >>> let myPattern = words8 .- words8 >>> renderMemorable myPattern (0xabcd :: Word16) "ages-old"

type Number nt n = NumberWithOffset nt n 0 Source #

Captures n bits and converts them to a string via the nt ("number type") argument. See Dec, Hex.

data NumberWithOffset nt n o Source #

Captures n bits and convertes them to a string via the nt ("number type") argument after adding the offset. See Dec, Hex.

Instances

data PadTo nt n a Source #

Pad the a argument out to length n by taking the remaining bits and converting them via nt (see Dec and Hex). If padding is required, it is separated by a dash.

See padHex and padDec for convinence functions.

Instances

(MemRender k1 a, (<=) (Depth k1 a) n, NumberRender k nt, KnownNat n, KnownNat (Depth k1 a)) => MemRender * (PadTo k1 k nt n a) Source # 

Methods

render :: Proxy (PadTo k1 k nt n a) a -> Coding Get String Source #

parser :: Proxy (PadTo k1 k nt n a) a -> ExceptT String (State ([String], Coding PutM ())) () Source #

type family ToTreeH (a :: [k]) :: [*] where ... Source #

Equations

ToTreeH '[] = '[] 
ToTreeH (x1 ': (x2 ': (x3 ': (x4 ': (x5 ': (x6 ': (x7 ': (x8 ': (x9 ': (x10 ': (x11 ': (x12 ': (x13 ': (x14 ': (x15 ': (x16 ': (x17 ': (x18 ': (x19 ': (x20 ': (x21 ': (x22 ': (x23 ': (x24 ': (x25 ': (x26 ': (x27 ': (x28 ': (x29 ': (x30 ': (x31 ': (x32 ': (x33 ': (x34 ': (x35 ': (x36 ': (x37 ': (x38 ': (x39 ': (x40 ': (x41 ': (x42 ': (x43 ': (x44 ': (x45 ': (x46 ': (x47 ': (x48 ': (x49 ': (x50 ': (x51 ': (x52 ': (x53 ': (x54 ': (x55 ': (x56 ': (x57 ': (x58 ': (x59 ': (x60 ': (x61 ': (x62 ': (x63 ': (x64 ': xs)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) = ToTree64 (x1 ': (x2 ': (x3 ': (x4 ': (x5 ': (x6 ': (x7 ': (x8 ': (x9 ': (x10 ': (x11 ': (x12 ': (x13 ': (x14 ': (x15 ': (x16 ': (x17 ': (x18 ': (x19 ': (x20 ': (x21 ': (x22 ': (x23 ': (x24 ': (x25 ': (x26 ': (x27 ': (x28 ': (x29 ': (x30 ': (x31 ': (x32 ': (x33 ': (x34 ': (x35 ': (x36 ': (x37 ': (x38 ': (x39 ': (x40 ': (x41 ': (x42 ': (x43 ': (x44 ': (x45 ': (x46 ': (x47 ': (x48 ': (x49 ': (x50 ': (x51 ': (x52 ': (x53 ': (x54 ': (x55 ': (x56 ': (x57 ': (x58 ': (x59 ': (x60 ': (x61 ': (x62 ': (x63 ': (x64 ': xs)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) 
ToTreeH as = ToTree2 as 

type family ToTree2 (as :: [k]) :: [*] where ... Source #

Equations

ToTree2 '[] = '[] 
ToTree2 (a ': (b ': bs)) = (a :| b) ': ToTree2 bs 

type family ToTree64 (as :: [k]) :: [*] where ... Source #

Equations

ToTree64 '[] = '[] 
ToTree64 (x1 ': (x2 ': (x3 ': (x4 ': (x5 ': (x6 ': (x7 ': (x8 ': (x9 ': (x10 ': (x11 ': (x12 ': (x13 ': (x14 ': (x15 ': (x16 ': (x17 ': (x18 ': (x19 ': (x20 ': (x21 ': (x22 ': (x23 ': (x24 ': (x25 ': (x26 ': (x27 ': (x28 ': (x29 ': (x30 ': (x31 ': (x32 ': (x33 ': (x34 ': (x35 ': (x36 ': (x37 ': (x38 ': (x39 ': (x40 ': (x41 ': (x42 ': (x43 ': (x44 ': (x45 ': (x46 ': (x47 ': (x48 ': (x49 ': (x50 ': (x51 ': (x52 ': (x53 ': (x54 ': (x55 ': (x56 ': (x57 ': (x58 ': (x59 ': (x60 ': (x61 ': (x62 ': (x63 ': (x64 ': xs)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) = ((((((x1 :| x2) :| (x3 :| x4)) :| ((x5 :| x6) :| (x7 :| x8))) :| (((x9 :| x10) :| (x11 :| x12)) :| ((x13 :| x14) :| (x15 :| x16)))) :| ((((x17 :| x18) :| (x19 :| x20)) :| ((x21 :| x22) :| (x23 :| x24))) :| (((x25 :| x26) :| (x27 :| x28)) :| ((x29 :| x30) :| (x31 :| x32))))) :| (((((x33 :| x34) :| (x35 :| x36)) :| ((x37 :| x38) :| (x39 :| x40))) :| (((x41 :| x42) :| (x43 :| x44)) :| ((x45 :| x46) :| (x47 :| x48)))) :| ((((x49 :| x50) :| (x51 :| x52)) :| ((x53 :| x54) :| (x55 :| x56))) :| (((x57 :| x58) :| (x59 :| x60)) :| ((x61 :| x62) :| (x63 :| x64)))))) ': ToTree64 xs 

type family Len (a :: [Symbol]) :: Nat where ... Source #

Equations

Len (a ': (b ': (c ': (d ': (e ': (f ': (g ': (h ': (i ': (j ': (k ': (l ': (m ': (n ': (o ': (p ': (q ': (r ': (s ': (t ': (u ': (v ': (w ': (x ': (y ': (z ': as)))))))))))))))))))))))))) = Len as + 26 
Len (a ': as) = Len as + 1 
Len '[] = 0 

type family ToTree (a :: [k]) :: * where ... Source #

Convert a '[Symbol] to a balanced tree of :|. Each result has equal probability of occurring. Length of the list must be a power of two. This is very useful for converting long lists of words into a usable pattern.

>>> :kind! ToTree '["a", "b", "c", "d"]
ToTree '["a", "b", "c", "d"] :: *
= ("a" :| "b") :| ("c" :| "d")

Equations

ToTree (x ': (y ': '[])) = x :| y 
ToTree '[x :| y] = x :| y 
ToTree xs = ToTree (ToTreeH xs) 

type family Concat (a :: [k]) :: * where ... Source #

Equations

Concat (a ': (b ': '[])) = a :- b 
Concat (a ': (b ': cs)) = (a :- b) :- Concat cs 

type family Intersperse (a :: k) (b :: [k]) :: [k] where ... Source #

Equations

Intersperse a '[] = '[] 
Intersperse a (b ': '[]) = b ': '[] 
Intersperse a (b ': cs) = b ': (a ': Intersperse a cs) 

type family LeftSide (a :: *) :: * where ... Source #

Useful to prevent haddock from expanding the type.

Equations

LeftSide (a :| b) = a 

type family RightSide (a :: *) :: * where ... Source #

Useful to prevent haddock from expanding the type.

Equations

RightSide (a :| b) = b 

leftSide :: Proxy (a :| b) -> Proxy a Source #

Shrink a branching pattern by discarding the right hand side.

rightSide :: Proxy (a :| b) -> Proxy b Source #

Shrink a branching pattern by discarding the left hand side.

type family BitsInPowerOfTwo (a :: Nat) :: Nat where ... Source #

type family Find a as :: Bool where ... Source #

Equations

Find a '[] = False 
Find a (a ': as) = True 
Find a (b ': (a ': as)) = True 
Find a (c ': (b ': (a ': as))) = True 
Find a (d ': (c ': (b ': (a ': as)))) = True 
Find a (e ': (d ': (c ': (b ': (a ': as))))) = True 
Find a (f ': (e ': (d ': (c ': (b ': (a ': as)))))) = True 
Find a (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))) = True 
Find a (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))) = True 
Find a (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))))) = True 
Find a (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))))) = True 
Find a (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))))))) = True 
Find a (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))))))) = True 
Find a (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))))))))) = True 
Find a (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))))))))) = True 
Find a (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))))))))))) = True 
Find a (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))))))))))) = True 
Find a (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))))))))))))) = True 
Find a (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))))))))))))) = True 
Find a (s ': (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))))))))))))))) = True 
Find a (t ': (s ': (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))))))))))))))) = True 
Find a (u ': (t ': (s ': (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))))))))))))))))) = True 
Find a (v ': (u ': (t ': (s ': (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))))))))))))))))) = True 
Find a (w ': (v ': (u ': (t ': (s ': (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))))))))))))))))))) = True 
Find a (x ': (w ': (v ': (u ': (t ': (s ': (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))))))))))))))))))) = True 
Find a (y ': (x ': (w ': (v ': (u ': (t ': (s ': (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as))))))))))))))))))))))))) = True 
Find a (z ': (y ': (x ': (w ': (v ': (u ': (t ': (s ': (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (a ': as)))))))))))))))))))))))))) = True 
Find a (z ': (y ': (x ': (w ': (v ': (u ': (t ': (s ': (r ': (q ': (p ': (o ': (n ': (m ': (l ': (k ': (j ': (i ': (h ': (g ': (f ': (e ': (d ': (c ': (b ': (aa ': as)))))))))))))))))))))))))) = Find a as 
Find a (b ': as) = Find a as 

type family HasDups (a :: [Symbol]) :: Bool where ... Source #

Equations

HasDups (a ': as) = Find a as || HasDups as 
HasDups '[] = False 

type family NoDups (a :: [Symbol]) :: Constraint where ... Source #

Equations

NoDups (a ': as) = If (Find a as) (TypeError (Text "Pattern is ambiguous because of " :<>: ShowType a)) (NoDups as) 
NoDups '[] = () 

type family Depth (a :: k) :: Nat where ... Source #

Determines the number of bits that a pattern will consume.

Equations

Depth (a :: Symbol) = 0 
Depth (a :- b) = Depth a + Depth b 
Depth (a :| b) = 1 + Depth a 
Depth (NumberWithOffset nt a o) = a 
Depth (PadTo nt n a) = n 

getDepth :: forall a. KnownNat (Depth a) => Proxy a -> Integer Source #

Get the depth of a pattern as a value-level Integer. >>> :set -XTypeApplications -XDataKinds >>> getDepth (Proxy "foo" .| Proxy "bar") 1

type family NTimes (n :: Nat) (p :: *) where ... Source #

Equations

NTimes 1 a = a 
NTimes n a = a :- NTimes (n - 1) a 

five :: Proxy a -> Proxy ((((a :- a) :- a) :- a) :- a) Source #

Put five things next to each other. Same as using .- repeatedly

four :: Proxy a -> Proxy (((a :- a) :- a) :- a) Source #

Put four things next to each other.

three :: Proxy a -> Proxy ((a :- a) :- a) Source #

Put three things next to each other.

two :: Proxy a -> Proxy (a :- a) Source #

Put two things next to each other.

padHex :: forall n a. Proxy a -> Proxy (PadTo Hex n a) Source #

Pad this pattern out with hex digits. Useful when you want some human readability, but also want full coverage of the data. See Hex for details.

>>> import Data.Word
>>> import Data.Memorable.Theme.Fantasy
>>> renderMemorable (padHex rpgWeapons) (0xdeadbeef01020304 :: Word64)
"sacred-club-of-ghoul-charming-eef01020304"

The depth to pad to is the first type-level argument. If you have TypeApplications set, you can use it like `padHex @256` to be explicit.

padDec :: forall n a. Proxy a -> Proxy (PadTo Dec n a) Source #

Pad with decimal digits. See padHex and Dec for details. This does not pad with 0's

hex4 :: Proxy (Number Hex 4) Source #

A single hex number consuming 4 bits (with leading 0's).

hex8 :: Proxy (Number Hex 8) Source #

A single hex number consuming 8 bits (with leading 0's).

hex16 :: Proxy (Number Hex 16) Source #

A single hex number consuming 16 bits (with leading 0's).

hex32 :: Proxy (Number Hex 32) Source #

A single hex number consuming 32 bits (with leading 0's).

hex :: Proxy (Number Hex n) Source #

A single hex number consuming n bits, which it will try and figure out from context (with leading 0's). Using TypeApplications allows you to specify the size directly, `hex @32 == hex32`.

dec4 :: Proxy (Number Dec 4) Source #

A single decimal number consuming 4 bits (no leading 0's)

dec8 :: Proxy (Number Dec 8) Source #

A single decimal number consuming 8 bits (no leading 0's)

dec16 :: Proxy (Number Dec 16) Source #

A single decimal number consuming 16 bits (no leading 0's)

dec32 :: Proxy (Number Dec 32) Source #

A single decimal number consuming 32 bits (no leading 0's)

dec :: Proxy (Number Dec n) Source #

A single decimal number consuming n bits, which it will try and figure out from context (no leading 0's). Using TypeApplications allows you to specify the size directly, `dec @32 == hex32`.

class MemRender a where Source #

The class that implements the main rendering function.

Minimal complete definition

render, parser

Instances

KnownSymbol a => MemRender Symbol a Source # 
(NumberRender k nt, KnownNat a, KnownNat o) => MemRender * (NumberWithOffset k nt a o) Source # 
(MemRender k1 a, MemRender k b) => MemRender * ((:-) k k1 a b) Source # 

Methods

render :: Proxy ((k :- k1) a b) a -> Coding Get String Source #

parser :: Proxy ((k :- k1) a b) a -> ExceptT String (State ([String], Coding PutM ())) () Source #

(MemRender k1 a, MemRender k b) => MemRender * ((:|) k k1 a b) Source # 

Methods

render :: Proxy ((k :| k1) a b) a -> Coding Get String Source #

parser :: Proxy ((k :| k1) a b) a -> ExceptT String (State ([String], Coding PutM ())) () Source #

(MemRender k1 a, (<=) (Depth k1 a) n, NumberRender k nt, KnownNat n, KnownNat (Depth k1 a)) => MemRender * (PadTo k1 k nt n a) Source # 

Methods

render :: Proxy (PadTo k1 k nt n a) a -> Coding Get String Source #

parser :: Proxy (PadTo k1 k nt n a) a -> ExceptT String (State ([String], Coding PutM ())) () Source #

parseMemorable :: (Memorable a, MemRender p, MemLen a ~ Depth p) => Proxy p -> String -> Maybe a Source #

Turn a memorable string back into a Memorable value.

rerender :: (MemRender a, MemRender b, Depth a ~ Depth b) => Proxy a -> Proxy b -> String -> Maybe String Source #

Convert a memorable string into a different memorable string.

Useful for things like taking an existing md5, and converting it into a memorable one.

>>> :set -XTypeApplications -XDataKinds
>>> import Data.Memorable.Theme.Words
>>> rerender hex (padHex @128 $ four words10) "2d4fbe4d5db8748c931b85c551d03360"
Just "lurk-lash-atop-hole-b8748c931b85c551d03360"

class NumberRender n where Source #

Class for capturing how to render numbers.

Minimal complete definition

renderNumber, readNumber

data Dec Source #

Render numbers as decimal numbers. Does not pad.

data Hex Source #

Render numbers as hexadecimal numbers. Pads with 0s.

class Memorable a where Source #

Class for all things that can be converted to memorable strings. See renderMemorable for how to use.

Minimal complete definition

renderMem, parserMem

Associated Types

type MemLen a :: Nat Source #

Methods

renderMem :: MonadPut m => a -> Coding m () Source #

parserMem :: MonadGet m => Coding m a Source #

Instances

Memorable Int8 Source # 

Associated Types

type MemLen Int8 :: Nat Source #

Memorable Int16 Source # 

Associated Types

type MemLen Int16 :: Nat Source #

Memorable Int32 Source # 

Associated Types

type MemLen Int32 :: Nat Source #

Memorable Int64 Source # 

Associated Types

type MemLen Int64 :: Nat Source #

Memorable Word8 Source # 

Associated Types

type MemLen Word8 :: Nat Source #

Memorable Word16 Source # 

Associated Types

type MemLen Word16 :: Nat Source #

Memorable Word32 Source # 

Associated Types

type MemLen Word32 :: Nat Source #

Memorable Word64 Source # 

Associated Types

type MemLen Word64 :: Nat Source #

Memorable Word256 Source # 

Associated Types

type MemLen Word256 :: Nat Source #

Memorable Int256 Source # 

Associated Types

type MemLen Int256 :: Nat Source #

Memorable Word224 Source # 

Associated Types

type MemLen Word224 :: Nat Source #

Memorable Int224 Source # 

Associated Types

type MemLen Int224 :: Nat Source #

Memorable Word192 Source # 

Associated Types

type MemLen Word192 :: Nat Source #

Memorable Int192 Source # 

Associated Types

type MemLen Int192 :: Nat Source #

Memorable Word160 Source # 

Associated Types

type MemLen Word160 :: Nat Source #

Memorable Int160 Source # 

Associated Types

type MemLen Int160 :: Nat Source #

Memorable Word128 Source # 

Associated Types

type MemLen Word128 :: Nat Source #

Memorable Int128 Source # 

Associated Types

type MemLen Int128 :: Nat Source #

Memorable Word96 Source # 

Associated Types

type MemLen Word96 :: Nat Source #

Memorable Int96 Source # 

Associated Types

type MemLen Int96 :: Nat Source #

Memorable IP4 Source #
>>> renderMemorable threeWordsFor32Bits (ip4FromOctets 127 0 0 1)
"shore-pick-pets"

Associated Types

type MemLen IP4 :: Nat Source #

Memorable IP6 Source # 

Associated Types

type MemLen IP6 :: Nat Source #

Memorable (Digest Blake2b_512) Source # 
Memorable (Digest Blake2bp_512) Source # 
Memorable (Digest Blake2s_224) Source # 
Memorable (Digest Blake2s_256) Source # 
Memorable (Digest Blake2sp_224) Source # 
Memorable (Digest Blake2sp_256) Source # 
Memorable (Digest Keccak_224) Source # 
Memorable (Digest Keccak_256) Source # 
Memorable (Digest Keccak_384) Source # 
Memorable (Digest Keccak_512) Source # 
Memorable (Digest MD2) Source # 

Associated Types

type MemLen (Digest MD2) :: Nat Source #

Memorable (Digest MD4) Source # 

Associated Types

type MemLen (Digest MD4) :: Nat Source #

Memorable (Digest MD5) Source #
>>> :set -XOverloadedStrings
>>> import Data.ByteString
>>> import Crypto.Hash
>>> let myPattern = padHex (four flw10)
>>> renderMemorable myPattern (hash ("anExample" :: ByteString) :: Digest MD5)
"bark-most-gush-tuft-1b7155ab0dce3ecb4195fc"

Associated Types

type MemLen (Digest MD5) :: Nat Source #

Memorable (Digest RIPEMD160) Source # 
Memorable (Digest SHA1) Source # 

Associated Types

type MemLen (Digest SHA1) :: Nat Source #

Memorable (Digest SHA224) Source # 

Associated Types

type MemLen (Digest SHA224) :: Nat Source #

Memorable (Digest SHA256) Source # 

Associated Types

type MemLen (Digest SHA256) :: Nat Source #

Memorable (Digest SHA3_224) Source # 

Associated Types

type MemLen (Digest SHA3_224) :: Nat Source #

Memorable (Digest SHA3_256) Source # 

Associated Types

type MemLen (Digest SHA3_256) :: Nat Source #

Memorable (Digest SHA3_384) Source # 

Associated Types

type MemLen (Digest SHA3_384) :: Nat Source #

Memorable (Digest SHA3_512) Source # 

Associated Types

type MemLen (Digest SHA3_512) :: Nat Source #

Memorable (Digest SHA384) Source # 

Associated Types

type MemLen (Digest SHA384) :: Nat Source #

Memorable (Digest SHA512) Source # 

Associated Types

type MemLen (Digest SHA512) :: Nat Source #

Memorable (Digest SHA512t_224) Source # 
Memorable (Digest SHA512t_256) Source # 
Memorable (Digest Skein256_224) Source # 
Memorable (Digest Skein256_256) Source # 
Memorable (Digest Skein512_224) Source # 
Memorable (Digest Skein512_256) Source # 
Memorable (Digest Skein512_384) Source # 
Memorable (Digest Skein512_512) Source # 
Memorable (Digest Tiger) Source # 

Associated Types

type MemLen (Digest Tiger) :: Nat Source #

Memorable (Digest Whirlpool) Source # 
(Memorable a, Memorable b) => Memorable (a, b) Source # 

Associated Types

type MemLen (a, b) :: Nat Source #

Methods

renderMem :: MonadPut m => (a, b) -> Coding m () Source #

parserMem :: MonadGet m => Coding m (a, b) Source #

(Memorable a, Memorable b, Memorable c) => Memorable (a, b, c) Source # 

Associated Types

type MemLen (a, b, c) :: Nat Source #

Methods

renderMem :: MonadPut m => (a, b, c) -> Coding m () Source #

parserMem :: MonadGet m => Coding m (a, b, c) Source #

(Memorable a, Memorable b, Memorable c, Memorable d) => Memorable (a, b, c, d) Source # 

Associated Types

type MemLen (a, b, c, d) :: Nat Source #

Methods

renderMem :: MonadPut m => (a, b, c, d) -> Coding m () Source #

parserMem :: MonadGet m => Coding m (a, b, c, d) Source #

(Memorable a, Memorable b, Memorable c, Memorable d, Memorable e) => Memorable (a, b, c, d, e) Source # 

Associated Types

type MemLen (a, b, c, d, e) :: Nat Source #

Methods

renderMem :: MonadPut m => (a, b, c, d, e) -> Coding m () Source #

parserMem :: MonadGet m => Coding m (a, b, c, d, e) Source #

memBitSize :: forall a. KnownNat (MemLen a) => Proxy a -> Int Source #

testMemLen :: forall a. (KnownNat (MemLen a), Memorable a) => a -> Bool Source #

Use this with tasty-quickcheck (or your prefered testing framework) to make sure you aren't lying about MemLen.

testProperty "MemLen Word8" $ forAll (arbitrary :: Gen Word8) testMemLen

renderMemorable :: (MemRender p, Depth p ~ MemLen a, Memorable a) => Proxy p -> a -> String Source #

This is the function to use when you want to turn your values into a memorable strings.

>>> import Data.Word
>>> import Data.Memorable.Theme.Words
>>> let myPattern = words8 .- words8
>>> renderMemorable myPattern (0x0123 :: Word16)
"cats-bulk"

renderMemorableByteString :: MemRender a => Proxy a -> ByteString -> String Source #

Render a ByteString as a more memorable String.

renderRandom :: forall a. (MemRender a, KnownNat (Depth a)) => Proxy a -> IO String Source #

Generate a random string.

renderHashable32 :: (MemRender p, Depth p ~ 32, Hashable a) => Proxy p -> a -> String Source #

Render any Hashable value as a 32 bit pattern.

renderHashable16 :: (MemRender p, Depth p ~ 16, Hashable a) => Proxy p -> a -> String Source #

Render any Hashable value as a 16 bit pattern.

renderHashable8 :: (MemRender p, Depth p ~ 8, Hashable a) => Proxy p -> a -> String Source #

Render any Hashable value as a 8 bit pattern.