Skip to content

Commit

Permalink
Added ParPat and working on ConPat so that generic lambda pattern
Browse files Browse the repository at this point in the history
matching works in HSX.
  • Loading branch information
Montmorency committed Sep 26, 2022
1 parent edab873 commit 922aec6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ihp-hsx/IHP/HSX/HsExpToTH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import GHC.Hs.Expr as Expr
import GHC.Hs.Extension as Ext
import GHC.Hs.Pat as Pat
import GHC.Hs.Lit
import qualified GHC.Hs.Utils as Utils
import qualified Data.ByteString as B
import qualified Language.Haskell.TH.Syntax as TH
import GHC.Types.SrcLoc
Expand All @@ -28,6 +29,7 @@ import GHC.Stack
import qualified Data.List.NonEmpty as NonEmpty
import Language.Haskell.Syntax.Type


fl_value = rationalFromFractionalLit

toLit :: HsLit GhcPs -> TH.Lit
Expand Down Expand Up @@ -72,6 +74,12 @@ toFieldExp = undefined
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 pat_args pat_con_ext) = TH.ConP (toName pat_con) () --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"
toPat (NPat _ _ _ _ ) = error "TH.NPat not implemented"
toPat p = todo "toPat" p

toExp :: Expr.HsExpr GhcPs -> TH.Exp
Expand Down Expand Up @@ -198,4 +206,4 @@ noTH :: (HasCallStack, Show e) => String -> e -> a
noTH fun thing = error . concat $ [moduleName, ".", fun, ": no TemplateHaskell for: ", show thing]

moduleName :: String
moduleName = "IHP.HSX.HsExpToTH"
moduleName = "IHP.HSX.HsExpToTH"

0 comments on commit 922aec6

Please sign in to comment.