Skip to content

Commit

Permalink
Trying to map constructors to types for template haskell.
Browse files Browse the repository at this point in the history
  • Loading branch information
Montmorency committed Sep 26, 2022
1 parent 67404fa commit 1812fab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ihp-hsx/IHP/HSX/HsExpToTH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ toFieldExp = undefined
-- Th.ConP Name [Type] [Pat]
-- ConPat (XConPat p) (XRec p (ConLikeP p)) (HsConPatDetails p)
-- type XConPat GhcRn = NoExtField see
-- Looks like we need the https://hackage.haskell.org/package/ghc-9.4.2/docs/GHC-Hs-Syn-Type.html hsLPatType :: LPat GhcTc -> Type
toPat :: Pat.Pat GhcPs -> TH.Pat
toPat (Pat.VarPat _ (unLoc -> name)) = TH.VarP (toName name)
toPat (TuplePat _ p _) = TH.TupP (map (toPat . unLoc) p)
toPat (ParPat xP lP) = (toPat . unLoc) lP --error "TH.ParPat not implemented"
toPat (ConPat pat_con_ext pat_con pat_args) = TH.ConP (toName pat_con_ext) (map toType (pat_con)) (map (toPat . unLoc) (Pat.hsConPatArgs pat_args)) --error "TH.ConstructorPattern not implemented"
toPat (ConPat pat_con_ext pat_con pat_args) = TH.ConP (toName pat_con_ext) (map toType (map hsLPatType (Pat.hsConPatArgs pat_args))) (map (toPat . unLoc) (Pat.hsConPatArgs pat_args)) --error "TH.ConstructorPattern not implemented"
toPat (ViewPat pat_con pat_args pat_con_ext) = error "TH.ViewPattern not implemented"
toPat (SumPat _ _ _ _) = error "TH.SumPat not implemented"
toPat (WildPat _ ) = error "TH.WildPat not implemented"
Expand Down

0 comments on commit 1812fab

Please sign in to comment.