Skip to content

Commit 376a46e

Browse files
committed
refactor: Remove unnecessary promotion ticks
Unticked promoted constructors are the encouraged default as of GHC 9.4 (see [1]). We remove unnecessary ticks from type families, and disable -Wunticked-promoted-constructors on GHC 9.2. [1]: https://gitlab.haskell.org/ghc/ghc/-/issues/20531
1 parent 6e391a0 commit 376a46e

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

package.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ ghc-options:
4444
- -Wpartial-fields
4545
- -Wredundant-constraints
4646
- -Wunused-packages
47+
when:
48+
- condition: impl(ghc < 9.4)
49+
ghc-options:
50+
- -Wno-unticked-promoted-constructors
4751

4852
library:
4953
source-dirs: src

src/VCard/Symbol/Private/Case.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ sToLower :: SSymbol s -> SSymbol (ToLower s)
4545
sToLower ss = sToLowerUncons (sUnconsSymbol ss)
4646

4747
type family ToLowerUncons (mcs :: Maybe (Char, Symbol)) :: Symbol where
48-
ToLowerUncons 'Nothing = ""
49-
ToLowerUncons ('Just '(c, s)) = ConsSymbol (ToLowerChar c) (ToLower s)
48+
ToLowerUncons Nothing = ""
49+
ToLowerUncons (Just '(c, s)) = ConsSymbol (ToLowerChar c) (ToLower s)
5050

5151
sToLowerUncons :: SMaybe mcs -> SSymbol (ToLowerUncons mcs)
5252
sToLowerUncons = \case
@@ -131,8 +131,8 @@ sToUpper :: SSymbol s -> SSymbol (ToUpper s)
131131
sToUpper ss = sToUpperUncons (sUnconsSymbol ss)
132132

133133
type family ToUpperUncons (mcs :: Maybe (Char, Symbol)) :: Symbol where
134-
ToUpperUncons 'Nothing = ""
135-
ToUpperUncons ('Just '(c, s)) = ConsSymbol (ToUpperChar c) (ToUpper s)
134+
ToUpperUncons Nothing = ""
135+
ToUpperUncons (Just '(c, s)) = ConsSymbol (ToUpperChar c) (ToUpper s)
136136

137137
sToUpperUncons :: SMaybe mcs -> SSymbol (ToUpperUncons mcs)
138138
sToUpperUncons = \case

src/VCard/Symbol/Private/Prefix.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ type family IsPrefixOfInsensitive (s :: Symbol) (t :: Symbol) :: Bool where
2525
IsPrefixOfInsensitive s t = IsPrefixOf (ToLower s) (ToLower t)
2626

2727
type family IsPrefixOfList (s :: [Char]) (t :: [Char]) :: Bool where
28-
IsPrefixOfList '[] '[] = 'True
29-
IsPrefixOfList '[] (y ': ys) = 'True
30-
IsPrefixOfList (x ': xs) (y ': ys) = (x == y) && IsPrefixOfList xs ys
31-
IsPrefixOfList (x ': xs) '[] = 'False
28+
IsPrefixOfList '[] '[] = True
29+
IsPrefixOfList '[] (y : ys) = True
30+
IsPrefixOfList (x : xs) (y : ys) = (x == y) && IsPrefixOfList xs ys
31+
IsPrefixOfList (x : xs) '[] = False
3232

3333
type family ToList (s :: Symbol) :: [Char] where
3434
ToList s = ToListUncons (UnconsSymbol s)
3535

3636
type family ToListUncons (x :: (Maybe (Char, Symbol))) :: [Char] where
37-
ToListUncons 'Nothing = '[]
38-
ToListUncons ('Just '(c, s)) = c ': ToList s
37+
ToListUncons Nothing = '[]
38+
ToListUncons (Just '(c, s)) = c : ToList s

vcard.cabal

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ library
7575
, text >=1.2 && <1.3 || >=2.0 && <2.1 || >=2.1 && <2.2
7676
, vary ==0.1.*
7777
default-language: Haskell2010
78+
if impl(ghc < 9.4)
79+
ghc-options: -Wno-unticked-promoted-constructors
7880
if impl(ghc >= 9.6)
7981
other-modules:
8082
VCard.Symbol.Private.Compat.New
@@ -157,6 +159,8 @@ test-suite vcard-tests
157159
, time >=1.11 && <1.12 || >=1.12 && <1.13 || >=1.14 && <1.15
158160
, vary ==0.1.*
159161
default-language: Haskell2010
162+
if impl(ghc < 9.4)
163+
ghc-options: -Wno-unticked-promoted-constructors
160164
if impl(ghc >= 9.6)
161165
other-modules:
162166
VCard.Symbol.Private.Compat.New

0 commit comments

Comments
 (0)