luau/prototyping/FFI/IO.agda
Alan Jeffrey 041838a942
Prototyping a small subset of Luau in Agda (#350)
* First cut reading JSON into an Agda representation of Luau syntax
2022-02-08 18:26:58 -06:00

34 lines
999 B
Agda
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module FFI.IO where
open import Agda.Builtin.IO using (IO)
open import Agda.Builtin.Unit using ()
open import Agda.Builtin.String using (String)
open import FFI.Data.HaskellString using (HaskellString; pack ; unpack)
infixl 1 _>>=_
infixl 1 _>>_
postulate
return : {a} {A : Set a} A IO A
_>>=_ : {a b} {A : Set a} {B : Set b} IO A (A IO B) IO B
fmap : {a b} {A : Set a} {B : Set b} (A B) IO A IO B
{-# COMPILE GHC return = \_ _ -> return #-}
{-# COMPILE GHC _>>=_ = \_ _ _ _ -> (>>=) #-}
{-# COMPILE GHC fmap = \_ _ _ _ -> fmap #-}
postulate getHContents : IO HaskellString
{-# COMPILE GHC getHContents = getContents #-}
postulate putHStrLn : HaskellString IO
{-# COMPILE GHC putHStrLn = putStrLn #-}
getContents : IO String
getContents = fmap pack getHContents
putStrLn : String IO
putStrLn txt = putHStrLn (unpack txt)
_>>_ : {a} {A : Set a} IO IO A IO A
a >> b = a >>= (λ _ b )