From bf4a469f369f1b8c6b1c2d7cc6907177405603f4 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Wed, 13 Nov 2024 20:20:30 +0100 Subject: Add withKnownSh{S,X} --- src/Data/Array/Mixed/Shape.hs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Data/Array/Mixed') diff --git a/src/Data/Array/Mixed/Shape.hs b/src/Data/Array/Mixed/Shape.hs index 1d3e60a..b5a4cb9 100644 --- a/src/Data/Array/Mixed/Shape.hs +++ b/src/Data/Array/Mixed/Shape.hs @@ -31,6 +31,7 @@ import Data.Kind (Type, Constraint) import Data.Monoid (Sum(..)) import Data.Proxy import Data.Type.Equality +import GHC.Exts (withDict) import GHC.Generics (Generic) import GHC.IsList (IsList) import GHC.IsList qualified as IsList @@ -469,6 +470,9 @@ instance KnownShX '[] where knownShX = ZKX instance (KnownNat n, KnownShX sh) => KnownShX (Just n : sh) where knownShX = SKnown natSing :!% knownShX instance KnownShX sh => KnownShX (Nothing : sh) where knownShX = SUnknown () :!% knownShX +withKnownShX :: forall sh r. StaticShX sh -> (KnownShX sh => r) -> r +withKnownShX sh = withDict @(KnownShX sh) sh + -- * Flattening -- cgit v1.2.3-70-g09d2