Skip to content

Commit 07886db

Browse files
committed
WIP (compiling)
1 parent 7307af4 commit 07886db

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

app/Agda/Core/PrettyPrint.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ instance PrettyCore Core.Defn where
163163
prettyCore m c
164164
prettyCore m (Core.RecordDefn r) =
165165
prettyCore m r
166+
prettyCore m (Core.ProjDefn) =
167+
"Is a Projection"
166168

167169
instance PrettyCore Core.Definition where
168170
prettyCore :: NameMap -> Core.Definition -> String

app/Agda/Core/ToCore.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ toCoreDefn (I.FunctionDefn def) _ =
296296
recordIdx <- lookupRec qn >>= \case
297297
Nothing -> throwError $ "Trying to access an unknown record definition: " <+> pretty qn
298298
Just (recordIndex, _) -> pure recordIndex
299-
300-
throwError "TODO: Add support for compiling record projections"
299+
-- a dummy Defn object which simply communicates that this Defn is a record projection
300+
return Core.ProjDefn
301301
I.FunctionData{}
302302
-> throwError "unsupported case (shouldn't happen)"
303303

@@ -409,7 +409,7 @@ instance ToCore I.Elim where
409409
toCore (I.Apply x) = toCore x
410410
--TODO (diode-lang) : Support projection as an Elim
411411
-- toCore (I.Proj _ qn) = TDef <$> lookupDefOrData qn
412-
toCore (I.Proj _ qn) = throwError "record projection not supported"
412+
toCore (I.Proj _ qn) = throwError "TODO: Support record projections"
413413
toCore I.IApply{} = throwError "cubical endpoint application not supported"
414414

415415

app/Main.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ agdaCoreCompile env _ _ def = do
297297
, preSigCons = preSigCons
298298
, preSigRecs = Map.insert (indexToNat index) recTyp preSigRecs
299299
}
300+
Core.ProjDefn ->
301+
liftIO $ writeIORef ioPreSig $
302+
PreSignature
303+
{ preSigDefs = preSigDefs
304+
, preSigData = preSigData
305+
, preSigCons = preSigCons
306+
, preSigRecs = preSigRecs
307+
}
300308
return $ pure def'
301309

302310

src/Agda/Core/Syntax/Signature.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ data Defn : Set where
141141
DatatypeDefn : (@0 d : NameData) Datatype d Defn
142142
ConstructorDefn : (@0 d : NameData) (@0 c : NameCon d) Constructor c Defn
143143
RecordDefn : (@0 r : NameRec) Record r Defn
144+
ProjDefn : Defn
144145
{-# COMPILE AGDA2HS Defn #-}
145146

146147

test/EtaRecords.agda

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,30 @@ x = record { fst = Zero; snd = Suc Zero }
4848
x' : Pair Nat Nat
4949
x' = Pair.constructor Zero (Suc Zero)
5050

51-
y : Pair Nat Bool
52-
y = record { fst = Pair.fst x; snd = False }
51+
proj_example : Nat
52+
proj_example = Pair.fst x
5353

54-
z : PairExplCon Nat Nat
55-
z = _,_ Zero (Suc Zero)
54+
-- y : Pair Nat Bool
55+
-- y = record { fst = Pair.fst x; snd = False }
5656

57-
-- (diode-lang): I don't think this statement is actually provable, because we have turned off eta-equality
58-
-- eta-R-two_expl : (A B : Set) (x : PairNoEta A B) →
59-
-- x ≡ record { fst = PairNoEta.fst x ; snd = PairNoEta.snd x }
60-
-- eta-R-two_expl = λ A B → λ x → {!!}
57+
-- z : PairExplCon Nat Nat
58+
-- z = _,_ Zero (Suc Zero)
6159

60+
-- eta-R-two : (A B : Set) (x : Pair A B) →
61+
-- x ≡ record { fst = (const (Pair A B → A) Pair.fst Pair.fst) x ; snd = Pair.snd x }
62+
-- eta-R-two = λ A B → λ x → refl
6263

63-
eta-R-two : (A B : Set) (x : Pair A B)
64-
x ≡ record { fst = (const (Pair A B A) Pair.fst Pair.fst) x ; snd = Pair.snd x }
65-
eta-R-two = λ A B λ x refl
66-
67-
eta-R-two-expl-con : (A B : Set) (x : PairExplCon A B)
68-
x ≡ (_,_ (const (PairExplCon A B A) PairExplCon.fstE PairExplCon.fstE x) (PairExplCon.sndE x))
69-
eta-R-two-expl-con = λ A B λ x refl
64+
-- eta-R-two-expl-con : (A B : Set) (x : PairExplCon A B) →
65+
-- x ≡ (_,_ (const (PairExplCon A B → A) PairExplCon.fstE PairExplCon.fstE x) (PairExplCon.sndE x))
66+
-- eta-R-two-expl-con = λ A B → λ x → refl
7067

7168
-- eta-R-two : (A B : Set) (x : Pair A B) →
7269
-- x ≡ record { fst = (const (Pair A B → A) Pair.fst Pair.fst) x ; snd = Pair.snd x }
7370
-- eta-R-two = λ A B → λ x → {!!}
7471

72+
-- (diode-lang): I don't think this statement is actually provable, because we have turned off eta-equality
73+
-- eta-R-two_expl : (A B : Set) (x : PairNoEta A B) →
74+
-- x ≡ record { fst = PairNoEta.fst x ; snd = PairNoEta.snd x }
75+
-- eta-R-two_expl = λ A B → λ x → {!!}
76+
77+

0 commit comments

Comments
 (0)