Skip to content

Instantly share code, notes, and snippets.

@paolino
Last active February 24, 2020 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paolino/ae36ee30e9ffe17da166ed30302b0885 to your computer and use it in GitHub Desktop.
Save paolino/ae36ee30e9ffe17da166ed30302b0885 to your computer and use it in GitHub Desktop.
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedLabels #-}
{-# options_ghc -Wall #-}
module FCF where
import Control.Lens hiding ( contains
, (.=)
)
import Database.Selda hiding ( Set
, first
, groupBy
)
import qualified Generics.SOP as GS
import qualified Generics.SOP.TH as GS
import Protolude hiding ( Ap
, Selector
)
import GHC.Generics ( from
, to
)
import Generic.Data.Surgery
import Generic.Data.Surgery.Internal
import Fcf
type E a = Eval (InsertField 0 ('Just "pk") RowID (Linearize (Rep a)))
type A a = Arborify (E a)
newtype W a = W (Data (A a) ())
-- GS.deriveGeneric ''W
instance ( Functor (A a) , Contravariant (A a)) => Generic (W a) where
type Rep (W a) = Rep (Data (A a) ())
from (W a) = GHC.Generics.from a
to a = W (GHC.Generics.to a)
instance (Functor (A a), Contravariant (A a)) => SqlRow (W a)
{-
/home/a.pv/ga/cloud-service/missing/src/FCF.hs:58:10: error:
• Could not deduce (selda-0.5.1.0:Database.Selda.SqlRow.GSqlRow
(Arborify
(Eval (InsertField 0 ('Just "pk") RowID (Linearize (Rep a))))))
arising from a use of ‘selda-0.5.1.0:Database.Selda.SqlRow.$dmnestedCols’
from the context: (Functor (A a), Contravariant (A a), Typeable a)
bound by the instance declaration
at /home/a.pv/ga/cloud-service/missing/src/FCF.hs:58:10-73
• In the expression:
selda-0.5.1.0:Database.Selda.SqlRow.$dmnestedCols @(W a)
In an equation for ‘nestedCols’:
nestedCols
= selda-0.5.1.0:Database.Selda.SqlRow.$dmnestedCols @(W a)
In the instance declaration for ‘SqlRow (W a)’typecheck
-}
addKey'
:: ( Linearize (A a) ~ E a
, Eval (FieldIndex "pk" (E a)) ~ 0
, Eval (FieldTypeAt 0 (E a)) ~ RowID
, Eval (RemoveField 0 (E a)) ~ Linearize (Rep a)
, Arborify (Linearize (Rep a)) ~ Rep a
, GArborify (A a)
, GInsertField 0 (E a)
, Generic a
, GLinearize (Rep a)
)
=> a -> W a
addKey' a = W $ fromOR' $ insertRField' @"pk" @0 @RowID def $ toOR a
@paolino
Copy link
Author

paolino commented Feb 24, 2020

/home/a.pv/ga/cloud-service/missing/src/FCF.hs:58:10: error: • Could not deduce (selda-0.5.1.0:Database.Selda.SqlRow.GSqlRow (Arborify (Eval (InsertField 0 ('Just "pk") RowID (Linearize (Rep a)))))) arising from a use of ‘selda-0.5.1.0:Database.Selda.SqlRow.$dmnestedCols’ from the context: (Functor (A a), Contravariant (A a), Typeable a) bound by the instance declaration at /home/a.pv/ga/cloud-service/missing/src/FCF.hs:58:10-73 • In the expression: selda-0.5.1.0:Database.Selda.SqlRow.$dmnestedCols @(W a) In an equation for ‘nestedCols’: nestedCols = selda-0.5.1.0:Database.Selda.SqlRow.$dmnestedCols @(W a) In the instance declaration for ‘SqlRow (W a)’typecheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment