-
Notifications
You must be signed in to change notification settings - Fork 251
[ new ] IO buffering, and loops #2367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
da96a88
a8be231
1bf539e
a885335
1cf6f2c
513f564
cd7200f
1138237
e200afc
9ae32c5
4f4bbe0
48dfa71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- IO handles: simple bindings to Haskell types and functions | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --guardedness #-} | ||
|
||
module IO.Handle where | ||
|
||
open import Level using (Level) | ||
open import Data.Unit.Polymorphic.Base using (⊤) | ||
open import IO.Base using (IO; lift; lift′) | ||
|
||
private variable a : Level | ||
|
||
------------------------------------------------------------------------ | ||
-- Re-exporting types and constructors | ||
|
||
open import IO.Primitive.Handle as Prim public | ||
using ( BufferMode | ||
; noBuffering | ||
; lineBuffering | ||
; blockBuffering | ||
; Handle | ||
; stdin | ||
; stdout | ||
; stderr | ||
) | ||
|
||
------------------------------------------------------------------------ | ||
-- Wrapping functions | ||
|
||
hSetBuffering : Handle → BufferMode → IO {a} ⊤ | ||
hSetBuffering hdl bm = lift′ (Prim.hSetBuffering hdl bm) | ||
|
||
hGetBuffering : Handle → IO BufferMode | ||
hGetBuffering hdl = lift (Prim.hGetBuffering hdl) | ||
|
||
hFlush : Handle → IO {a} ⊤ | ||
hFlush hdl = lift′ (Prim.hFlush hdl) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,15 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Primitive IO: simple bindings to Haskell types and functions | ||
-- This module is DEPRECATED. Please use IO.Primitive.Core instead | ||
------------------------------------------------------------------------ | ||
|
||
-- NOTE: the contents of this module should be accessed via `IO`. | ||
|
||
{-# OPTIONS --cubical-compatible #-} | ||
|
||
module IO.Primitive where | ||
|
||
open import Level using (Level) | ||
private | ||
variable | ||
a : Level | ||
A B : Set a | ||
|
||
------------------------------------------------------------------------ | ||
-- The IO monad | ||
|
||
open import Agda.Builtin.IO public | ||
using (IO) | ||
|
||
infixl 1 _>>=_ | ||
|
||
postulate | ||
pure : A → IO A | ||
_>>=_ : IO A → (A → IO B) → IO B | ||
|
||
{-# COMPILE GHC pure = \_ _ -> return #-} | ||
{-# COMPILE GHC _>>=_ = \_ _ _ _ -> (>>=) #-} | ||
{-# COMPILE UHC pure = \_ _ x -> UHC.Agda.Builtins.primReturn x #-} | ||
{-# COMPILE UHC _>>=_ = \_ _ _ _ x y -> UHC.Agda.Builtins.primBind x y #-} | ||
open import IO.Primitive.Core public | ||
|
||
-- Haskell-style alternative syntax | ||
return : A → IO A | ||
return = pure | ||
{-# WARNING_ON_IMPORT | ||
"IO.Primitive was deprecated in v2.1. Use IO.Primitive.Core instead." | ||
#-} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gallais: Are there plans to use Question came up when updating the Agda testsuite to latest std-lib: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No plans on my end. It was a cleanup because having It's named |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Primitive IO: simple bindings to Haskell types and functions | ||
------------------------------------------------------------------------ | ||
|
||
-- NOTE: the contents of this module should be accessed via `IO`. | ||
|
||
{-# OPTIONS --cubical-compatible #-} | ||
|
||
module IO.Primitive.Core where | ||
|
||
open import Level using (Level) | ||
private | ||
variable | ||
a : Level | ||
A B : Set a | ||
|
||
------------------------------------------------------------------------ | ||
-- The IO monad | ||
|
||
open import Agda.Builtin.IO public | ||
using (IO) | ||
|
||
infixl 1 _>>=_ | ||
|
||
postulate | ||
pure : A → IO A | ||
_>>=_ : IO A → (A → IO B) → IO B | ||
|
||
{-# COMPILE GHC pure = \_ _ -> return #-} | ||
{-# COMPILE GHC _>>=_ = \_ _ _ _ -> (>>=) #-} | ||
{-# COMPILE UHC pure = \_ _ x -> UHC.Agda.Builtins.primReturn x #-} | ||
{-# COMPILE UHC _>>=_ = \_ _ _ _ x y -> UHC.Agda.Builtins.primBind x y #-} | ||
|
||
-- Haskell-style alternative syntax | ||
return : A → IO A | ||
return = pure |
Uh oh!
There was an error while loading. Please reload this page.