{-# language DeriveGeneric #-}
{-# language LambdaCase #-}
{-# options_ghc -Wno-unused-imports #-}
module Core.Data.Frame.Generic (
encode,
) where
import qualified Data.Foldable as F (toList)
import Data.Typeable (Typeable)
import Control.Exception (Exception(..))
import GHC.Generics (Generic(..))
import Control.Monad.Catch (MonadThrow(..))
import Lens.Micro (toListOf)
import qualified Core.Data.Frame.List as FL (Frame, frameFromList)
import qualified Heidi.Data.Row.GenericTrie as GTR (Row, mkRow)
import Data.Generics.Encode.Internal (gflattenHM, gflattenGT, Heidi, TC(..), VP)
encode :: (Foldable t, Heidi a) =>
t a
-> FL.Frame (GTR.Row [TC] VP)
encode :: t a -> Frame (Row [TC] VP)
encode t a
ds = (a -> Row [TC] VP) -> t a -> Frame (Row [TC] VP)
forall (t :: * -> *) a row.
Foldable t =>
(a -> row) -> t a -> Frame row
gToFrameWith a -> Row [TC] VP
forall a. Heidi a => a -> Row [TC] VP
gToRowGT t a
ds
gToRowGT :: Heidi a => a -> GTR.Row [TC] VP
gToRowGT :: a -> Row [TC] VP
gToRowGT = Trie [TC] VP -> Row [TC] VP
forall k v. Trie k v -> Row k v
GTR.mkRow (Trie [TC] VP -> Row [TC] VP)
-> (a -> Trie [TC] VP) -> a -> Row [TC] VP
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Trie [TC] VP
forall a. Heidi a => a -> Trie [TC] VP
gflattenGT
gToFrameWith :: Foldable t => (a -> row) -> t a -> FL.Frame row
gToFrameWith :: (a -> row) -> t a -> Frame row
gToFrameWith a -> row
f = [row] -> Frame row
forall row. [row] -> Frame row
FL.frameFromList ([row] -> Frame row) -> (t a -> [row]) -> t a -> Frame row
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> row) -> [a] -> [row]
forall a b. (a -> b) -> [a] -> [b]
map a -> row
f ([a] -> [row]) -> (t a -> [a]) -> t a -> [row]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList
data A = A { A -> Int
a1 :: Int, A -> Char
a2 :: Char } deriving (A -> A -> Bool
(A -> A -> Bool) -> (A -> A -> Bool) -> Eq A
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: A -> A -> Bool
$c/= :: A -> A -> Bool
== :: A -> A -> Bool
$c== :: A -> A -> Bool
Eq, Int -> A -> ShowS
[A] -> ShowS
A -> String
(Int -> A -> ShowS) -> (A -> String) -> ([A] -> ShowS) -> Show A
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [A] -> ShowS
$cshowList :: [A] -> ShowS
show :: A -> String
$cshow :: A -> String
showsPrec :: Int -> A -> ShowS
$cshowsPrec :: Int -> A -> ShowS
Show, (forall x. A -> Rep A x) -> (forall x. Rep A x -> A) -> Generic A
forall x. Rep A x -> A
forall x. A -> Rep A x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep A x -> A
$cfrom :: forall x. A -> Rep A x
Generic)
instance Heidi A
data B = B { B -> A
b1 :: A, B -> String
b2 :: String } deriving (B -> B -> Bool
(B -> B -> Bool) -> (B -> B -> Bool) -> Eq B
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: B -> B -> Bool
$c/= :: B -> B -> Bool
== :: B -> B -> Bool
$c== :: B -> B -> Bool
Eq, Int -> B -> ShowS
[B] -> ShowS
B -> String
(Int -> B -> ShowS) -> (B -> String) -> ([B] -> ShowS) -> Show B
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [B] -> ShowS
$cshowList :: [B] -> ShowS
show :: B -> String
$cshow :: B -> String
showsPrec :: Int -> B -> ShowS
$cshowsPrec :: Int -> B -> ShowS
Show, (forall x. B -> Rep B x) -> (forall x. Rep B x -> B) -> Generic B
forall x. Rep B x -> B
forall x. B -> Rep B x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep B x -> B
$cfrom :: forall x. B -> Rep B x
Generic)
instance Heidi B