@@ -1,6 +1,5 @@
1{-# language DataKinds #-}
1{-# language DataKinds #-}
2{-# language FlexibleContexts #-}
2{-# language FlexibleContexts #-}
4{-# language LambdaCase #-}
3{-# language LambdaCase #-}
5{-# language MultiParamTypeClasses #-}
4{-# language MultiParamTypeClasses #-}
6{-# language StandaloneKindSignatures #-}
5{-# language StandaloneKindSignatures #-}
@@ -15,6 +14,7 @@ where
16import Data.Kind ( Type )
15import Data.Kind ( Type )
17import Data.List.NonEmpty ( NonEmpty )
16import Data.List.NonEmpty ( NonEmpty )
17+import Data.Type.Equality ( (:~:)( Refl ) )
18import Prelude
18import Prelude
@@ -34,7 +34,10 @@ import Rel8.Table
35import Rel8.Table.NonEmpty ( NonEmptyTable( NonEmptyTable ) )
35import Rel8.Table.NonEmpty ( NonEmptyTable( NonEmptyTable ) )
36import Rel8.Table.Recontextualize ( Recontextualize )
36import Rel8.Table.Recontextualize ( Recontextualize )
37−import Rel8.Table.Unreify ( Unreifiable )
37+import Rel8.Table.Unreify
38+ ( Unreifiability( Unreifiability )
39+ , Unreifiable, unreifiability
40type HNonEmpty :: K.Context -> Type -> Type
43type HNonEmpty :: K.Context -> Type -> Type
@@ -51,12 +54,8 @@ type AHNonEmpty :: K.Context -> Type -> Type
51newtype AHNonEmpty context a = AHNonEmpty (HNonEmpty context a)
54newtype AHNonEmpty context a = AHNonEmpty (HNonEmpty context a)
56− , Table (Reify context) a
57− , Unreifiable (Reify context) a
57+instance (Reifiable context, Unreifiable a, Table (Reify context) a) =>
59− => Table (Reify context) (AHNonEmpty context a)
58+ Table (Reify context) (AHNonEmpty context a)
61 type Context (AHNonEmpty context a) = Reify context
60 type Context (AHNonEmpty context a) = Reify context
62 type Columns (AHNonEmpty context a) = HNonEmptyTable (Columns a)
61 type Columns (AHNonEmpty context a) = HNonEmptyTable (Columns a)
@@ -64,20 +63,17 @@ instance
65 fromColumns = sfromColumnsNonEmpty contextSing
64 fromColumns = sfromColumnsNonEmpty contextSing
66 toColumns = stoColumnsNonEmpty contextSing
65 toColumns = stoColumnsNonEmpty contextSing
68− smapNonEmpty contextSing (reify proof) hreify .
67+ reify _ = sreifyNonEmpty (unreifiability contextSing)
69− AHNonEmpty
68+ unreify _ = sunreifyNonEmpty (unreifiability contextSing)
71− (\(AHNonEmpty a) -> a) .
72− smapNonEmpty contextSing (unreify proof) hunreify
76 ( Reifiable context, Reifiable context'
72 ( Reifiable context, Reifiable context'
77− , Unreifiable (Reify context) a, Unreifiable (Reify context') a'
73+ , Unreifiable a, Unreifiable a'
78 , Recontextualize (Reify context) (Reify context') a a'
74 , Recontextualize (Reify context) (Reify context') a a'
80− Recontextualize
76+ => Recontextualize
81 (Reify context)
77 (Reify context)
82 (Reify context')
78 (Reify context')
83 (AHNonEmpty context a)
79 (AHNonEmpty context a)
@@ -133,3 +129,21 @@ stoColumnsNonEmpty = \case
133 stoColumnsNonEmpty context .
129 stoColumnsNonEmpty context .
134 smapNonEmpty context (hunreify . toColumns) hunreify .
130 smapNonEmpty context (hunreify . toColumns) hunreify .
135 (\(AHNonEmpty a) -> a)
131 (\(AHNonEmpty a) -> a)
135+ => Unreifiability context a
136+ -> HNonEmpty context (Unreify a)
137+ -> AHNonEmpty context a
138+sreifyNonEmpty (Unreifiability context) =
139+ smapNonEmpty context (reify Refl) hreify .
143+sunreifyNonEmpty :: ()
144+ => Unreifiability context a
145+ -> AHNonEmpty context a
146+ -> HNonEmpty context (Unreify a)
147+sunreifyNonEmpty (Unreifiability context) =
148+ (\(AHNonEmpty a) -> a) .
149+ smapNonEmpty context (unreify Refl) hunreify