mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-11 06:05:12 +03:00
Make it possible to show ANF code
This commit is contained in:
parent
ca146f4197
commit
edce1f8d1e
@ -681,11 +681,12 @@ type Ctx v = [Cte v]
|
||||
-- Should be a completely closed term
|
||||
data SuperNormal v
|
||||
= Lambda { conventions :: [Mem], bound :: ANormal v }
|
||||
deriving (Show)
|
||||
data SuperGroup v
|
||||
= Rec
|
||||
{ group :: [(v, SuperNormal v)]
|
||||
, entry :: SuperNormal v
|
||||
}
|
||||
} deriving (Show)
|
||||
|
||||
type ANFM v
|
||||
= ReaderT (Set v, Reference -> Word64, Reference -> RTag)
|
||||
|
@ -7,6 +7,9 @@
|
||||
{-# language PatternSynonyms #-}
|
||||
{-# language DeriveTraversable #-}
|
||||
|
||||
{-# language UndecidableInstances #-}
|
||||
{-# language QuantifiedConstraints #-}
|
||||
|
||||
module Unison.ABT.Normalized
|
||||
( ABT(..)
|
||||
, Term(.., TAbs, TTm, TAbss)
|
||||
@ -40,6 +43,21 @@ data Term f v = Term
|
||||
, out :: ABT f v
|
||||
}
|
||||
|
||||
instance (forall a b. Show a => Show b => Show (f a b), Show v)
|
||||
=> Show (ABT f v)
|
||||
where
|
||||
showsPrec p a = showParen (p >= 9) $ case a of
|
||||
Abs v tm
|
||||
-> showString "Abs " . showsPrec 10 v
|
||||
. showString " " . showsPrec 10 tm
|
||||
Tm e -> showString "Tm " . showsPrec 10 e
|
||||
|
||||
instance (forall a b. Show a => Show b => Show (f a b), Show v)
|
||||
=> Show (Term f v)
|
||||
where
|
||||
showsPrec p (Term _ e)
|
||||
= showParen (p >= 9) $ showString "Term " . showsPrec 10 e
|
||||
|
||||
pattern TAbs :: Var v => v -> Term f v -> Term f v
|
||||
pattern TAbs u bd <- Term _ (Abs u bd)
|
||||
where TAbs u bd = Term (Set.delete u (freeVars bd)) (Abs u bd)
|
||||
|
Loading…
Reference in New Issue
Block a user