Skip to content

Commit 9352cf5

Browse files
MatthewDaggittandreasabel
authored andcommitted
Restore 'return' as an alias for 'pure' (#2164)
1 parent daa4437 commit 9352cf5

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

CHANGELOG.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,7 @@ Non-backwards compatible changes
774774
This is needed for level-increasing functors like `IO : Set l → Set (suc l)`.
775775
776776
* `RawApplicative` is now `RawFunctor + pure + _<*>_` and `RawMonad` is now
777-
`RawApplicative` + `_>>=_` and so `return` is not used anywhere anymore.
778-
This fixes the conflict with `case_return_of` (#356)
777+
`RawApplicative` + `_>>=_`.
779778
This reorganisation means in particular that the functor/applicative of a monad
780779
are not computed using `_>>=_`. This may break proofs.
781780

src/Effect/Applicative.agda

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ record RawApplicative (F : Set f → Set g) : Set (suc f ⊔ g) where
5353
zip : F A F B F (A × B)
5454
zip = zipWith _,_
5555

56+
-- Haskell-style alternative name for pure
57+
return : A F A
58+
return = pure
59+
5660
-- backwards compatibility: unicode variants
5761
_⊛_ : F (A B) F A F B
5862
_⊛_ = _<*>_

src/IO/Primitive.agda

+13-4
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,29 @@
1010

1111
module IO.Primitive where
1212

13-
open import Agda.Builtin.IO
13+
open import Level using (Level)
14+
private
15+
variable
16+
a : Level
17+
A B : Set a
1418

1519
------------------------------------------------------------------------
1620
-- The IO monad
1721

18-
open import Agda.Builtin.IO public using (IO)
22+
open import Agda.Builtin.IO public
23+
using (IO)
1924

2025
infixl 1 _>>=_
2126

2227
postulate
23-
pure : {a} {A : Set a} A IO A
24-
_>>=_ : {a b} {A : Set a} {B : Set b} IO A (A IO B) IO B
28+
pure : A IO A
29+
_>>=_ : IO A (A IO B) IO B
2530

2631
{-# COMPILE GHC pure = \_ _ -> return #-}
2732
{-# COMPILE GHC _>>=_ = \_ _ _ _ -> (>>=) #-}
2833
{-# COMPILE UHC pure = \_ _ x -> UHC.Agda.Builtins.primReturn x #-}
2934
{-# COMPILE UHC _>>=_ = \_ _ _ _ x y -> UHC.Agda.Builtins.primBind x y #-}
35+
36+
-- Haskell-style alternative syntax
37+
return : A IO A
38+
return = pure

0 commit comments

Comments
 (0)