Added more bindings from Data.Aeson

This commit is contained in:
ajeffrey@roblox.com 2022-02-03 14:49:33 -06:00
parent 4fbca71dcd
commit dbbe6788f5
4 changed files with 34 additions and 3 deletions

View file

@ -1,16 +1,34 @@
module FFI.Data.Aeson where module FFI.Data.Aeson where
open import Agda.Builtin.Bool using (Bool)
open import Agda.Builtin.String using (String) open import Agda.Builtin.String using (String)
open import FFI.Data.ByteString using (ByteString) open import FFI.Data.ByteString using (ByteString)
open import FFI.Data.HaskellString using (HaskellString; pack) open import FFI.Data.HaskellString using (HaskellString; pack)
open import FFI.Data.Maybe using (Maybe) open import FFI.Data.Maybe using (Maybe)
open import FFI.Data.Either using (Either; mapLeft) open import FFI.Data.Either using (Either; mapLeft)
open import FFI.Data.Scientific using (Scientific)
open import FFI.Data.Vector using (Vector)
{-# FOREIGN GHC import qualified Data.Aeson #-} {-# FOREIGN GHC import qualified Data.Aeson #-}
{-# FOREIGN GHC import qualified Data.Aeson.KeyMap #-}
postulate Value : Set postulate KeyMap : Set Set
{-# COMPILE GHC Value = type Data.Aeson.Value #-} {-# POLARITY KeyMap ++ #-}
{-# COMPILE GHC KeyMap = type Data.Aeson.KeyMap.KeyMap #-}
data Value : Set where
object : KeyMap Value Value
array : Vector Value Value
string : String Value
number : Scientific Value
bool : Bool Value
null : Value
Object = KeyMap Value
Array = Vector Value
{-# COMPILE GHC Value = data Data.Aeson.Value (Data.Aeson.Object|Data.Aeson.Array|Data.Aeson.String|Data.Aeson.Number|Data.Aeson.Bool|Data.Aeson.Null) #-}
postulate decode : ByteString Maybe Value postulate decode : ByteString Maybe Value
{-# COMPILE GHC decode = Data.Aeson.decodeStrict #-} {-# COMPILE GHC decode = Data.Aeson.decodeStrict #-}

View file

@ -0,0 +1,6 @@
module FFI.Data.Scientific where
{-# FOREIGN GHC import qualified Data.Scientific #-}
postulate Scientific : Set
{-# COMPILE GHC Scientific = type Data.Scientific.Scientific #-}

View file

@ -0,0 +1,7 @@
module FFI.Data.Vector where
{-# FOREIGN GHC import qualified Data.Vector #-}
postulate Vector : Set Set
{-# POLARITY Vector ++ #-}
{-# COMPILE GHC Vector = type Data.Vector.Vector #-}

View file

@ -11,7 +11,7 @@ First install Haskell and Agda.
Install dependencies: Install dependencies:
``` ```
cabal update cabal update
cabal install --lib aeson cabal install --lib aeson scientific vector
``` ```
Then compile Then compile