mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
d04d8fd588
commit
fb2de50461
|
@ -80,6 +80,9 @@ instance IsContext c => OptionalVal c Int where
|
|||
LitIntVal x -> fromIntegral x
|
||||
_ -> d
|
||||
|
||||
hasKey :: IsContext c => Id -> [Syntax c] -> Maybe (Syntax c)
|
||||
hasKey k ss = headMay [ e | ListVal [SymbolVal z, e] <- ss, z == k]
|
||||
|
||||
stringLike :: Syntax c -> Maybe String
|
||||
stringLike = \case
|
||||
LitStrVal s -> Just $ Text.unpack s
|
||||
|
|
|
@ -13,9 +13,23 @@ import Data.ByteString.Char8 qualified as BS8
|
|||
import Data.Text qualified as Text
|
||||
import Lens.Micro.Platform
|
||||
|
||||
|
||||
sigilEntries :: forall c m . (c ~ C, IsContext c, MonadUnliftIO m) => MakeDictM c m ()
|
||||
sigilEntries = do
|
||||
|
||||
entry $ bindMatch "hbs2:sigil:sign-pubkey" $ \case
|
||||
[ ListVal (SymbolVal sigil : (hasKey "sign-pubkey" -> Just s)) ] -> do
|
||||
pure s
|
||||
|
||||
_ -> throwIO $ BadFormException @C nil
|
||||
|
||||
|
||||
entry $ bindMatch "hbs2:sigil:encrypt-pubkey" $ \case
|
||||
[ ListVal (SymbolVal sigil : (hasKey "encrypt-pubkey" -> Just s)) ] -> do
|
||||
pure s
|
||||
|
||||
_ -> throwIO $ BadFormException @C nil
|
||||
|
||||
entry $ bindMatch "hbs2:sigil:parse" $ \case
|
||||
[StringLike s] -> do
|
||||
|
||||
|
|
Loading…
Reference in New Issue