Skip to content

Commit 9584c1c

Browse files
authored
[ fix #1128 ] Use the BUILTIN Maybe (#1220)
1 parent bb965ca commit 9584c1c

File tree

8 files changed

+49
-40
lines changed

8 files changed

+49
-40
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ matrix:
140140
mv html/* . ;
141141
fi
142142
- if [[ $TRAVIS_BRANCH = "experimental" ]]; then
143-
mkdir -p experimental ;
143+
mkdir -p experimental ;
144144
mv html/* experimental/ ;
145145
fi
146146

@@ -194,4 +194,4 @@ matrix:
194194
- stack ${ARGS} exec -- AllNonAsciiChars
195195
before_cache:
196196
- find ${TRAVIS_BUILD_DIR}/.stack-work -type f -name '*.agdai' -delete
197-
after_success: []
197+
after_success: []

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@ Bug-fixes
2121
Non-backwards compatible changes
2222
--------------------------------
2323

24-
* The `n` argument to `_⊜_` in `Tactic.RingSolver.NonReflective` has been made implict rather than explicit.
24+
* The `n` argument to `_⊜_` in `Tactic.RingSolver.NonReflective` has
25+
been made implict rather than explicit.
2526

2627
* `Data.Empty.Polymorphic` and `Data.Unit.Polymorphic` were rewritten
2728
to explicitly use `Lift` rather that defining new types. This means
2829
that these are now compatible with `` and `` from the rest of the
2930
library. This allowed them to be used in the rest of library where
3031
explicit `Lift` was used.
3132

33+
* `Data.Maybe.Base` now re-exports the definition of `Maybe` given by
34+
`Agda.Builtin.Maybe`. The `Foreign.Haskell` modules and definitions
35+
corresponding to `Maybe` have been removed.
36+
3237
* The representation of reflected syntax in `Reflection.Term` and
3338
`Reflection.Pattern` has been updated to match the new
3439
representation used in Agda 2.6.2. Specifically, the following changes were made:

GNUmakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test: Everything.agda check-whitespace
1313
$(AGDA) -i. -isrc README.agda
1414

1515
check-whitespace:
16-
cabal exec -- fix-whitespace --check
16+
cabal v1-exec -- fix-whitespace --check
1717

1818
setup: Everything.agda
1919

@@ -23,8 +23,8 @@ Everything.agda:
2323
# command `cabal install` is needed by cabal-install <= 2.4.*. I did
2424
# not found any problem running both commands with different versions
2525
# of cabal-install. See Issue #1001.
26-
cabal clean && cabal build && cabal install
27-
cabal exec -- GenerateEverything
26+
cabal v1-clean && cabal v1-build && cabal v1-install
27+
cabal v1-exec -- GenerateEverything
2828

2929
.PHONY: listings
3030
listings: Everything.agda

README/Foreign/Haskell.agda

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ private
3232
a : Level
3333
A : Set a
3434

35-
-- Here we use the FFI version of Maybe and Pair.
35+
-- Here we use the FFI version of Pair.
3636

3737
postulate
38-
primUncons : List A FFI.Maybe (FFI.Pair A (List A))
39-
primCatMaybes : List (FFI.Maybe A) List A
38+
primUncons : List A Maybe (FFI.Pair A (List A))
39+
primCatMaybes : List (Maybe A) List A
4040
primTestChar : Char Bool
4141
primIntEq : Int Int Bool
4242

@@ -53,21 +53,19 @@ postulate
5353

5454
{-# COMPILE GHC primIntEq = (==) #-}
5555

56-
-- We however want to use the notion of Maybe and Pair internal to
57-
-- the standard library. For this we use `coerce` to take use back
58-
-- to the types we are used to.
56+
-- We however want to use the notion of Pair internal to the standard library.
57+
-- For this we use `coerce` to take use back to the types we are used to.
5958

60-
-- The typeclass mechanism uses the coercion rules for Maybe and Pair,
61-
-- as well as the knowledge that natural numbers are represented as
62-
-- integers.
63-
-- We additionally benefit from the congruence rules for List, Char,
59+
-- The typeclass mechanism uses the coercion rules for Pair, as well as the
60+
-- knowledge that natural numbers are represented as integers.
61+
-- We additionally benefit from the congruence rules for List, Maybe, Char,
6462
-- Bool, and a reflexivity principle for variable A.
6563

6664
uncons : List A Maybe (A × List A)
6765
uncons = coerce primUncons
6866

6967
catMaybes : List (Maybe A) List A
70-
catMaybes = coerce primCatMaybes
68+
catMaybes = primCatMaybes
7169

7270
testChar : Char Bool
7371
testChar = coerce primTestChar

src/Data/Maybe/Base.agda

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ private
2929
------------------------------------------------------------------------
3030
-- Definition
3131

32-
data Maybe (A : Set a) : Set a where
33-
nothing : Maybe A
34-
just : (x : A) Maybe A
35-
32+
open import Agda.Builtin.Maybe public
33+
using (Maybe; just; nothing)
3634

3735
------------------------------------------------------------------------
3836
-- Some operations

src/Foreign/Haskell.agda

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ open import Foreign.Haskell.Either public
2828
; fromForeign to fromForeignEither
2929
)
3030

31-
------------------------------------------------------------------------
32-
-- Maybe
33-
34-
open import Foreign.Haskell.Maybe public
35-
renaming
36-
( toForeign to toForeignMaybe
37-
; fromForeign to fromForeignMaybe
38-
)
39-
4031
------------------------------------------------------------------------
4132
-- DEPRECATED NAMES
4233
------------------------------------------------------------------------

src/Foreign/Haskell/Coerce.agda

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import Data.Maybe.Base as STD
4141
import Data.Product as STD
4242
import Data.Sum as STD
4343

44-
import Foreign.Haskell.Maybe as FFI
4544
import Foreign.Haskell.Pair as FFI
4645
import Foreign.Haskell.Either as FFI
4746

@@ -107,14 +106,6 @@ instance
107106
-- can be converted to their FFI equivalents which are bound to actual
108107
-- Haskell types.
109108

110-
-- Maybe
111-
112-
maybe-toFFI : Coercible₁ a b STD.Maybe FFI.Maybe
113-
maybe-toFFI = TrustMe
114-
115-
maybe-fromFFI : Coercible₁ a b FFI.Maybe STD.Maybe
116-
maybe-fromFFI = TrustMe
117-
118109
-- Product
119110

120111
pair-toFFI : Coercible₂ a b c d STD._×_ FFI.Pair
@@ -134,6 +125,11 @@ instance
134125
-- We follow up with purely structural rules for builtin data types which
135126
-- already have known low-level representations.
136127

128+
-- Maybe
129+
130+
coerce-maybe : Coercible₁ a b STD.Maybe STD.Maybe
131+
coerce-maybe = TrustMe
132+
137133
-- List
138134

139135
coerce-list : Coercible₁ a b STD.List STD.List

src/Foreign/Haskell/Maybe.agda

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------
22
-- The Agda standard library
33
--
4-
-- Which Maybe type which calls out to Haskell via the FFI
4+
-- This module is DEPRECATED. Please use the builtin Maybe instead.
55
------------------------------------------------------------------------
66

77
{-# OPTIONS --without-K #-}
@@ -36,3 +36,24 @@ toForeign nothing = nothing
3636
fromForeign : Maybe A Data.Maybe A
3737
fromForeign (just x) = just x
3838
fromForeign nothing = nothing
39+
40+
41+
{-# WARNING_ON_IMPORT
42+
"Warning: Foreign.Haskell.Maybe was deprecated in v1.4.
43+
Maybe is now an Agda builtin and does not need library support."
44+
#-}
45+
46+
{-# WARNING_ON_USAGE Maybe
47+
"Warning: Foreign.Haskell.Maybe's Maybe was deprecated in v1.4.
48+
Maybe is now an Agda builtin and does not need library support."
49+
#-}
50+
51+
{-# WARNING_ON_USAGE toForeign
52+
"Warning: toForeign was deprecated in v1.4.
53+
Maybe is now an Agda builtin and does not need library support."
54+
#-}
55+
56+
{-# WARNING_ON_USAGE fromForeign
57+
"Warning: fromForeign was deprecated in v1.4.
58+
Maybe is now an Agda builtin and does not need library support."
59+
#-}

0 commit comments

Comments
 (0)