@@ -191,6 +191,7 @@ data IState = IState {
191191 idris_implicits :: Ctxt [PArg],
192192 idris_statics :: Ctxt [Bool],
193193 idris_classes :: Ctxt ClassInfo,
194+ idris_openimpls :: [Name], -- ^ Privileged implementations, will resolve immediately
194195 idris_records :: Ctxt RecordInfo,
195196 idris_dsls :: Ctxt DSL,
196197 idris_optimisation :: Ctxt OptInfo,
@@ -354,7 +355,7 @@ data IBCWrite = IBCFix FixDecl
354355-- | The initial state for the compiler
355356idrisInit :: IState
356357idrisInit = IState initContext S.empty []
357− emptyContext emptyContext emptyContext emptyContext
358+ emptyContext emptyContext emptyContext [] emptyContext
358359 emptyContext emptyContext emptyContext emptyContext
359360 emptyContext emptyContext emptyContext emptyContext
360361 emptyContext emptyContext emptyContext emptyContext
@@ -703,6 +704,7 @@ data PDecl' t
703704 | PCAF FC Name t -- ^ Top level constant
704705 | PData (Docstring (Either Err t)) [(Name, Docstring (Either Err t))] SyntaxInfo FC DataOpts (PData' t) -- ^ Data declaration.
705706 | PParams FC [(Name, t)] [PDecl' t] -- ^ Params block
707+ | POpenInterfaces FC [Name] [PDecl' t] -- ^ Open block/declaration
706708 | PNamespace String FC [PDecl' t]
707709 -- ^ New namespace, where FC is accurate location of the
708710 -- namespace in the file
@@ -733,6 +735,7 @@ data PDecl' t
733735 [(Name, Docstring (Either Err t))] -- Parameter docs
734736 SyntaxInfo
735737 FC [(Name, t)] -- constraints
738+ [Name] -- parent dictionaries to search for constraints
736739 Accessibility
737740 FnOpts
738741 Name -- class
@@ -881,6 +884,8 @@ mapPDeclFC f g (PParams fc params decls) =
881884 PParams (f fc)
882885 (map (\(n, ty) -> (n, mapPTermFC f g ty)) params)
883886 (map (mapPDeclFC f g) decls)
887+mapPDeclFC f g (POpenInterfaces fc ifs decls) =
888+ POpenInterfaces (f fc) ifs (map (mapPDeclFC f g) decls)
884889mapPDeclFC f g (PNamespace ns fc decls) =
885890 PNamespace ns (f fc) (map (mapPDeclFC f g) decls)
886891mapPDeclFC f g (PRecord doc syn fc opts n nfc params paramdocs fields ctor ctorDoc syn') =
@@ -901,10 +906,10 @@ mapPDeclFC f g (PClass doc syn fc constrs n nfc params paramDocs det body ctor c
901906 (map (mapPDeclFC f g) body)
902907 (fmap (\(n, nfc) -> (n, g nfc)) ctor)
903908 ctorDoc
904−mapPDeclFC f g (PInstance doc paramDocs syn fc constrs cn acc opts cnfc params pextra instTy instN body) =
909+mapPDeclFC f g (PInstance doc paramDocs syn fc constrs pnames cn acc opts cnfc params pextra instTy instN body) =
905910 PInstance doc paramDocs syn (f fc)
906911 (map (\(constrN, constrT) -> (constrN, mapPTermFC f g constrT)) constrs)
907− cn acc opts (g cnfc) (map (mapPTermFC f g) params)
912+ pnames cn acc opts (g cnfc) (map (mapPTermFC f g) params)
908913 (map (\(en, et) -> (en, mapPTermFC f g et)) pextra)
909914 (mapPTermFC f g instTy)
910915 instN
@@ -942,10 +947,11 @@ declared (PData _ _ _ _ _ (PDatadecl n _ _ ts)) = n : map fstt ts
942947 where fstt (_, _, a, _, _, _, _) = a
943948declared (PData _ _ _ _ _ (PLaterdecl n _ _)) = [n]
944949declared (PParams _ _ ds) = concatMap declared ds
950+declared (POpenInterfaces _ _ ds) = concatMap declared ds
945951declared (PNamespace _ _ ds) = concatMap declared ds
946952declared (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
947953declared (PClass _ _ _ _ n _ _ _ _ ms cn cd) = n : (map fst (maybeToList cn) ++ concatMap declared ms)
948−declared (PInstance _ _ _ _ _ _ _ _ _ _ _ _ mn _)
954+declared (PInstance _ _ _ _ _ _ _ _ _ _ _ _ _ mn _)
949955 = case mn of
950956 Nothing -> []
951957 Just n -> [n]
@@ -965,10 +971,11 @@ tldeclared (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
965971tldeclared (PData _ _ _ _ _ (PDatadecl n _ _ ts)) = n : map fstt ts
966972 where fstt (_, _, a, _, _, _, _) = a
967973tldeclared (PParams _ _ ds) = []
974+tldeclared (POpenInterfaces _ _ ds) = concatMap tldeclared ds
968975tldeclared (PMutual _ ds) = concatMap tldeclared ds
969976tldeclared (PNamespace _ _ ds) = concatMap tldeclared ds
970977tldeclared (PClass _ _ _ _ n _ _ _ _ ms cn _) = n : (map fst (maybeToList cn) ++ concatMap tldeclared ms)
971−tldeclared (PInstance _ _ _ _ _ _ _ _ _ _ _ _ mn _)
978+tldeclared (PInstance _ _ _ _ _ _ _ _ _ _ _ _ _ mn _)
972979 = case mn of
973980 Nothing -> []
974981 Just n -> [n]
@@ -984,10 +991,11 @@ defined (PData _ _ _ _ _ (PDatadecl n _ _ ts)) = n : map fstt ts
984991 where fstt (_, _, a, _, _, _, _) = a
985992defined (PData _ _ _ _ _ (PLaterdecl n _ _)) = []
986993defined (PParams _ _ ds) = concatMap defined ds
994+defined (POpenInterfaces _ _ ds) = concatMap defined ds
987995defined (PNamespace _ _ ds) = concatMap defined ds
988996defined (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
989997defined (PClass _ _ _ _ n _ _ _ _ ms cn _) = n : (map fst (maybeToList cn) ++ concatMap defined ms)
990−defined (PInstance _ _ _ _ _ _ _ _ _ _ _ _ mn _)
998+defined (PInstance _ _ _ _ _ _ _ _ _ _ _ _ _ mn _)
991999 = case mn of
9921000 Nothing -> []
9931001 Just n -> [n]
@@ -2174,11 +2182,12 @@ showDeclImp o (PClauses _ _ n cs) = text "pat" <+> text (showCG n) <+> text "\
21742182 indent 2 (vsep (map (showCImp o) cs))
21752183showDeclImp o (PData _ _ _ _ _ d) = showDImp o { ppopt_impl = True } d
21762184showDeclImp o (PParams _ ns ps) = text "params" <+> braces (text (show ns) <> line <> showDecls o ps <> line)
2185+showDeclImp o (POpenInterfaces _ ns ps) = text "open" <+> braces (text (show ns) <> line <> showDecls o ps <> line)
21772186showDeclImp o (PNamespace n fc ps) = text "namespace" <+> text n <> braces (line <> showDecls o ps <> line)
21782187showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
21792188showDeclImp o (PClass _ _ _ cs n _ ps _ _ ds _ _)
21802189 = text "interface" <+> text (show cs) <+> text (show n) <+> text (show ps) <> line <> showDecls o ds
2181−showDeclImp o (PInstance _ _ _ _ cs acc _ n _ _ _ t _ ds)
2190+showDeclImp o (PInstance _ _ _ _ cs _ acc _ n _ _ _ t _ ds)
21822191 = text "implementation" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds
21832192showDeclImp _ _ = text "..."
21842193-- showDeclImp (PImport o) = "import " ++ o