Skip to content

Commit f2bd3aa

Browse files
Sized types will no longer be safe in 2.6.2 (#1465)
* Sized types will no longer be safe in 2.6.2 * Add removal of --safe from modules using sized types to changelog * Split out `stream` into `Data.Nat.PseudoRandom.LCG.Unsafe` Co-authored-by: = <[email protected]>
1 parent 94fd103 commit f2bd3aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+132
-80
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ Non-backwards compatible changes
6464
and `Reflection.Argument.Quantity`. The constructors of the types
6565
`Modality` and `Quantity` are reexported from `Reflection`.
6666

67+
#### Sized types
68+
69+
* Sized types are no longer considered safe in Agda 2.6.2. As a
70+
result, all modules that use `--sized-types` no longer have the
71+
`--safe` flag. For a full list of affected modules, refer to the
72+
relevant [commit](https://github.com/agda/agda-stdlib/pull/1465/files#diff-e1c0e3196e4cea6ff808f5d2906031a7657130e10181516206647b83c7014584R91-R131.)
73+
74+
* In order to keep `Data.Nat.Pseudorandom.LCG` safe, the function
75+
`stream` that relies on the newly unsafe `Codata` modules has
76+
been moved to the new module `Data.Nat.Pseudorandom.LCG.Unsafe`.
77+
6778
#### Other
6879

6980
* `Data.Maybe.Base` now re-exports the definition of `Maybe` given by

GenerateEverything.hs

+54-28
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ unsafeModules = map modToFile
5959
, "System.Exit.Primitive"
6060
, "Text.Pretty.Core"
6161
, "Text.Pretty"
62-
]
62+
] ++ sizedTypesModules
6363

6464
isUnsafeModule :: FilePath -> Bool
6565
isUnsafeModule fp =
@@ -98,6 +98,55 @@ isWithKModule =
9898
\ fp -> unqualifiedModuleName fp == "WithK"
9999
|| fp `elem` withKModules
100100

101+
sizedTypesModules :: [FilePath]
102+
sizedTypesModules = map modToFile
103+
[ "Codata.Cofin"
104+
, "Codata.Cofin.Literals"
105+
, "Codata.Colist"
106+
, "Codata.Colist.Bisimilarity"
107+
, "Codata.Colist.Categorical"
108+
, "Codata.Colist.Properties"
109+
, "Codata.Conat"
110+
, "Codata.Conat.Bisimilarity"
111+
, "Codata.Conat.Literals"
112+
, "Codata.Conat.Properties"
113+
, "Codata.Covec"
114+
, "Codata.Covec.Bisimilarity"
115+
, "Codata.Covec.Categorical"
116+
, "Codata.Covec.Instances"
117+
, "Codata.Covec.Properties"
118+
, "Codata.Cowriter"
119+
, "Codata.Cowriter.Bisimilarity"
120+
, "Codata.Delay"
121+
, "Codata.Delay.Bisimilarity"
122+
, "Codata.Delay.Categorical"
123+
, "Codata.Delay.Properties"
124+
, "Codata.M"
125+
, "Codata.M.Bisimilarity"
126+
, "Codata.M.Properties"
127+
, "Codata.Stream"
128+
, "Codata.Stream.Bisimilarity"
129+
, "Codata.Stream.Categorical"
130+
, "Codata.Stream.Instances"
131+
, "Codata.Stream.Properties"
132+
, "Codata.Thunk"
133+
, "Data.Container"
134+
, "Data.Container.Any"
135+
, "Data.Container.FreeMonad"
136+
, "Data.Nat.PseudoRandom.LCG.Unsafe"
137+
, "Data.Tree.Rose"
138+
, "Data.Tree.Rose.Properties"
139+
, "Data.Trie"
140+
, "Data.Trie.NonEmpty"
141+
, "Relation.Unary.Sized"
142+
, "Size"
143+
, "Text.Tree.Linear"
144+
]
145+
146+
isSizedTypesModule :: FilePath -> Bool
147+
isSizedTypesModule =
148+
\ fp -> fp `elem` sizedTypesModules
149+
101150
unqualifiedModuleName :: FilePath -> String
102151
unqualifiedModuleName = dropExtension . takeFileName
103152

@@ -139,10 +188,9 @@ extractHeader mod = extract
139188
, "Please see other existing files or consult HACKING.md."
140189
]
141190

142-
-- | A crude classifier looking for lines containing options & trying to guess
143-
-- whether the safe file is using either @--guardedness@ or @--sized-types@
191+
-- | A crude classifier looking for lines containing options
144192

145-
data Status = Deprecated | Unsafe | Safe | SafeGuardedness | SafeSizedTypes
193+
data Status = Deprecated | Unsafe | Safe
146194
deriving (Eq)
147195

148196
classify :: FilePath -> [String] -> [String] -> Status
@@ -156,8 +204,6 @@ classify fp hd ls
156204
-- And then perform the actual classification
157205
| deprecated = Deprecated
158206
| isUnsafe = Unsafe
159-
| guardedness = SafeGuardedness
160-
| sizedtypes = SafeSizedTypes
161207
| safe = Safe
162208
-- We know that @not (isUnsafe || safe)@, all cases are covered
163209
| otherwise = error "IMPOSSIBLE"
@@ -169,8 +215,6 @@ classify fp hd ls
169215
isUnsafe = isUnsafeModule fp
170216

171217
-- based on detected OPTIONS
172-
guardedness = option "--guardedness"
173-
sizedtypes = option "--sized-types"
174218
safe = option "--safe"
175219
withK = option "--with-K"
176220
withoutK = option "--without-K"
@@ -223,9 +267,7 @@ checkFilePaths cat fps = forM_ fps $ \ fp -> do
223267
-- Collecting all non-Core library files, analysing them and generating
224268
-- 4 files:
225269
-- Everything.agda all the modules
226-
-- EverythingSafe.agda all the safe modules (may be incompatible)
227-
-- EverythingSafeGuardedness.agda all the safe modules using --guardedness
228-
-- EverythingSafeSizedTypes.agda all the safe modules using --sized-types
270+
-- EverythingSafe.agda all the safe modules
229271

230272
main = do
231273
args <- getArgs
@@ -254,27 +296,11 @@ main = do
254296

255297
writeFileUTF8 (safeOutputFile ++ ".agda") $
256298
unlines [ header
257-
, "{-# OPTIONS --guardedness --sized-types #-}\n"
299+
, "{-# OPTIONS --safe --guardedness #-}\n"
258300
, mkModule safeOutputFile
259301
, format $ filter ((Unsafe /=) . status) libraryfiles
260302
]
261303

262-
let safeGuardednessOutputFile = safeOutputFile ++ "Guardedness"
263-
writeFileUTF8 (safeGuardednessOutputFile ++ ".agda") $
264-
unlines [ header
265-
, "{-# OPTIONS --safe --guardedness #-}\n"
266-
, mkModule safeGuardednessOutputFile
267-
, format $ filter ((SafeGuardedness ==) . status) libraryfiles
268-
]
269-
270-
let safeSizedTypesOutputFile = safeOutputFile ++ "SizedTypes"
271-
writeFileUTF8 (safeSizedTypesOutputFile ++ ".agda") $
272-
unlines [ header
273-
, "{-# OPTIONS --safe --sized-types #-}\n"
274-
, mkModule safeSizedTypesOutputFile
275-
, format $ filter ((SafeSizedTypes ==) . status) libraryfiles
276-
]
277-
278304
-- | Usage info.
279305

280306
usage :: String

README/Data/Container/FreeMonad.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
-- used
66
------------------------------------------------------------------------
77

8-
{-# OPTIONS --without-K --safe --sized-types #-}
8+
{-# OPTIONS --without-K --sized-types #-}
99

1010
module README.Data.Container.FreeMonad where
1111

README/Data/Tree/Rose.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Some examples showing how the Rose tree module can be used
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module README.Data.Tree.Rose where
1010

README/Data/Trie/NonDependent.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Example use case for a trie: a wee generic lexer
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module README.Data.Trie.NonDependent where
1010

src/Codata/Cofin.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- "Finite" sets indexed on coinductive "natural" numbers
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Cofin where
1010

src/Codata/Cofin/Literals.agda

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Conat Literals
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Cofin.Literals where
1010

@@ -20,4 +20,3 @@ number n = record
2020
{ Constraint = λ k True (suc k ℕ≤? n)
2121
; fromNat = λ n {{p}} fromℕ< (toWitness p)
2222
}
23-

src/Codata/Colist.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- The Colist type and some operations
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Colist where
1010

src/Codata/Colist/Bisimilarity.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Bisimilarity for Colists
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Colist.Bisimilarity where
1010

src/Codata/Colist/Categorical.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- A categorical view of Colist
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Colist.Categorical where
1010

src/Codata/Colist/Properties.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Properties of operations on the Colist type
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Colist.Properties where
1010

src/Codata/Conat.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- The Conat type and some operations
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Conat where
1010

src/Codata/Conat/Bisimilarity.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Bisimilarity for Conats
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Conat.Bisimilarity where
1010

src/Codata/Conat/Literals.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Conat Literals
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Conat.Literals where
1010

src/Codata/Conat/Properties.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Properties for Conats
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Conat.Properties where
1010

src/Codata/Covec.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- The Covec type and some operations
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Covec where
1010

src/Codata/Covec/Bisimilarity.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Bisimilarity for Covecs
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Covec.Bisimilarity where
1010

src/Codata/Covec/Categorical.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- A categorical view of Covec
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Covec.Categorical where
1010

src/Codata/Covec/Instances.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Typeclass instances for Covec
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Covec.Instances where
1010

src/Codata/Covec/Properties.agda

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Properties of operations on the Covec type
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Covec.Properties where
1010

@@ -29,4 +29,3 @@ module _ {a b c} {A : Set a} {B : Set b} {C : Set c} where
2929
map-map-fusion : (f : A B) (g : B C) {m} as {i} i , m ⊢ map g (map f as) ≈ map (g ∘ f) as
3030
map-map-fusion f g [] = []
3131
map-map-fusion f g (a ∷ as) = Eq.refl ∷ λ where .force map-map-fusion f g (as .force)
32-

src/Codata/Cowriter.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- The Cowriter type and some operations
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
-- Disabled to prevent warnings from BoundedVec
1010
{-# OPTIONS --warn=noUserWarning #-}

src/Codata/Cowriter/Bisimilarity.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Bisimilarity for Cowriter
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Cowriter.Bisimilarity where
1010

src/Codata/Delay.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- The Delay type and some operations
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Delay where
1010

src/Codata/Delay/Bisimilarity.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Bisimilarity for the Delay type
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Delay.Bisimilarity where
1010

src/Codata/Delay/Categorical.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- A categorical view of Delay
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Delay.Categorical where
1010

src/Codata/Delay/Properties.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Properties of operations on the Delay type
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.Delay.Properties where
1010

src/Codata/M.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- M-types (the dual of W-types)
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.M where
1010

src/Codata/M/Bisimilarity.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Bisimilarity for M-types
55
------------------------------------------------------------------------
66

7-
{-# OPTIONS --without-K --safe --sized-types #-}
7+
{-# OPTIONS --without-K --sized-types #-}
88

99
module Codata.M.Bisimilarity where
1010

0 commit comments

Comments
 (0)