File tree Expand file tree Collapse file tree 10 files changed +129
-3
lines changed Expand file tree Collapse file tree 10 files changed +129
-3
lines changed Original file line number Diff line number Diff line change @@ -332,6 +332,14 @@ compilePat ty (ConP ch i ps) = do
332332-- literal patterns
333333compilePat ty (LitP _ l) = compileLitPat l
334334
335+ -- "Inferred" dot patterns that the programmer has explicitly named are
336+ -- compiled to variable patterns using that given name, wildcards otherwise
337+ compilePat _ (DotP (PatternInfo (PatOVar n) _) _) = do
338+ let n' = hsName $ prettyShow n
339+ checkValidVarName n'
340+ return $ Hs. PVar () n'
341+ compilePat _ (DotP (PatternInfo PatODot _) _) =
342+ return $ Hs. PWildCard ()
335343
336344-- nothing else is supported
337345compilePat _ p = agda2hsErrorM $ " bad pattern:" <?> prettyTCM p
Original file line number Diff line number Diff line change @@ -576,9 +576,7 @@ compileInlineFunctionApp f ty args = do
576576 extractPatName _ = __IMPOSSIBLE__
577577
578578 extractName :: NamedArg DeBruijnPattern -> ArgName
579- extractName (unArg -> np)
580- | Just n <- nameOf np = rangedThing (woThing n)
581- | otherwise = extractPatName (namedThing np)
579+ extractName p = fromMaybe (extractPatName $ namedArg p) (extractMaybeName p)
582580
583581 etaExpand :: NAPs -> Type -> [Term ] -> C Term
584582 etaExpand [] ty args = do
@@ -594,6 +592,8 @@ compileInlineFunctionApp f ty args = do
594592 let ai = domInfo dom
595593 Lam ai . mkAbs (extractName p) <$> etaExpand ps (absBody cod) (raise 1 args ++ [ var 0 ])
596594
595+ extractMaybeName :: NamedArg a -> Maybe ArgName
596+ extractMaybeName p = rangedThing . woThing <$> nameOf (unArg p)
597597
598598compileApp :: Hs. Exp () -> Type -> [Term ] -> C (Hs. Exp () )
599599compileApp = compileApp' . eApp
Original file line number Diff line number Diff line change @@ -103,6 +103,9 @@ import Issue408
103103import CompileTo
104104import RuntimeCast
105105import Issue306
106+ import RelevantDotPattern1
107+ import RelevantDotPattern2
108+ import RelevantDotPattern3
106109
107110{-# FOREIGN AGDA2HS
108111import Issue14
@@ -203,4 +206,7 @@ import Issue408
203206import CompileTo
204207import RuntimeCast
205208import Issue306
209+ import RelevantDotPattern1
210+ import RelevantDotPattern2
211+ import RelevantDotPattern3
206212#-}
Original file line number Diff line number Diff line change 1+ -- Derived from "ErasedPatternLambda"
2+ open import Haskell.Prelude
3+
4+ Scope = List Bool
5+
6+ data Telescope (@0 α : Scope) : @0 Scope → Type where
7+ ExtendTel : ∀ {@0 x β} → Bool → Telescope (x ∷ α) β → Telescope α (x ∷ β)
8+ {-# COMPILE AGDA2HS Telescope #-}
9+
10+ caseTelBind : ∀ {@0 x α β} (tel : Telescope α (x ∷ β))
11+ → ((a : Bool) (rest : Telescope (x ∷ α) β) → @0 tel ≡ ExtendTel a rest → d)
12+ → d
13+ caseTelBind (ExtendTel a tel) f = f a tel refl
14+
15+ {-# COMPILE AGDA2HS caseTelBind #-}
16+
17+ checkSubst' : ∀ {@0 x α β} (t : Telescope α (x ∷ β)) (ty : Bool) (rest : Telescope (x ∷ α) β) → @0 t ≡ ExtendTel ty rest → Bool
18+ checkSubst' t ty rest refl = True
19+ {-# COMPILE AGDA2HS checkSubst' #-}
20+
21+ checkSubst : ∀ {@0 x α β} (t : Telescope α (x ∷ β)) → Bool
22+ checkSubst t = caseTelBind t (checkSubst' t)
23+ {-# COMPILE AGDA2HS checkSubst #-}
Original file line number Diff line number Diff line change 1+ -- Derived from "ErasedPatternLambda"
2+ open import Haskell.Prelude
3+
4+ Scope = List Bool
5+
6+ data Telescope (@0 α : Scope) : @0 Scope → Type where
7+ ExtendTel : ∀ {@0 x β} → Bool → Telescope (x ∷ α) β → Telescope α (x ∷ β)
8+ {-# COMPILE AGDA2HS Telescope #-}
9+
10+ caseTelBind : ∀ {@0 x α β} (tel : Telescope α (x ∷ β))
11+ → ((a : Bool) (rest : Telescope (x ∷ α) β) → @0 tel ≡ ExtendTel a rest → d)
12+ → d
13+ caseTelBind (ExtendTel a tel) f = f a tel refl
14+
15+ {-# COMPILE AGDA2HS caseTelBind #-}
16+
17+ module _ {@0 x α β} (t : Telescope α (x ∷ β)) where
18+ checkSubst' : ∀ (ty : Bool) (rest : Telescope (x ∷ α) β) → @0 t ≡ ExtendTel ty rest → Bool
19+ checkSubst' ty rest refl = True
20+ {-# COMPILE AGDA2HS checkSubst' #-}
21+
22+ checkSubst : Bool
23+ checkSubst = caseTelBind t checkSubst'
24+ {-# COMPILE AGDA2HS checkSubst #-}
Original file line number Diff line number Diff line change 1+ -- Derived from "ErasedPatternLambda"
2+ open import Haskell.Prelude
3+
4+ Scope = List Bool
5+
6+ data Telescope (@0 α : Scope) : @0 Scope → Type where
7+ ExtendTel : ∀ {@0 x β} → Bool → Telescope (x ∷ α) β → Telescope α (x ∷ β)
8+ {-# COMPILE AGDA2HS Telescope #-}
9+
10+ caseTelBind : ∀ {@0 x α β} (tel : Telescope α (x ∷ β))
11+ → ((a : Bool) (rest : Telescope (x ∷ α) β) → @0 tel ≡ ExtendTel a rest → d)
12+ → d
13+ caseTelBind (ExtendTel a tel) f = f a tel refl
14+
15+ {-# COMPILE AGDA2HS caseTelBind #-}
16+
17+ checkSubst' : ∀ {@0 x α β} (t : Telescope α (x ∷ β)) (ty : Bool) (rest : Telescope (x ∷ α) β) → @0 t ≡ ExtendTel ty rest → Bool
18+ checkSubst' (ExtendTel ty' rest') ty rest refl = True
19+ {-# COMPILE AGDA2HS checkSubst' #-}
20+
21+ checkSubst : ∀ {@0 x α β} (t : Telescope α (x ∷ β)) → Bool
22+ checkSubst t = caseTelBind t (checkSubst' t)
23+ {-# COMPILE AGDA2HS checkSubst #-}
Original file line number Diff line number Diff line change @@ -98,4 +98,7 @@ import Issue408
9898import CompileTo
9999import RuntimeCast
100100import Issue306
101+ import RelevantDotPattern1
102+ import RelevantDotPattern2
103+ import RelevantDotPattern3
101104
Original file line number Diff line number Diff line change 1+ module RelevantDotPattern1 where
2+
3+ data Telescope = ExtendTel Bool Telescope
4+
5+ caseTelBind :: Telescope -> (Bool -> Telescope -> d ) -> d
6+ caseTelBind (ExtendTel a tel) f = f a tel
7+
8+ checkSubst' :: Telescope -> Bool -> Telescope -> Bool
9+ checkSubst' t ty rest = True
10+
11+ checkSubst :: Telescope -> Bool
12+ checkSubst t = caseTelBind t (checkSubst' t)
13+
Original file line number Diff line number Diff line change 1+ module RelevantDotPattern2 where
2+
3+ data Telescope = ExtendTel Bool Telescope
4+
5+ caseTelBind :: Telescope -> (Bool -> Telescope -> d ) -> d
6+ caseTelBind (ExtendTel a tel) f = f a tel
7+
8+ checkSubst' :: Telescope -> Bool -> Telescope -> Bool
9+ checkSubst' t ty rest = True
10+
11+ checkSubst :: Telescope -> Bool
12+ checkSubst t = caseTelBind t (checkSubst' t)
13+
Original file line number Diff line number Diff line change 1+ module RelevantDotPattern3 where
2+
3+ data Telescope = ExtendTel Bool Telescope
4+
5+ caseTelBind :: Telescope -> (Bool -> Telescope -> d ) -> d
6+ caseTelBind (ExtendTel a tel) f = f a tel
7+
8+ checkSubst' :: Telescope -> Bool -> Telescope -> Bool
9+ checkSubst' (ExtendTel ty' rest') ty rest = True
10+
11+ checkSubst :: Telescope -> Bool
12+ checkSubst t = caseTelBind t (checkSubst' t)
13+
You can’t perform that action at this time.
0 commit comments