text to atom, etc

This commit is contained in:
pilfer-pandex 2019-10-02 15:06:26 -07:00
parent a5a36f94f2
commit 5331c5be87
3 changed files with 16 additions and 10 deletions

View File

@ -23,7 +23,7 @@ type Jet = Noun -> Noun
type JetName = Atom
type Hash = Int
pattern FastAtom = 9999
pattern FastAtom = 1953718630 -- %fast
pattern FastHint id n =
C (A 11)
(C
@ -92,18 +92,18 @@ instance Dashboard Careboard where
n@(FastHint nm _) -> case namely nm of
Just (h, j) -> do
when (h /= hash n) $
putStrLn ("careboard: jet " <> tshow nm <> " should have its hash "
putStrLn ("careboard: jet " <> tshowA nm <> " should have its hash "
<> "updated from " <> tshow h <> " to " <> tshow (hash n))
get <&> lookup nm >>= \case
Just n' ->
when (n' /= n) $
putStrLn ("careboard: jet hint " <> tshow nm <> " has been "
putStrLn ("careboard: jet hint " <> tshowA nm <> " has been "
<> "detected on unequal formulae " <> tshow n
<> " and " <> tshow n' <> ", which is very bad")
Nothing -> modify' (insertMap nm n)
pure (Just j)
Nothing -> do
putStrLn ("careboard: unmatched fast hint: " ++ tshow nm)
putStrLn ("careboard: unmatched fast hint: " ++ tshowA nm)
pure $ byHash $ hash n
n -> pure $ byHash $ hash n

View File

@ -3,6 +3,8 @@ module SimpleNoun where
import ClassyPrelude
import Numeric.Natural
import qualified Noun as N
type Atom = Natural
type Noun = Tree Atom
@ -41,6 +43,16 @@ loob = \case
True -> yes
False -> no
textToAtom :: Text -> Atom
textToAtom t = case N.textToUtf8Atom t of
N.A a -> a
showA :: Atom -> String
showA a = show (N.A a)
tshowA :: Atom -> Text
tshowA = pack . showA
-- | Tree address
type Axis = Atom

View File

@ -4,7 +4,6 @@ import ClassyPrelude
import Prelude (foldr1)
import SimpleNoun
import qualified Noun as N
import qualified Untyped.Hoon as H
import Untyped.Parser -- remove after we've moved the CST type
@ -53,8 +52,3 @@ hone = go
tr (PatTar, c) = (H.Wild, go c)
tr (PatTag s, c) = (H.Exact (A $ textToAtom s), go c)
textToAtom :: Text -> Atom
textToAtom t = case N.textToUtf8Atom t of
N.A a -> a