urbit-hob-0.2.0: Hoon-style atom manipulation and printing functions

Copyright(c) 2019 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@jtobin.io>
Stabilityunstable
Portabilityghc
Safe HaskellNone
LanguageHaskell2010

Urbit.Ob.Co

Description

General functions for atom printing.

Roughly analogous to the +co arm in hoon.hoon.

Synopsis

Documentation

data Patp Source #

Hoon's @p encoding.

This encoding is an obfuscated representation of some underlying number, but a pronounceable, memorable, and unique one.

The representation exists for any natural number, but it's typically used only for naming Azimuth points, and thus normal 32-bit Urbit ships.

(It's also used for naming comets, i.e. self-signed 128-bit Urbit ships.)

Instances
Eq Patp Source # 
Instance details

Defined in Urbit.Ob.Co

Methods

(==) :: Patp -> Patp -> Bool #

(/=) :: Patp -> Patp -> Bool #

Show Patp Source # 
Instance details

Defined in Urbit.Ob.Co

Methods

showsPrec :: Int -> Patp -> ShowS #

show :: Patp -> String #

showList :: [Patp] -> ShowS #

patp :: Natural -> Patp Source #

Convert a Natural to @p.

>>> patp 0
~zod
>>> patp 256
~marzod
>>> patp 65536
~dapnep-ronmyl
>>> patp 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
~fipfes-fipfes-fipfes-fipfes--fipfes-fipfes-fipfes-fipfes

fromPatp :: Patp -> Natural Source #

Convert a @p value to its corresponding Natural.

>>> let zod = patp 0
>>> fromPatp zod
0

render :: Patp -> Text Source #

Render a @p value as Text.

>>> render (patp 0)
"~zod"
>>> render (patp 15663360)
"~nidsut-tomdun"

parse :: Text -> Either Text Patp Source #

Parse a @p value existing as Text.

>>> parse "~nidsut-tomdun"
Right ~nidsut-tomdun
> parse "~fipfes-fipfes-fipfes-doznec"
Right ~fipfes-fipfes-fipfes-doznec