urbit-hob

Haskell utilities for phonetic base wrangling.
Log | Files | Refs | README | LICENSE

commit 218140fc3eda00777d03513d7be9f556796790ac
parent 4b7e0353ed696f432da4d7db3300de1daf2f6978
Author: Jared Tobin <jared@jtobin.io>
Date:   Mon, 23 Dec 2019 09:00:16 -0330

ob, muk, co: minor cleaning

Diffstat:
Mlib/Urbit/Ob/Co.hs | 16++++++++--------
Mlib/Urbit/Ob/Muk.hs | 2+-
Mlib/Urbit/Ob/Ob.hs | 4++--
3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/Urbit/Ob/Co.hs b/lib/Urbit/Ob/Co.hs @@ -128,7 +128,7 @@ fromPatq = C.roll . BS.reverse . unPatq -- >>> renderPatp (patp 15663360) -- "~nidsut-tomdun" renderPatp :: Patp -> T.Text -renderPatp (Patp bs) = render' Padding LongSpacing bs +renderPatp (Patp bs) = render Padding LongSpacing bs -- | Render a \@p value as 'T.Text'. -- @@ -137,7 +137,7 @@ renderPatp (Patp bs) = render' Padding LongSpacing bs -- >>> renderPatq (patq 15663360) -- "~mun-marzod" renderPatq :: Patq -> T.Text -renderPatq (Patq bs) = render' NoPadding ShortSpacing bs +renderPatq (Patq bs) = render NoPadding ShortSpacing bs -- | Parse a \@p value existing as 'T.Text'. -- @@ -172,8 +172,8 @@ data Spacing = deriving Eq -- General-purpose renderer. -render' :: Padding -> Spacing -> BS.ByteString -> T.Text -render' padding spacing bs = +render :: Padding -> Spacing -> BS.ByteString -> T.Text +render padding spacing bs = T.cons '~' . snd . BS.foldr alg (0 :: Int, mempty) @@ -246,10 +246,10 @@ prefix = V.unsafeIndex prefixes . fromIntegral fromPrefix :: T.Text -> Either T.Text Word8 fromPrefix syl = case V.findIndex (== syl) prefixes of - Nothing -> Left (msg syl) + Nothing -> Left msg Just x -> Right (fromIntegral x :: Word8) where - msg s = "urbit-hob (fromPrefix): invalid prefix \"" <> s <> "\"" + msg = "urbit-hob (fromPrefix): invalid prefix \"" <> syl <> "\"" suffixes :: V.Vector T.Text suffixes = V.fromList @@ -281,8 +281,8 @@ suffix = V.unsafeIndex suffixes . fromIntegral fromSuffix :: T.Text -> Either T.Text Word8 fromSuffix syl = case V.findIndex (== syl) suffixes of - Nothing -> Left (msg syl) + Nothing -> Left msg Just x -> Right (fromIntegral x :: Word8) where - msg s = "urbit-hob (fromSuffix): invalid suffix \"" <> s <> "\"" + msg = "urbit-hob (fromSuffix): invalid suffix \"" <> syl <> "\"" diff --git a/lib/Urbit/Ob/Muk.hs b/lib/Urbit/Ob/Muk.hs @@ -27,5 +27,5 @@ muk :: Word32 -> Word32 -> Word32 muk syd key = M.murmur3 syd kee where kee = chr lo `B8.cons` chr hi `B8.cons` mempty lo = fromIntegral (key .&. 0xFF) - hi = fromIntegral (key .&. 0xFF00 `div` 256) + hi = fromIntegral (key .&. 0xFF00 `div` 0x0100) diff --git a/lib/Urbit/Ob/Ob.hs b/lib/Urbit/Ob/Ob.hs @@ -63,7 +63,7 @@ fynd = loop where -- Note that this has been adjusted from the reference paper in order to -- support some legacy behaviour. feis :: Word32 -> Word32 -feis = capFe 4 65535 65536 0xFFFFFFFF capF +feis = capFe 4 0xFFFF 0x10000 0xFFFFFFFF capF -- | Reverse 'feis'. -- @@ -72,7 +72,7 @@ feis = capFe 4 65535 65536 0xFFFFFFFF capF -- Note that this has been adjusted from the reference paper in order to -- support some legacy behaviour. tail :: Word32 -> Word32 -tail = capFen 4 65535 65536 0xFFFFFFFF capF +tail = capFen 4 0xFFFF 0x10000 0xFFFFFFFF capF -- | A PRF for j in [0, .., 3] capF :: Int -> Word32 -> Word32