@@ -421,12 +421,20 @@ class RebuildSortedHList l where
421 rebuildSortedHList :: [DSum (HListPtr l)] -> HList l
421 rebuildSortedHList :: [DSum (HListPtr l)] -> HList l
423instance RebuildSortedHList '[] where
423instance RebuildSortedHList '[] where
424− rebuildSortedFHList [] = FHNil
424+ rebuildSortedFHList l = case l of
426+ _ : _ -> error "rebuildSortedFHList{'[]}: empty list expected"
425− rebuildSortedHList [] = HNil
427+ rebuildSortedHList l = case l of
429+ _ : _ -> error "rebuildSortedHList{'[]}: empty list expected"
427instance RebuildSortedHList t => RebuildSortedHList (h ': t) where
431instance RebuildSortedHList t => RebuildSortedHList (h ': t) where
432+ rebuildSortedFHList l = case l of
428− rebuildSortedFHList ((WrapArg HHeadPtr :=> h) : t) = FHCons h $ rebuildSortedFHList $ map (\(WrapArg (HTailPtr p) :=> v) -> WrapArg p :=> v) t
433+ ((WrapArg HHeadPtr :=> h) : t) -> FHCons h $ rebuildSortedFHList $ map (\(WrapArg (HTailPtr p) :=> v) -> WrapArg p :=> v) t
434+ _ -> error "rebuildSortedFHList{h':t}: non-empty list with HHeadPtr expected"
435+ rebuildSortedHList l = case l of
429− rebuildSortedHList ((HHeadPtr :=> h) : t) = HCons h $ rebuildSortedHList $ map (\(HTailPtr p :=> v) -> p :=> v) t
436+ ((HHeadPtr :=> h) : t) -> HCons h $ rebuildSortedHList $ map (\(HTailPtr p :=> v) -> p :=> v) t
437+ _ -> error "rebuildSortedHList{h':t}: non-empty list with HHeadPtr expected"
431dmapToHList :: forall l. RebuildSortedHList l => DMap (HListPtr l) -> HList l
439dmapToHList :: forall l. RebuildSortedHList l => DMap (HListPtr l) -> HList l
432dmapToHList = rebuildSortedHList . DMap.toList
440dmapToHList = rebuildSortedHList . DMap.toList
@@ -449,12 +457,16 @@ class AllAreFunctors (f :: a -> *) (l :: [a]) where
450instance AllAreFunctors f '[] where
458instance AllAreFunctors f '[] where
451 type FunctorList f '[] = '[]
459 type FunctorList f '[] = '[]
460+ toFHList l = case l of
452− toFHList HNil = FHNil
461+ HNil -> FHNil
462+ _ -> error "toFHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
453 fromFHList FHNil = HNil
463 fromFHList FHNil = HNil
455instance AllAreFunctors f t => AllAreFunctors f (h ': t) where
465instance AllAreFunctors f t => AllAreFunctors f (h ': t) where
456 type FunctorList f (h ': t) = f h ': FunctorList f t
466 type FunctorList f (h ': t) = f h ': FunctorList f t
467+ toFHList l = case l of
457− toFHList (a `HCons` b) = a `FHCons` toFHList b
468+ a `HCons` b -> a `FHCons` toFHList b
469+ _ -> error "toFHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
458 fromFHList (a `FHCons` b) = a `HCons` fromFHList b
470 fromFHList (a `FHCons` b) = a `HCons` fromFHList b
460collectDyn :: ( RebuildSortedHList (HListElems b)
472collectDyn :: ( RebuildSortedHList (HListElems b)
@@ -475,14 +487,20 @@ class IsHList a where
475instance IsHList (a, b) where
487instance IsHList (a, b) where
476 type HListElems (a, b) = [a, b]
488 type HListElems (a, b) = [a, b]
477 toHList (a, b) = hBuild a b
489 toHList (a, b) = hBuild a b
490+ fromHList l = case l of
478− fromHList (a `HCons` b `HCons` HNil) = (a, b)
491+ a `HCons` b `HCons` HNil -> (a, b)
492+ _ -> error "fromHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
480instance IsHList (a, b, c, d) where
494instance IsHList (a, b, c, d) where
481 type HListElems (a, b, c, d) = [a, b, c, d]
495 type HListElems (a, b, c, d) = [a, b, c, d]
482 toHList (a, b, c, d) = hBuild a b c d
496 toHList (a, b, c, d) = hBuild a b c d
497+ fromHList l = case l of
483− fromHList (a `HCons` b `HCons` c `HCons` d `HCons` HNil) = (a, b, c, d)
498+ a `HCons` b `HCons` c `HCons` d `HCons` HNil -> (a, b, c, d)
499+ _ -> error "fromHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
485instance IsHList (a, b, c, d, e, f) where
501instance IsHList (a, b, c, d, e, f) where
486 type HListElems (a, b, c, d, e, f) = [a, b, c, d, e, f]
502 type HListElems (a, b, c, d, e, f) = [a, b, c, d, e, f]
487 toHList (a, b, c, d, e, f) = hBuild a b c d e f
503 toHList (a, b, c, d, e, f) = hBuild a b c d e f
504+ fromHList l = case l of
488− fromHList (a `HCons` b `HCons` c `HCons` d `HCons` e `HCons` f `HCons` HNil) = (a, b, c, d, e, f)
505+ a `HCons` b `HCons` c `HCons` d `HCons` e `HCons` f `HCons` HNil -> (a, b, c, d, e, f)
506+ _ -> error "fromHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139