Skip to content

Commit 2e908da

Browse files
committed
fin,bin,vec,ral are explicitly Safe
1 parent cdd9311 commit 2e908da

Some content is hidden

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

48 files changed

+214
-87
lines changed

bin/ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Version history for bin
22

3+
## 0.1.1
4+
5+
- Explicitly mark all modules as Safe or Trustworthy.
6+
- `fin-0.2` support.
7+
38
## 0.1
49

510
- First version. Released on an unsuspecting world.

bin/bin.cabal

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: bin
3-
version: 0.1.0.1
3+
version: 0.1.1
44
synopsis: Bin: binary natural numbers.
55
category: Data, Dependent Types, Singletons, Math
66
description:
@@ -61,6 +61,7 @@ library
6161
Data.Type.BinP
6262
Data.Wrd
6363

64+
other-modules: TrustworthyCompat
6465
build-depends:
6566
, base >=4.7 && <4.15
6667
, dec ^>=0.0.3
@@ -72,6 +73,11 @@ library
7273
if !impl(ghc >=7.10)
7374
build-depends: nats ^>=1.1.2
7475

76+
if impl(ghc >= 9.0)
77+
-- these flags may abort compilation with GHC-8.10
78+
-- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3295
79+
ghc-options: -Winferred-safe-imports -Wmissing-safe-haskell-mode
80+
7581
-- dump-core
7682
-- if impl(ghc >= 8.0)
7783
-- build-depends: dump-core

bin/cabal.project

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
packages: .
22
packages: ../fin
33
packages: ../dec
4+
5+
-- for testing GHC-9.0
6+
allow-newer: bin:base
7+
allow-newer: fin:base
8+
allow-newer: dec:base
9+
allow-newer: hashable-1.3.0.0:base
10+
allow-newer: hashable-1.3.0.0:integer-gmp

bin/src/Data/Bin.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE DeriveDataTypeable #-}
3+
{-# LANGUAGE Safe #-}
34

45
#if __GLASGOW_HASKELL__ < 710
56
{-# LANGUAGE DataKinds #-}

bin/src/Data/Bin/Pos.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{-# LANGUAGE FunctionalDependencies #-}
77
{-# LANGUAGE GADTs #-}
88
{-# LANGUAGE KindSignatures #-}
9+
{-# LANGUAGE Safe #-}
910
{-# LANGUAGE ScopedTypeVariables #-}
1011
{-# LANGUAGE StandaloneDeriving #-}
1112
{-# LANGUAGE UndecidableInstances #-}
@@ -38,7 +39,7 @@ import Numeric.Natural (Natural)
3839

3940
import qualified Data.BinP.PosP as PP
4041
import qualified Data.Type.Bin as B
41-
import qualified Data.Type.BinP as BP
42+
import qualified Data.Type.BinP as BP
4243
import qualified Test.QuickCheck as QC
4344

4445
import Data.Type.Bin

bin/src/Data/BinP.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE BangPatterns #-}
22
{-# LANGUAGE CPP #-}
33
{-# LANGUAGE DeriveDataTypeable #-}
4+
{-# LANGUAGE Safe #-}
45

56
#if __GLASGOW_HASKELL__ < 710
67
{-# LANGUAGE DataKinds #-}
@@ -84,8 +85,8 @@ instance Ord BinP where
8485
go _acc _ BE = GT
8586
go acc (B0 a) (B0 b) = go acc a b
8687
go acc (B1 a) (B1 b) = go acc a b
87-
go acc (B0 a) (B1 b) = go LT a b
88-
go acc (B1 a) (B0 b) = go GT a b
88+
go _acc (B0 a) (B1 b) = go LT a b
89+
go _acc (B1 a) (B0 b) = go GT a b
8990

9091
instance Show BinP where
9192
showsPrec d = showsPrec d . toNatural

bin/src/Data/BinP/PosP.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{-# LANGUAGE FunctionalDependencies #-}
77
{-# LANGUAGE GADTs #-}
88
{-# LANGUAGE KindSignatures #-}
9+
{-# LANGUAGE Safe #-}
910
{-# LANGUAGE ScopedTypeVariables #-}
1011
{-# LANGUAGE StandaloneDeriving #-}
1112
{-# LANGUAGE UndecidableInstances #-}
@@ -31,8 +32,8 @@ module Data.BinP.PosP (
3132

3233
import Prelude
3334
(Bounded (..), Either (..), Eq, Int, Integer, Num, Ord (..),
34-
Ordering (..), Show (..), ShowS, String, either, fmap, fromIntegral,
35-
map, showParen, showString, ($), (*), (+), (++), (.))
35+
Ordering (..), Show (..), ShowS, String, either, fmap, fromIntegral, map,
36+
showParen, showString, ($), (*), (+), (++), (.))
3637

3738
import Data.Bin (BinP (..))
3839
import Data.Nat (Nat (..))

bin/src/Data/Type/Bin.hs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DataKinds #-}
23
{-# LANGUAGE DeriveDataTypeable #-}
34
{-# LANGUAGE FlexibleContexts #-}
@@ -8,6 +9,11 @@
89
{-# LANGUAGE TypeFamilies #-}
910
{-# LANGUAGE TypeOperators #-}
1011
{-# LANGUAGE UndecidableInstances #-}
12+
#if MIN_VERSION_base(4,8,0)
13+
{-# LANGUAGE Safe #-}
14+
#else
15+
{-# LANGUAGE Trustworthy #-}
16+
#endif
1117
-- | Binary natural numbers. @DataKinds@ stuff.
1218
module Data.Type.Bin (
1319
-- * Singleton
@@ -43,17 +49,18 @@ module Data.Type.Bin (
4349
Bin0, Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9,
4450
) where
4551

46-
import Data.Bin (Bin (..), BinP (..))
47-
import Data.Nat (Nat (..))
48-
import Data.Proxy (Proxy (..))
49-
import Data.Type.Equality ((:~:) (..), TestEquality (..))
50-
import Data.Typeable (Typeable)
51-
import Numeric.Natural (Natural)
52-
import Data.Type.BinP (SBinP (..), SBinPI (..))
52+
import Data.Bin (Bin (..), BinP (..))
53+
import Data.Nat (Nat (..))
54+
import Data.Proxy (Proxy (..))
55+
import Data.Type.BinP (SBinP (..), SBinPI (..))
56+
import Data.Typeable (Typeable)
57+
import Numeric.Natural (Natural)
5358

54-
import qualified Data.Type.Nat as N
55-
import qualified GHC.TypeLits as GHC
5659
import qualified Data.Type.BinP as BP
60+
import qualified Data.Type.Nat as N
61+
import qualified GHC.TypeLits as GHC
62+
63+
import TrustworthyCompat
5764

5865
-- $setup
5966
-- >>> :set -XDataKinds
@@ -288,7 +295,7 @@ type family Mult2Plus1 (b :: Bin) :: BinP where
288295
-- >>> :kind! Succ Bin5
289296
-- Succ Bin5 :: Bin
290297
-- = 'BP ('B0 ('B1 'BE))
291-
--
298+
--
292299
-- @
293300
-- `Succ` :: 'Bin' -> 'Bin'
294301
-- `Succ'` :: 'Bin' -> 'BinP'

bin/src/Data/Type/BinP.hs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DataKinds #-}
23
{-# LANGUAGE DeriveDataTypeable #-}
34
{-# LANGUAGE FlexibleContexts #-}
@@ -8,6 +9,11 @@
89
{-# LANGUAGE TypeFamilies #-}
910
{-# LANGUAGE TypeOperators #-}
1011
{-# LANGUAGE UndecidableInstances #-}
12+
#if MIN_VERSION_base(4,8,0)
13+
{-# LANGUAGE Safe #-}
14+
#else
15+
{-# LANGUAGE Trustworthy #-}
16+
#endif
1117
-- | Positive binary natural numbers. @DataKinds@ stuff.
1218
module Data.Type.BinP (
1319
-- * Singleton
@@ -39,17 +45,17 @@ module Data.Type.BinP (
3945
BinP1, BinP2, BinP3, BinP4, BinP5, BinP6, BinP7, BinP8, BinP9,
4046
) where
4147

42-
import Data.BinP (BinP (..))
43-
import Data.Coerce (coerce)
44-
import Data.Nat (Nat (..))
45-
import Data.Proxy (Proxy (..))
46-
import Data.Type.Equality ((:~:) (..), TestEquality (..))
47-
import Data.Typeable (Typeable)
48-
import Numeric.Natural (Natural)
48+
import Data.BinP (BinP (..))
49+
import Data.Nat (Nat (..))
50+
import Data.Proxy (Proxy (..))
51+
import Data.Typeable (Typeable)
52+
import Numeric.Natural (Natural)
4953

5054
import qualified Data.Type.Nat as N
5155
import qualified GHC.TypeLits as GHC
5256

57+
import TrustworthyCompat
58+
5359
-- $setup
5460
-- >>> :set -XDataKinds
5561
-- >>> import Data.Bin

bin/src/Data/Wrd.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{-# LANGUAGE DeriveDataTypeable #-}
55
{-# LANGUAGE GADTs #-}
66
{-# LANGUAGE KindSignatures #-}
7+
{-# LANGUAGE Safe #-}
78
{-# LANGUAGE ScopedTypeVariables #-}
89
{-# LANGUAGE StandaloneDeriving #-}
910
-- | Fixed-'Wrd'th (unsigned) integers.
@@ -154,7 +155,7 @@ instance N.SNatI n => Num (Wrd n) where
154155
go True (W1 WE) = W1 WE
155156
go False (W1 WE) = W1 WE
156157
go b (W0 w) = W0 (go b w)
157-
go _ (W1 w) = W0 (go True w)
158+
go _ (W1 w) = W0 (go True w)
158159

159160
-------------------------------------------------------------------------------
160161
-- Bits & FiniteBits
@@ -489,7 +490,7 @@ wrdScanl0 g = go where
489490
go :: forall m. N.SNatI m => s -> (s, Wrd m)
490491
go s = case N.snat :: N.SNat m of
491492
N.SZ -> (s, WE)
492-
N.SS ->
493+
N.SS ->
493494
let (s'', b) = g s'
494495
(s' , w') = go s
495496
in (s'', if b then W1 w' else W0 w')
@@ -506,7 +507,7 @@ wrdScanl g = go where
506507
let (s'', b) = g s' True
507508
(s' , w') = go s w
508509
in (s'', if b then W1 w' else W0 w')
509-
510+
510511
wrdScanl2 :: forall s n. (s -> Bool -> Bool -> (s, Bool)) -> s -> Wrd n -> Wrd n -> (s, Wrd n)
511512
wrdScanl2 g = go where
512513
go :: s -> Wrd m -> Wrd m -> (s, Wrd m)

0 commit comments

Comments
 (0)