-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is Template Haskell Rel8able
deriving worth having?
#136
Comments
There may be something here. If we take data AoiOverlayImage f = AoiOverlayImage
{ id :: Column f AoiOverlayImageId
, category :: Column f AoiOverlayImageCategory
, orderId :: Column f OrderId
, name :: Column f Text
, mimeType :: Column f Text
, imageBucket :: Column f Text
, imageKey :: Column f Text
, createdAt :: Column f UTCTime
, imageWidth :: Column f Double
, imageHeight :: Column f Double
, side :: Column f PanelSide
, fiducials :: Fiducials (Point V2 (Column f Double))
} Then if I use
If I manually define instance Rel8able AoiOverlayImage where
type GColumns AoiOverlayImage =
HProduct (HIdentity AoiOverlayImageId)
(HProduct (HIdentity AoiOverlayImageCategory)
(HProduct (HIdentity OrderId)
(HProduct (HIdentity Text)
(HProduct (HIdentity Text)
(HProduct (HIdentity Text)
(HProduct (HIdentity Text)
(HProduct (HIdentity UTCTime)
(HProduct (HIdentity Double)
(HProduct (HIdentity Double)
(HProduct (HIdentity PanelSide)
(Columns (Fiducials (Point V2 (Column Expr Double))))))))))))))
type GFromExprs AoiOverlayImage = AoiOverlayImage Result
gfromColumns = \case
SAggregate -> \(HProduct (HIdentity id) (HProduct (HIdentity category) (HProduct (HIdentity orderId) (HProduct (HIdentity name) (HProduct (HIdentity mimeType) (HProduct (HIdentity imageBucket) (HProduct (HIdentity imageKey) (HProduct (HIdentity createdAt) (HProduct (HIdentity imageWidth) (HProduct (HIdentity imageHeight) (HProduct (HIdentity side) _fiducials))))))))))) ->
AoiOverlayImage{..}
SExpr -> \(HProduct (HIdentity id) (HProduct (HIdentity category) (HProduct (HIdentity orderId) (HProduct (HIdentity name) (HProduct (HIdentity mimeType) (HProduct (HIdentity imageBucket) (HProduct (HIdentity imageKey) (HProduct (HIdentity createdAt) (HProduct (HIdentity imageWidth) (HProduct (HIdentity imageHeight) (HProduct (HIdentity side) _fiducials))))))))))) ->
AoiOverlayImage{..}
SField -> \(HProduct (HIdentity id) (HProduct (HIdentity category) (HProduct (HIdentity orderId) (HProduct (HIdentity name) (HProduct (HIdentity mimeType) (HProduct (HIdentity imageBucket) (HProduct (HIdentity imageKey) (HProduct (HIdentity createdAt) (HProduct (HIdentity imageWidth) (HProduct (HIdentity imageHeight) (HProduct (HIdentity side) _fiducials))))))))))) ->
AoiOverlayImage{..}
SName -> \(HProduct (HIdentity id) (HProduct (HIdentity category) (HProduct (HIdentity orderId) (HProduct (HIdentity name) (HProduct (HIdentity mimeType) (HProduct (HIdentity imageBucket) (HProduct (HIdentity imageKey) (HProduct (HIdentity createdAt) (HProduct (HIdentity imageWidth) (HProduct (HIdentity imageHeight) (HProduct (HIdentity side) _fiducials))))))))))) ->
AoiOverlayImage{..}
SResult -> \(HProduct (HIdentity (Identity id)) (HProduct (HIdentity (Identity category)) (HProduct (HIdentity (Identity orderId)) (HProduct (HIdentity (Identity name)) (HProduct (HIdentity (Identity mimeType)) (HProduct (HIdentity (Identity imageBucket)) (HProduct (HIdentity (Identity imageKey)) (HProduct (HIdentity (Identity createdAt)) (HProduct (HIdentity (Identity imageWidth)) (HProduct (HIdentity (Identity imageHeight)) (HProduct (HIdentity (Identity side)) _fiducials))))))))))) ->
AoiOverlayImage{..}
gtoColumns context AoiOverlayImage{..} = case context of
SAggregate ->
HProduct (HIdentity id) (HProduct (HIdentity category) (HProduct (HIdentity orderId) (HProduct (HIdentity name) (HProduct (HIdentity mimeType) (HProduct (HIdentity imageBucket) (HProduct (HIdentity imageKey) (HProduct (HIdentity createdAt) (HProduct (HIdentity imageWidth) (HProduct (HIdentity imageHeight) (HProduct (HIdentity side) (undefined fiducials)))))))))))
SExpr ->
HProduct (HIdentity id) (HProduct (HIdentity category) (HProduct (HIdentity orderId) (HProduct (HIdentity name) (HProduct (HIdentity mimeType) (HProduct (HIdentity imageBucket) (HProduct (HIdentity imageKey) (HProduct (HIdentity createdAt) (HProduct (HIdentity imageWidth) (HProduct (HIdentity imageHeight) (HProduct (HIdentity side) (undefined fiducials)))))))))))
SField ->
HProduct (HIdentity id) (HProduct (HIdentity category) (HProduct (HIdentity orderId) (HProduct (HIdentity name) (HProduct (HIdentity mimeType) (HProduct (HIdentity imageBucket) (HProduct (HIdentity imageKey) (HProduct (HIdentity createdAt) (HProduct (HIdentity imageWidth) (HProduct (HIdentity imageHeight) (HProduct (HIdentity side) (undefined fiducials)))))))))))
SName ->
HProduct (HIdentity id) (HProduct (HIdentity category) (HProduct (HIdentity orderId) (HProduct (HIdentity name) (HProduct (HIdentity mimeType) (HProduct (HIdentity imageBucket) (HProduct (HIdentity imageKey) (HProduct (HIdentity createdAt) (HProduct (HIdentity imageWidth) (HProduct (HIdentity imageHeight) (HProduct (HIdentity side) (undefined fiducials)))))))))))
SResult ->
HProduct (HIdentity (pure id)) $
HProduct (HIdentity (pure category))$
HProduct (HIdentity (pure orderId)) $
HProduct (HIdentity (pure name)) $
HProduct (HIdentity (pure mimeType)) $
HProduct (HIdentity (pure imageBucket)) $
HProduct (HIdentity (pure imageKey)) $
HProduct (HIdentity (pure createdAt)) $
HProduct (HIdentity (pure imageWidth)) $
HProduct (HIdentity (pure imageHeight)) $
HProduct (HIdentity (pure side)) $
(undefined fiducials)
gfromResult (HProduct (HIdentity (Identity id)) (HProduct (HIdentity (Identity category)) (HProduct (HIdentity (Identity orderId)) (HProduct (HIdentity (Identity name)) (HProduct (HIdentity (Identity mimeType)) (HProduct (HIdentity (Identity imageBucket)) (HProduct (HIdentity (Identity imageKey)) (HProduct (HIdentity (Identity createdAt)) (HProduct (HIdentity (Identity imageWidth)) (HProduct (HIdentity (Identity imageHeight)) (HProduct (HIdentity (Identity side)) _fiducials))))))))))) =
AoiOverlayImage{..}
gtoResult AoiOverlayImage{..} =
HProduct (HIdentity (pure id)) $
HProduct (HIdentity (pure category))$
HProduct (HIdentity (pure orderId)) $
HProduct (HIdentity (pure name)) $
HProduct (HIdentity (pure mimeType)) $
HProduct (HIdentity (pure imageBucket)) $
HProduct (HIdentity (pure imageKey)) $
HProduct (HIdentity (pure createdAt)) $
HProduct (HIdentity (pure imageWidth)) $
HProduct (HIdentity (pure imageHeight)) $
HProduct (HIdentity (pure side)) $
(undefined fiducials) Then I get
If I'm reading this right, 500ms becomes 144ms - so almost a 5x speed up in compilation time. Obviously generating the code using TH is going to take time, so 5x might be out of reach, but even 2x would be fairly impressive. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently we derive
Rel8able
by piggy-backing off aGeneric
instance. This is fine, but I wonder if we should also have aderiveRel8able
Template Haskell function. My theory: overall faster compilation due to not needing aGeneric
instance at all, and possibly a more efficient implementation.The text was updated successfully, but these errors were encountered: