@@ -19,9 +19,12 @@ Stability : experimental
1919
2020-}
2121module Grenade.Core.Shape (
22− Shape (..)
23− , S (..)
22+ S (..)
23+ , Shape (..)
2424 , Sing (..)
25+#if MIN_VERSION_singletons(2,6,0)
26+ , SShape (..)
27+#endif
2528
2629 , randomOfShape
2730 , fromStorable
@@ -30,6 +33,9 @@ module Grenade.Core.Shape (
3033import Control.DeepSeq (NFData (..))
3134import Control.Monad.Random ( MonadRandom, getRandom )
3235
36+#if MIN_VERSION_base(4,13,0)
37+import Data.Kind (Type)
38+#endif
3339import Data.Proxy
3440import Data.Serialize
3541import Data.Singletons
@@ -87,10 +93,20 @@ deriving instance Show (S n)
8793-- These could probably be derived with template haskell, but this seems
8894-- clear and makes adding the KnownNat constraints simple.
8995-- We can also keep our code TH free, which is great.
96+#if MIN_VERSION_singletons(2,6,0)
97+-- In singletons 2.6 Sing switched from a data family to a type family.
98+type instance Sing = SShape
99+
100+data SShape :: Shape -> Type where
101+ D1Sing :: Sing a -> SShape ('D1 a)
102+ D2Sing :: Sing a -> Sing b -> SShape ('D2 a b)
103+ D3Sing :: KnownNat (a * c) => Sing a -> Sing b -> Sing c -> SShape ('D3 a b c)
104+#else
90105data instance Sing (n :: Shape) where
91106 D1Sing :: Sing a -> Sing ('D1 a)
92107 D2Sing :: Sing a -> Sing b -> Sing ('D2 a b)
93108 D3Sing :: KnownNat (a * c) => Sing a -> Sing b -> Sing c -> Sing ('D3 a b c)
109+#endif
94110
95111instance KnownNat a => SingI ('D1 a) where
96112 sing = D1Sing sing