|
16 | 16 | {-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-} |
17 | 17 |
|
18 | 18 |
|
19 | | -module Data.Array.Accelerate.Pattern.Matchable where |
| 19 | +module Data.Array.Accelerate.Pattern.Matchable (Matchable(..)) where |
20 | 20 |
|
21 | 21 | import Data.Array.Accelerate.Smart as Smart |
22 | 22 | import GHC.TypeLits |
@@ -118,9 +118,6 @@ instance Matchable Bool where |
118 | 118 | makeTag :: TAG -> SmartExp TAG |
119 | 119 | makeTag x = SmartExp (Const (SingleScalarType (NumSingleType (IntegralNumType TypeTAG))) x) |
120 | 120 |
|
121 | | -tagType :: TupR ScalarType TAG |
122 | | -tagType = TupRsingle (SingleScalarType (NumSingleType (IntegralNumType TypeTAG))) |
123 | | - |
124 | 121 | instance (POSable (Maybe a), POSable a) => Matchable (Maybe a) where |
125 | 122 | build n fs = case sameNat (Proxy @(Choices a)) (Proxy @0) of |
126 | 123 | -- a has 0 valid choices (which means we cannot create a Just of this type) |
@@ -292,14 +289,6 @@ instance (POSable (Either a b), POSable a, POSable b) => Matchable (Either a b) |
292 | 289 | Nothing -> |
293 | 290 | error "Impossible type encountered" |
294 | 291 |
|
295 | | -undefPairs :: forall xs . ProductType xs -> SmartExp (FlattenProduct (Merge '[] (xs ++ '[]))) |
296 | | -undefPairs PTNil = SmartExp Smart.Nil |
297 | | -undefPairs (PTCons x xs) = SmartExp (Pair (SmartExp (Union (SmartExp (LiftUnion (unExp $ constant POS.Undef))))) (undefPairs xs)) |
298 | | - |
299 | | -mergePairs :: forall xs . ProductType xs -> SmartExp (FlattenProduct xs) -> SmartExp (FlattenProduct (Merge '[] (xs ++ '[]))) |
300 | | -mergePairs PTNil _ = SmartExp Smart.Nil |
301 | | -mergePairs (PTCons x xs) y = SmartExp (Pair (SmartExp (Union (SmartExp (Prj PairIdxLeft y)))) (mergePairs xs (SmartExp (Prj PairIdxRight y)))) |
302 | | - |
303 | 292 | -- like combineProducts, but lifted to the AST |
304 | 293 | buildTAG :: (All POSable xs) => NP Exp xs -> Exp TAG |
305 | 294 | buildTAG SOP.Nil = Exp $ makeTag 0 |
|
0 commit comments