From 926ef695c89b6109669f3eaeb87c4394bedfbdf8 Mon Sep 17 00:00:00 2001 From: pilfer-pandex <47340789+pilfer-pandex@users.noreply.github.com> Date: Tue, 1 Oct 2019 15:09:23 -0700 Subject: [PATCH] partway through desugar --- pkg/proto/lib/Untyped/Core.hs | 6 +++++- pkg/proto/lib/Untyped/Hoon.hs | 14 ++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/proto/lib/Untyped/Core.hs b/pkg/proto/lib/Untyped/Core.hs index c4594a6f12..4e5dfcc333 100644 --- a/pkg/proto/lib/Untyped/Core.hs +++ b/pkg/proto/lib/Untyped/Core.hs @@ -53,7 +53,11 @@ ledt v e f = Let e (abstract1 v f) fix :: Eq a => a -> Exp a -> Exp a fix v e = Fix (abstract1 v e) - +-- | The expression that returns the given noun as a constant. +con :: Noun -> Exp a +con = \case + A a -> Atm a + C n m -> Cel (con n) (con m) data CExp a = CVar a diff --git a/pkg/proto/lib/Untyped/Hoon.hs b/pkg/proto/lib/Untyped/Hoon.hs index 091b7f8fab..ea3fb7652a 100644 --- a/pkg/proto/lib/Untyped/Hoon.hs +++ b/pkg/proto/lib/Untyped/Hoon.hs @@ -32,22 +32,20 @@ data Pat = Exact Noun | Wild -{- - desugar :: Eq a => Hoon a -> Exp a desugar = go where go = \case HVar v -> Var v HCons h j -> Cel (go h) (go j) - BarCen v cs -> Lam $ Scope $ go $ WutHep (Var (B ())) - BarWut cs -> - CenBar cs -> Fix $ Scope + BarCen cs -> undefined --Lam $ Scope $ go $ WutHep (Var (B ())) + -- CenBar cs -> Fix $ Scope + WutHep h cs -> undefined branch :: (Hoon b -> Exp a) -> Exp a -> Cases b -> Exp a branch go e = foldr f Zap where - f c acc = case c of - (Exact n, h) -> Ift (Eql e + f c acc = case c of + (Exact n, h) -> Ift (Eql e (con n)) (go h) acc + (Wild, h) -> go h --}