Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,7 @@ Non-backwards compatible changes
This is needed for level-increasing functors like `IO : Set l → Set (suc l)`.

* `RawApplicative` is now `RawFunctor + pure + _<*>_` and `RawMonad` is now
`RawApplicative` + `_>>=_` and so `return` is not used anywhere anymore.
This fixes the conflict with `case_return_of` (#356)
`RawApplicative` + `_>>=_`.
This reorganisation means in particular that the functor/applicative of a monad
are not computed using `_>>=_`. This may break proofs.

Expand Down
4 changes: 4 additions & 0 deletions src/Effect/Applicative.agda
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ record RawApplicative (F : Set f → Set g) : Set (suc f ⊔ g) where
zip : F A → F B → F (A × B)
zip = zipWith _,_

-- Haskell-style alternative name for pure
return : A → F A
return = pure

-- backwards compatibility: unicode variants
_⊛_ : F (A → B) → F A → F B
_⊛_ = _<*>_
Expand Down
17 changes: 13 additions & 4 deletions src/IO/Primitive.agda
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,29 @@

module IO.Primitive where

open import Agda.Builtin.IO
open import Level using (Level)
private
variable
a : Level
A B : Set a

------------------------------------------------------------------------
-- The IO monad

open import Agda.Builtin.IO public using (IO)
open import Agda.Builtin.IO public
using (IO)

infixl 1 _>>=_

postulate
pure : ∀ {a} {A : Set a} → A → IO A
_>>=_ : ∀ {a b} {A : Set a} {B : Set b} → IO A → (A → IO B) → IO B
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