Skip to content

Commit ccfbd7e

Browse files
committed
Bump typelit plugins (preparations)
1 parent 5ec337c commit ccfbd7e

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

clash-prelude/src/Clash/Sized/Vector.hs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,17 +2654,43 @@ dtfold :: forall p k a . KnownNat k
26542654
dtfold _ f g = go (SNat :: SNat k)
26552655
where
26562656
go :: forall n . SNat n -> Vec (2^n) a -> (p @@ n)
2657+
#if __GLASGOW_HASKELL__ >= 904 && __GLASGOW_HASKELL__ < 912
2658+
go sn = case toUNat sn of
2659+
UZero -> \case
2660+
Cons x Nil -> f x
2661+
Cons x (Cons _ _) -> f x
2662+
USucc _ -> \case
2663+
xs@(Cons _ (Cons _ _)) ->
2664+
let sn' :: SNat (n - 1)
2665+
sn' = sn `subSNat` d1
2666+
(xsL,xsR) = splitAt (pow2SNat sn') xs
2667+
in g sn' (go sn' xsL) (go sn' xsR)
2668+
-- the remaining cases are impossible cases, but GHC cannot
2669+
-- automatically detect them to be inaccesible. We need to
2670+
-- give additional evidence for proving them to be absurd.
2671+
Cons _ Nil -> case p0 sn of Dict -> case p1 sn of {}
2672+
where
2673+
p0 :: 1 <= m => SNat m -> Dict (2 <= 2^((m-1)+1))
2674+
p0 = const Dict
2675+
p1 :: 1 <= m => SNat m -> Dict (2^m ~ 2^((m-1)+1))
2676+
p1 = const Dict
2677+
Nil -> case p sn of {}
2678+
where
2679+
p :: SNat m -> Dict (1 <= 2^m)
2680+
p = const Dict
2681+
#else
26572682
go _ (x `Cons` Nil) = f x
26582683
go sn xs@(Cons _ (Cons _ _)) =
26592684
let sn' :: SNat (n - 1)
26602685
sn' = sn `subSNat` d1
26612686
(xsL,xsR) = splitAt (pow2SNat sn') xs
26622687
in g sn' (go sn' xsL) (go sn' xsR)
2663-
#if !MIN_VERSION_base(4,16,0) || MIN_VERSION_base(4,17,0)
2688+
#if __GLASGOW_HASKELL__ != 902
26642689
go _ Nil =
26652690
case (const Dict :: forall m. Proxy m -> Dict (1 <= 2 ^ m)) (Proxy @n) of
26662691
{}
26672692
#endif
2693+
#endif
26682694
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
26692695
{-# CLASH_OPAQUE dtfold #-}
26702696
{-# ANN dtfold hasBlackBox #-}

0 commit comments

Comments
 (0)