@@ -407,8 +407,11 @@ sigmaTy = UN "Exists"
407existsCon = UN "Ex_intro"
407existsCon = UN "Ex_intro"
409piBind :: [(Name, PTerm)] -> PTerm -> PTerm
409piBind :: [(Name, PTerm)] -> PTerm -> PTerm
410−piBind [] t = t
410+piBind = piBindp expl
412+piBindp :: Plicity -> [(Name, PTerm)] -> PTerm -> PTerm
411−piBind ((n, ty):ns) t = PPi expl n ty (piBind ns t)
414+piBindp p ((n, ty):ns) t = PPi p n ty (piBind ns t)
413tcname (UN ('@':_)) = True
416tcname (UN ('@':_)) = True
414tcname (NS n _) = tcname n
417tcname (NS n _) = tcname n
@@ -455,17 +458,23 @@ expandParams dec ps ns tm = en tm
455 en (PTactics ts) = PTactics (map (fmap en) ts)
458 en (PTactics ts) = PTactics (map (fmap en) ts)
457 en (PQuote (Var n))
460 en (PQuote (Var n))
458− | n `elem` ns = PQuote (Var (dec n))
461+ | n `nselem` ns = PQuote (Var (dec n))
459 en (PApp fc (PRef fc' n) as)
462 en (PApp fc (PRef fc' n) as)
460− | n `elem` ns = PApp fc (PRef fc' (dec n))
463+ | n `nselem` ns = PApp fc (PRef fc' (dec n))
461 (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
464 (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
462 en (PRef fc n)
465 en (PRef fc n)
463− | n `elem` ns = PApp fc (PRef fc (dec n))
466+ | n `nselem` ns = PApp fc (PRef fc (dec n))
464 (map (pexp . (PRef fc)) (map fst ps))
467 (map (pexp . (PRef fc)) (map fst ps))
465 en (PApp fc f as) = PApp fc (en f) (map (fmap en) as)
468 en (PApp fc f as) = PApp fc (en f) (map (fmap en) as)
466 en (PCase fc c os) = PCase fc (en c) (map (pmap en) os)
469 en (PCase fc c os) = PCase fc (en c) (map (pmap en) os)
473+ nselem x (y : xs) | nseq x y = True
474+ | otherwise = nselem x xs
476+ nseq x y = nsroot x == nsroot y
469expandParamsD :: IState ->
478expandParamsD :: IState ->
470 (Name -> Name) -> [(Name, PTerm)] -> [Name] -> PDecl -> PDecl
479 (Name -> Name) -> [(Name, PTerm)] -> [Name] -> PDecl -> PDecl
471expandParamsD ist dec ps ns (PTy syn fc o n ty)
480expandParamsD ist dec ps ns (PTy syn fc o n ty)
@@ -496,9 +505,36 @@ expandParamsD ist dec ps ns (PClauses fc opts n cs)
496 updateps yn nm (((a, t), i):as)
505 updateps yn nm (((a, t), i):as)
497 | (a `elem` nm) == yn = (a, t) : updateps yn nm as
506 | (a `elem` nm) == yn = (a, t) : updateps yn nm as
498 | otherwise = (MN i (show n ++ "_u"), t) : updateps yn nm as
507 | otherwise = (MN i (show n ++ "_u"), t) : updateps yn nm as
499−
508+expandParamsD ist dec ps ns (PData syn fc pd) = PData syn fc (expandPData pd)
510+ -- just do the type decl, leave constructors alone (parameters will be
511+ -- added implicitly)
512+ expandPData (PDatadecl n ty cons)
514+ then PDatadecl (dec n) (piBind ps (expandParams dec ps ns ty)) (map econ cons)
515+ else PDatadecl n (expandParams dec ps ns ty) (map econ cons)
516+ econ (n, t, fc) = (dec n, piBindp expl ps (expandParams dec ps ns t), fc)
517+expandParamsD ist dec ps ns (PParams f params pds)
518+ = PParams f (map (mapsnd (expandParams dec ps ns)) params)
519+ (map (expandParamsD ist dec ps ns) pds)
520+expandParamsD ist dec ps ns (PClass info f cs n params decls)
522+ (map (expandParams dec ps ns) cs)
524+ (map (mapsnd (expandParams dec ps ns)) params)
525+ (map (expandParamsD ist dec ps ns) decls)
526+expandParamsD ist dec ps ns (PInstance info f cs n params ty cn decls)
528+ (map (expandParams dec ps ns) cs)
530+ (map (expandParams dec ps ns) params)
531+ (expandParams dec ps ns ty)
533+ (map (expandParamsD ist dec ps ns) decls)
500expandParamsD ist dec ps ns d = d
534expandParamsD ist dec ps ns d = d
536+mapsnd f (x, t) = (x, f t)
502-- Calculate a priority for a type, for deciding elaboration order
538-- Calculate a priority for a type, for deciding elaboration order
503-- * if it's just a type variable or concrete type, do it early (0)
539-- * if it's just a type variable or concrete type, do it early (0)
504-- * if there's only type variables and injective constructors, do it next (1)
540-- * if there's only type variables and injective constructors, do it next (1)