Skip to content

Commit f03ef0d

Browse files
authored
Merge pull request #525 from well-typed/issue-461-ticks
Resolve #461. Drop promotion ticks
2 parents 0dd7314 + d5520e1 commit f03ef0d

File tree

11 files changed

+160
-155
lines changed

11 files changed

+160
-155
lines changed

optics-core/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# optics-core-0.4.2
2+
* Rename PathTree data constructor to PathNode, to avoid pun with type constructor.
3+
14
# optics-core-0.4.1.1 (2023-06-22)
25
* Add INLINE pragmas to small functions that really should inline
36

optics-core/optics-core.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: optics-core
3-
version: 0.4.1.1
3+
version: 0.4.2
44
license: BSD-3-Clause
55
license-file: LICENSE
66
build-type: Simple
@@ -37,6 +37,8 @@ flag explicit-generic-labels
3737

3838
common language
3939
ghc-options: -Wall -Wcompat
40+
if impl(ghc <9.4)
41+
ghc-options: -Wno-unticked-promoted-constructors
4042

4143
default-language: Haskell2010
4244

optics-core/src/Optics/Generic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class GPlate a s where
373373
gplate :: Traversal' s a
374374

375375
instance GPlateContext a s => GPlate a s where
376-
gplate = traversalVL (gplateInner @'True)
376+
gplate = traversalVL (gplateInner @True)
377377
{-# INLINE gplate #-}
378378

379379
-- | Hide implementation from haddock.

optics-core/src/Optics/Internal/Generic.hs

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ instance
129129
instance
130130
( GSetFieldSum path1 g1 h1 b
131131
, GSetFieldSum path2 g2 h2 b
132-
) => GSetFieldSum ('PathTree path1 path2) (g1 :+: g2) (h1 :+: h2) b where
132+
) => GSetFieldSum (PathNode path1 path2) (g1 :+: g2) (h1 :+: h2) b where
133133
gsetFieldSum (L1 x) = L1 . gsetFieldSum @path1 x
134134
gsetFieldSum (R1 y) = R1 . gsetFieldSum @path2 y
135135
{-# INLINE gsetFieldSum #-}
@@ -138,15 +138,15 @@ instance
138138
( path ~ GSetFieldPath con epath
139139
, When (IsLeft epath) (HideReps g h)
140140
, GSetFieldProd path g h b
141-
) => GSetFieldSum ('PathLeaf epath) (M1 C ('MetaCons con fix hs) g)
142-
(M1 C ('MetaCons con fix hs) h) b where
141+
) => GSetFieldSum (PathLeaf epath) (M1 C (MetaCons con fix hs) g)
142+
(M1 C (MetaCons con fix hs) h) b where
143143
gsetFieldSum (M1 x) = M1 . gsetFieldProd @path x
144144

145145
type family GSetFieldPath (con :: Symbol) (e :: Either Symbol [Path]) :: [Path] where
146-
GSetFieldPath _ ('Right path) = path
147-
GSetFieldPath con ('Left name) = TypeError
148-
('Text "Data constructor " ':<>: QuoteSymbol con ':<>:
149-
'Text " doesn't have a field named " ':<>: QuoteSymbol name)
146+
GSetFieldPath _ (Right path) = path
147+
GSetFieldPath con (Left name) = TypeError
148+
(Text "Data constructor " :<>: QuoteSymbol con :<>:
149+
Text " doesn't have a field named " :<>: QuoteSymbol name)
150150

151151
class GSetFieldProd (path :: [Path]) g h b | path h -> b
152152
, path g b -> h where
@@ -155,27 +155,27 @@ class GSetFieldProd (path :: [Path]) g h b | path h -> b
155155
-- fast path left
156156
instance {-# OVERLAPPING #-}
157157
( GSetFieldProd path g1 h1 b
158-
) => GSetFieldProd ('PathLeft : path) (g1 :*: g2) (h1 :*: g2) b where
158+
) => GSetFieldProd (PathLeft : path) (g1 :*: g2) (h1 :*: g2) b where
159159
gsetFieldProd (x :*: y) = (:*: y) . gsetFieldProd @path x
160160

161161
-- slow path left
162162
instance
163163
( GSetFieldProd path g1 h1 b
164164
, g2 ~ h2
165-
) => GSetFieldProd ('PathLeft : path) (g1 :*: g2) (h1 :*: h2) b where
165+
) => GSetFieldProd (PathLeft : path) (g1 :*: g2) (h1 :*: h2) b where
166166
gsetFieldProd (x :*: y) = (:*: y) . gsetFieldProd @path x
167167

168168
-- fast path right
169169
instance {-# OVERLAPPING #-}
170170
( GSetFieldProd path g2 h2 b
171-
) => GSetFieldProd ('PathRight : path) (g1 :*: g2) (g1 :*: h2) b where
171+
) => GSetFieldProd (PathRight : path) (g1 :*: g2) (g1 :*: h2) b where
172172
gsetFieldProd (x :*: y) = (x :*:) . gsetFieldProd @path y
173173

174174
-- slow path right
175175
instance
176176
( GSetFieldProd path g2 h2 b
177177
, g1 ~ h1
178-
) => GSetFieldProd ('PathRight : path) (g1 :*: g2) (h1 :*: h2) b where
178+
) => GSetFieldProd (PathRight : path) (g1 :*: g2) (h1 :*: h2) b where
179179
gsetFieldProd (x :*: y) = (x :*:) . gsetFieldProd @path y
180180

181181
instance
@@ -202,10 +202,10 @@ instance
202202
, HasField name s a -- require the field to be in scope
203203
, Unless (AnyHasPath path)
204204
(TypeError
205-
('Text "Type " ':<>: QuoteType s ':<>:
206-
'Text " doesn't have a field named " ':<>: QuoteSymbol name))
205+
(Text "Type " :<>: QuoteType s :<>:
206+
Text " doesn't have a field named " :<>: QuoteSymbol name))
207207
, GAffineFieldSum path (Rep s) (Rep t) a b
208-
) => GAffineFieldImpl 'True name s t a b where
208+
) => GAffineFieldImpl True name s t a b where
209209
gafieldImpl = withAffineTraversal
210210
(atraversalVL (\point f s -> to <$> gafieldSum @path point f (from s)))
211211
(\match update -> atraversalVL $ \point f s ->
@@ -225,27 +225,27 @@ instance
225225
instance
226226
( GAffineFieldSum path1 g1 h1 a b
227227
, GAffineFieldSum path2 g2 h2 a b
228-
) => GAffineFieldSum ('PathTree path1 path2) (g1 :+: g2) (h1 :+: h2) a b where
228+
) => GAffineFieldSum (PathNode path1 path2) (g1 :+: g2) (h1 :+: h2) a b where
229229
gafieldSum point f (L1 x) = L1 <$> gafieldSum @path1 point f x
230230
gafieldSum point f (R1 y) = R1 <$> gafieldSum @path2 point f y
231231
{-# INLINE gafieldSum #-}
232232

233233
instance
234234
( GAffineFieldMaybe epath g h a b
235-
) => GAffineFieldSum ('PathLeaf epath) (M1 C m g) (M1 C m h) a b where
235+
) => GAffineFieldSum (PathLeaf epath) (M1 C m g) (M1 C m h) a b where
236236
gafieldSum point f (M1 x) = M1 <$> gafieldMaybe @epath point f x
237237

238238
class GAffineFieldMaybe (epath :: Either Symbol [Path]) g h a b where
239239
gafieldMaybe :: AffineTraversalVL (g x) (h x) a b
240240

241241
instance
242242
( g ~ h
243-
) => GAffineFieldMaybe ('Left name) g h a b where
243+
) => GAffineFieldMaybe (Left name) g h a b where
244244
gafieldMaybe point _ g = point g
245245

246246
instance
247247
( GFieldProd prodPath g h a b
248-
) => GAffineFieldMaybe ('Right prodPath) g h a b where
248+
) => GAffineFieldMaybe (Right prodPath) g h a b where
249249
gafieldMaybe _ f g = gfieldProd @prodPath f g
250250

251251
----------------------------------------
@@ -259,27 +259,27 @@ class GFieldProd (path :: [Path]) g h a b | path g -> a
259259
-- fast path left
260260
instance {-# OVERLAPPING #-}
261261
( GFieldProd path g1 h1 a b
262-
) => GFieldProd ('PathLeft : path) (g1 :*: g2) (h1 :*: g2) a b where
262+
) => GFieldProd (PathLeft : path) (g1 :*: g2) (h1 :*: g2) a b where
263263
gfieldProd f (x :*: y) = (:*: y) <$> gfieldProd @path f x
264264

265265
-- slow path left
266266
instance
267267
( GFieldProd path g1 h1 a b
268268
, g2 ~ h2
269-
) => GFieldProd ('PathLeft : path) (g1 :*: g2) (h1 :*: h2) a b where
269+
) => GFieldProd (PathLeft : path) (g1 :*: g2) (h1 :*: h2) a b where
270270
gfieldProd f (x :*: y) = (:*: y) <$> gfieldProd @path f x
271271

272272
-- fast path right
273273
instance {-# OVERLAPPING #-}
274274
( GFieldProd path g2 h2 a b
275-
) => GFieldProd ('PathRight : path) (g1 :*: g2) (g1 :*: h2) a b where
275+
) => GFieldProd (PathRight : path) (g1 :*: g2) (g1 :*: h2) a b where
276276
gfieldProd f (x :*: y) = (x :*:) <$> gfieldProd @path f y
277277

278278
-- slow path right
279279
instance
280280
( GFieldProd path g2 h2 a b
281281
, g1 ~ h1
282-
) => GFieldProd ('PathRight : path) (g1 :*: g2) (h1 :*: h2) a b where
282+
) => GFieldProd (PathRight : path) (g1 :*: g2) (h1 :*: h2) a b where
283283
gfieldProd f (x :*: y) = (x :*:) <$> gfieldProd @path f y
284284

285285
instance
@@ -304,11 +304,11 @@ instance
304304
( Generic s
305305
, Generic t
306306
, path ~ If (n <=? 0)
307-
(TypeError ('Text "There is no 0th position"))
307+
(TypeError (Text "There is no 0th position"))
308308
(GetPositionPaths s n (Rep s))
309309
, When (n <=? 0) (HideReps (Rep s) (Rep t))
310310
, GPositionSum path (Rep s) (Rep t) a b
311-
) => GPositionImpl 'True n s t a b where
311+
) => GPositionImpl True n s t a b where
312312
gpositionImpl = withLens
313313
(lensVL (\f s -> to <$> gpositionSum @path f (from s)))
314314
(\get set -> lensVL $ \f s -> set s <$> f (get s))
@@ -330,7 +330,7 @@ instance
330330
instance
331331
( GPositionSum path1 g1 h1 a b
332332
, GPositionSum path2 g2 h2 a b
333-
) => GPositionSum ('PathTree path1 path2) (g1 :+: g2) (h1 :+: h2) a b where
333+
) => GPositionSum (PathNode path1 path2) (g1 :+: g2) (h1 :+: h2) a b where
334334
gpositionSum f (L1 x) = L1 <$> gpositionSum @path1 f x
335335
gpositionSum f (R1 y) = R1 <$> gpositionSum @path2 f y
336336
{-# INLINE gpositionSum #-}
@@ -339,21 +339,21 @@ instance
339339
( path ~ GPositionPath con epath
340340
, When (IsLeft epath) (HideReps g h)
341341
, GFieldProd path g h a b
342-
) => GPositionSum ('PathLeaf epath) (M1 C ('MetaCons con fix hs) g)
343-
(M1 C ('MetaCons con fix hs) h) a b where
342+
) => GPositionSum (PathLeaf epath) (M1 C (MetaCons con fix hs) g)
343+
(M1 C (MetaCons con fix hs) h) a b where
344344
gpositionSum f (M1 x) = M1 <$> gfieldProd @path f x
345345

346346
type family GPositionPath con (e :: Either (Nat, Nat) [Path]) :: [Path] where
347-
GPositionPath _ ('Right path) = path
348-
GPositionPath con ('Left '(n, k)) = TypeError
349-
('Text "Data constructor " ':<>: QuoteSymbol con ':<>:
350-
'Text " has " ':<>: ShowFieldNumber k ':<>: 'Text ", " ':<>:
351-
ToOrdinal n ':<>: 'Text " requested")
347+
GPositionPath _ (Right path) = path
348+
GPositionPath con (Left '(n, k)) = TypeError
349+
(Text "Data constructor " :<>: QuoteSymbol con :<>:
350+
Text " has " :<>: ShowFieldNumber k :<>: Text ", " :<>:
351+
ToOrdinal n :<>: Text " requested")
352352

353353
type family ShowFieldNumber (k :: Nat) :: ErrorMessage where
354-
ShowFieldNumber 0 = 'Text "no fields"
355-
ShowFieldNumber 1 = 'Text "1 field"
356-
ShowFieldNumber k = 'ShowType k ':<>: 'Text " fields"
354+
ShowFieldNumber 0 = Text "no fields"
355+
ShowFieldNumber 1 = Text "1 field"
356+
ShowFieldNumber k = ShowType k :<>: Text " fields"
357357

358358
----------------------------------------
359359
-- Constructor
@@ -373,12 +373,12 @@ instance
373373
, epath ~ GetNamePath name (Rep s) '[]
374374
, path ~ FromRight
375375
(TypeError
376-
('Text "Type " ':<>: QuoteType s ':<>:
377-
'Text " doesn't have a constructor named " ':<>: QuoteSymbol name))
376+
(Text "Type " :<>: QuoteType s :<>:
377+
Text " doesn't have a constructor named " :<>: QuoteSymbol name))
378378
epath
379379
, When (IsLeft epath) (HideReps (Rep s) (Rep t))
380380
, GConstructorSum path (Rep s) (Rep t) a b
381-
) => GConstructorImpl 'True name s t a b where
381+
) => GConstructorImpl True name s t a b where
382382
gconstructorImpl = withPrism (generic % gconstructorSum @path) prism
383383
{-# INLINE gconstructorImpl #-}
384384

@@ -398,27 +398,27 @@ instance
398398
-- fast path left
399399
instance {-# OVERLAPPING #-}
400400
( GConstructorSum path g1 h1 a b
401-
) => GConstructorSum ('PathLeft : path) (g1 :+: g2) (h1 :+: g2) a b where
401+
) => GConstructorSum (PathLeft : path) (g1 :+: g2) (h1 :+: g2) a b where
402402
gconstructorSum = _L1 % gconstructorSum @path
403403

404404
-- slow path left
405405
instance
406406
( GConstructorSum path g1 h1 a b
407407
, g2 ~ h2
408-
) => GConstructorSum ('PathLeft : path) (g1 :+: g2) (h1 :+: h2) a b where
408+
) => GConstructorSum (PathLeft : path) (g1 :+: g2) (h1 :+: h2) a b where
409409
gconstructorSum = _L1 % gconstructorSum @path
410410

411411
-- fast path right
412412
instance {-# OVERLAPPING #-}
413413
( GConstructorSum path g2 h2 a b
414-
) => GConstructorSum ('PathRight : path) (g1 :+: g2) (g1 :+: h2) a b where
414+
) => GConstructorSum (PathRight : path) (g1 :+: g2) (g1 :+: h2) a b where
415415
gconstructorSum = _R1 % gconstructorSum @path
416416

417417
-- slow path right
418418
instance
419419
( GConstructorSum path g2 h2 a b
420420
, g1 ~ h1
421-
) => GConstructorSum ('PathRight : path) (g1 :+: g2) (h1 :+: h2) a b where
421+
) => GConstructorSum (PathRight : path) (g1 :+: g2) (h1 :+: h2) a b where
422422
gconstructorSum = _R1 % gconstructorSum @path
423423

424424
instance
@@ -438,9 +438,9 @@ type F m a = M1 S m (Rec0 a)
438438
instance {-# OVERLAPPABLE #-}
439439
( Dysfunctional () () g h a b
440440
, TypeError
441-
('Text "Generic based access supports constructors" ':$$:
442-
'Text "containing up to 5 fields. Please generate" ':$$:
443-
'Text "PrismS with Template Haskell if you need more.")
441+
(Text "Generic based access supports constructors" :$$:
442+
Text "containing up to 5 fields. Please generate" :$$:
443+
Text "PrismS with Template Haskell if you need more.")
444444
) => GConstructorTuple g h a b where
445445
gconstructorTuple = error "unreachable"
446446

@@ -544,7 +544,7 @@ instance GPlateImpl (URec b) a where
544544
class GPlateInner (repDefined :: Bool) s a where
545545
gplateInner :: TraversalVL' s a
546546

547-
instance (Generic s, GPlateImpl (Rep s) a) => GPlateInner 'True s a where
547+
instance (Generic s, GPlateImpl (Rep s) a) => GPlateInner True s a where
548548
gplateInner f = fmap to . gplateImpl f . from
549549

550550
instance {-# INCOHERENT #-} GPlateInner repNotDefined s a where

0 commit comments

Comments
 (0)