luau/prototyping/FFI/Data/Aeson.agda
2022-02-03 14:16:05 -06:00

23 lines
749 B
Agda

module FFI.Data.Aeson where
open import Agda.Builtin.String using (String)
open import FFI.Data.ByteString using (ByteString)
open import FFI.Data.HaskellString using (HaskellString; pack)
open import FFI.Data.Maybe using (Maybe)
open import FFI.Data.Either using (Either; mapLeft)
{-# FOREIGN GHC import qualified Data.Aeson #-}
postulate Value : Set
{-# COMPILE GHC Value = type Data.Aeson.Value #-}
postulate decode : ByteString Maybe Value
{-# COMPILE GHC decode = Data.Aeson.decodeStrict #-}
postulate eitherHDecode : ByteString Either HaskellString Value
{-# COMPILE GHC eitherHDecode = Data.Aeson.eitherDecodeStrict #-}
eitherDecode : ByteString Either String Value
eitherDecode bytes = mapLeft pack (eitherHDecode bytes)