From d200310ddb374012716ed844e8d75ca7fdad317a Mon Sep 17 00:00:00 2001 From: Eric Conlon <37287+ejconlon@users.noreply.github.com> Date: Fri, 12 Jan 2024 11:55:25 -0800 Subject: [PATCH] etc --- minipat/minipat.cabal | 1 + minipat/src/Minipat/Ast.hs | 5 +---- minipat/src/Minipat/Interp.hs | 11 +++++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 minipat/src/Minipat/Interp.hs diff --git a/minipat/minipat.cabal b/minipat/minipat.cabal index 6fb7e0e..8006668 100644 --- a/minipat/minipat.cabal +++ b/minipat/minipat.cabal @@ -25,6 +25,7 @@ source-repository head library exposed-modules: Minipat.Ast + Minipat.Interp Minipat.Main Minipat.Parser Minipat.Print diff --git a/minipat/src/Minipat/Ast.hs b/minipat/src/Minipat/Ast.hs index 842a813..5e0ec17 100644 --- a/minipat/src/Minipat/Ast.hs +++ b/minipat/src/Minipat/Ast.hs @@ -402,7 +402,7 @@ instance (Pretty s, Pretty a, Pretty r) => Pretty (PatF s a r) where newtype Pat b a = Pat {unPat :: UnPat b a} deriving stock (Show) - deriving newtype (Eq, Ord, Functor, Foldable) + deriving newtype (Eq, Ord, Functor, Foldable, Pretty) type UnPat b = Jot (PatF (Pat b Factor)) b @@ -448,9 +448,6 @@ instance Bitraversable Pat where PatMod (Mod r m) -> fmap PatMod $ Mod <$> go r <*> traverse (bitraverse f pure) m PatPoly (PolyPat rs mc) -> fmap (\rs' -> PatPoly (PolyPat rs' mc)) (traverse go rs) -instance (Pretty a) => Pretty (Pat b a) where - pretty = pretty . unPat - -- ** Normalization type NPat b = Pat (Expansion b) diff --git a/minipat/src/Minipat/Interp.hs b/minipat/src/Minipat/Interp.hs new file mode 100644 index 0000000..507a08b --- /dev/null +++ b/minipat/src/Minipat/Interp.hs @@ -0,0 +1,11 @@ +module Minipat.Interp where + +import Bowtie (jotRight) +import Minipat.Ast qualified as A +import Minipat.Types qualified as T + +interp :: A.NPat b a -> T.Pat a +interp = jotRight go . A.unPat + where + go = \case + _ -> error "TODO"