kh: fail to parse invalid belts

Previously we would allow the tags that were added Haskell-side for
union type syntax. Now we explicitly reject those before falling back
to the auto-generated noun parsing logic.
This commit is contained in:
fang 2021-06-17 20:23:38 +02:00
parent 0f6c3c05cd
commit ddf579bd75
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972

View File

@ -306,10 +306,13 @@ $(pure [])
instance FromNoun Bolt where instance FromNoun Bolt where
parseNoun = \case parseNoun = \case
A c -> pure $ Key $ C.chr $ fromIntegral c A c -> pure $ Key $ C.chr $ fromIntegral c
C (A 7955819) _ -> fail "%key not valid bolt tag"
n -> $(deriveFromNounFunc ''Bolt) n n -> $(deriveFromNounFunc ''Bolt) n
instance FromNoun Belt where instance FromNoun Belt where
parseNoun n = Bol <$> parseNoun n <|> $(deriveFromNounFunc ''Belt) n parseNoun = \case
C (A 7106402) _ -> fail "%bol not valid belt tag"
n -> Bol <$> parseNoun n <|> $(deriveFromNounFunc ''Belt) n
instance ToNoun Bolt where instance ToNoun Bolt where
toNoun = \case toNoun = \case