@@ -191,6 +191,7 @@ data IState = IState {
191 idris_implicits :: Ctxt [PArg],
191 idris_implicits :: Ctxt [PArg],
192 idris_statics :: Ctxt [Bool],
192 idris_statics :: Ctxt [Bool],
193 idris_classes :: Ctxt ClassInfo,
193 idris_classes :: Ctxt ClassInfo,
194+ idris_openimpls :: [Name], -- ^ Privileged implementations, will resolve immediately
194 idris_records :: Ctxt RecordInfo,
195 idris_records :: Ctxt RecordInfo,
195 idris_dsls :: Ctxt DSL,
196 idris_dsls :: Ctxt DSL,
196 idris_optimisation :: Ctxt OptInfo,
197 idris_optimisation :: Ctxt OptInfo,
@@ -354,7 +355,7 @@ data IBCWrite = IBCFix FixDecl
354-- | The initial state for the compiler
355-- | The initial state for the compiler
355idrisInit :: IState
356idrisInit :: IState
356idrisInit = IState initContext S.empty []
357idrisInit = IState initContext S.empty []
357− emptyContext emptyContext emptyContext emptyContext
358+ emptyContext emptyContext emptyContext [] emptyContext
358 emptyContext emptyContext emptyContext emptyContext
359 emptyContext emptyContext emptyContext emptyContext
359 emptyContext emptyContext emptyContext emptyContext
360 emptyContext emptyContext emptyContext emptyContext
360 emptyContext emptyContext emptyContext emptyContext
361 emptyContext emptyContext emptyContext emptyContext
@@ -703,6 +704,7 @@ data PDecl' t
703 | PCAF FC Name t -- ^ Top level constant
704 | PCAF FC Name t -- ^ Top level constant
704 | PData (Docstring (Either Err t)) [(Name, Docstring (Either Err t))] SyntaxInfo FC DataOpts (PData' t) -- ^ Data declaration.
705 | PData (Docstring (Either Err t)) [(Name, Docstring (Either Err t))] SyntaxInfo FC DataOpts (PData' t) -- ^ Data declaration.
705 | PParams FC [(Name, t)] [PDecl' t] -- ^ Params block
706 | PParams FC [(Name, t)] [PDecl' t] -- ^ Params block
707+ | POpenInterfaces FC [Name] [PDecl' t] -- ^ Open block/declaration
706 | PNamespace String FC [PDecl' t]
708 | PNamespace String FC [PDecl' t]
707 -- ^ New namespace, where FC is accurate location of the
709 -- ^ New namespace, where FC is accurate location of the
708 -- namespace in the file
710 -- namespace in the file
@@ -733,6 +735,7 @@ data PDecl' t
733 [(Name, Docstring (Either Err t))] -- Parameter docs
735 [(Name, Docstring (Either Err t))] -- Parameter docs
734 SyntaxInfo
736 SyntaxInfo
735 FC [(Name, t)] -- constraints
737 FC [(Name, t)] -- constraints
738+ [Name] -- parent dictionaries to search for constraints
736 Accessibility
739 Accessibility
738 Name -- class
741 Name -- class
@@ -881,6 +884,8 @@ mapPDeclFC f g (PParams fc params decls) =
881 PParams (f fc)
884 PParams (f fc)
882 (map (\(n, ty) -> (n, mapPTermFC f g ty)) params)
885 (map (\(n, ty) -> (n, mapPTermFC f g ty)) params)
883 (map (mapPDeclFC f g) decls)
886 (map (mapPDeclFC f g) decls)
887+mapPDeclFC f g (POpenInterfaces fc ifs decls) =
888+ POpenInterfaces (f fc) ifs (map (mapPDeclFC f g) decls)
884mapPDeclFC f g (PNamespace ns fc decls) =
889mapPDeclFC f g (PNamespace ns fc decls) =
885 PNamespace ns (f fc) (map (mapPDeclFC f g) decls)
890 PNamespace ns (f fc) (map (mapPDeclFC f g) decls)
886mapPDeclFC f g (PRecord doc syn fc opts n nfc params paramdocs fields ctor ctorDoc syn') =
891mapPDeclFC 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
901 (map (mapPDeclFC f g) body)
906 (map (mapPDeclFC f g) body)
902 (fmap (\(n, nfc) -> (n, g nfc)) ctor)
907 (fmap (\(n, nfc) -> (n, g nfc)) ctor)
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) =
905 PInstance doc paramDocs syn (f fc)
910 PInstance doc paramDocs syn (f fc)
906 (map (\(constrN, constrT) -> (constrN, mapPTermFC f g constrT)) constrs)
911 (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)
908 (map (\(en, et) -> (en, mapPTermFC f g et)) pextra)
913 (map (\(en, et) -> (en, mapPTermFC f g et)) pextra)
909 (mapPTermFC f g instTy)
914 (mapPTermFC f g instTy)
@@ -942,10 +947,11 @@ declared (PData _ _ _ _ _ (PDatadecl n _ _ ts)) = n : map fstt ts
942 where fstt (_, _, a, _, _, _, _) = a
947 where fstt (_, _, a, _, _, _, _) = a
943declared (PData _ _ _ _ _ (PLaterdecl n _ _)) = [n]
948declared (PData _ _ _ _ _ (PLaterdecl n _ _)) = [n]
944declared (PParams _ _ ds) = concatMap declared ds
949declared (PParams _ _ ds) = concatMap declared ds
950+declared (POpenInterfaces _ _ ds) = concatMap declared ds
945declared (PNamespace _ _ ds) = concatMap declared ds
951declared (PNamespace _ _ ds) = concatMap declared ds
946declared (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
952declared (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
947declared (PClass _ _ _ _ n _ _ _ _ ms cn cd) = n : (map fst (maybeToList cn) ++ concatMap declared ms)
953declared (PClass _ _ _ _ n _ _ _ _ ms cn cd) = n : (map fst (maybeToList cn) ++ concatMap declared ms)
948−declared (PInstance _ _ _ _ _ _ _ _ _ _ _ _ mn _)
954+declared (PInstance _ _ _ _ _ _ _ _ _ _ _ _ _ mn _)
949 = case mn of
955 = case mn of
950 Nothing -> []
956 Nothing -> []
951 Just n -> [n]
957 Just n -> [n]
@@ -965,10 +971,11 @@ tldeclared (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
965tldeclared (PData _ _ _ _ _ (PDatadecl n _ _ ts)) = n : map fstt ts
971tldeclared (PData _ _ _ _ _ (PDatadecl n _ _ ts)) = n : map fstt ts
966 where fstt (_, _, a, _, _, _, _) = a
972 where fstt (_, _, a, _, _, _, _) = a
967tldeclared (PParams _ _ ds) = []
973tldeclared (PParams _ _ ds) = []
974+tldeclared (POpenInterfaces _ _ ds) = concatMap tldeclared ds
968tldeclared (PMutual _ ds) = concatMap tldeclared ds
975tldeclared (PMutual _ ds) = concatMap tldeclared ds
969tldeclared (PNamespace _ _ ds) = concatMap tldeclared ds
976tldeclared (PNamespace _ _ ds) = concatMap tldeclared ds
970tldeclared (PClass _ _ _ _ n _ _ _ _ ms cn _) = n : (map fst (maybeToList cn) ++ concatMap tldeclared ms)
977tldeclared (PClass _ _ _ _ n _ _ _ _ ms cn _) = n : (map fst (maybeToList cn) ++ concatMap tldeclared ms)
971−tldeclared (PInstance _ _ _ _ _ _ _ _ _ _ _ _ mn _)
978+tldeclared (PInstance _ _ _ _ _ _ _ _ _ _ _ _ _ mn _)
972 = case mn of
979 = case mn of
973 Nothing -> []
980 Nothing -> []
974 Just n -> [n]
981 Just n -> [n]
@@ -984,10 +991,11 @@ defined (PData _ _ _ _ _ (PDatadecl n _ _ ts)) = n : map fstt ts
984 where fstt (_, _, a, _, _, _, _) = a
991 where fstt (_, _, a, _, _, _, _) = a
985defined (PData _ _ _ _ _ (PLaterdecl n _ _)) = []
992defined (PData _ _ _ _ _ (PLaterdecl n _ _)) = []
986defined (PParams _ _ ds) = concatMap defined ds
993defined (PParams _ _ ds) = concatMap defined ds
994+defined (POpenInterfaces _ _ ds) = concatMap defined ds
987defined (PNamespace _ _ ds) = concatMap defined ds
995defined (PNamespace _ _ ds) = concatMap defined ds
988defined (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
996defined (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
989defined (PClass _ _ _ _ n _ _ _ _ ms cn _) = n : (map fst (maybeToList cn) ++ concatMap defined ms)
997defined (PClass _ _ _ _ n _ _ _ _ ms cn _) = n : (map fst (maybeToList cn) ++ concatMap defined ms)
990−defined (PInstance _ _ _ _ _ _ _ _ _ _ _ _ mn _)
998+defined (PInstance _ _ _ _ _ _ _ _ _ _ _ _ _ mn _)
991 = case mn of
999 = case mn of
992 Nothing -> []
1000 Nothing -> []
993 Just n -> [n]
1001 Just n -> [n]
@@ -2174,11 +2182,12 @@ showDeclImp o (PClauses _ _ n cs) = text "pat" <+> text (showCG n) <+> text "\
2174 indent 2 (vsep (map (showCImp o) cs))
2182 indent 2 (vsep (map (showCImp o) cs))
2175showDeclImp o (PData _ _ _ _ _ d) = showDImp o { ppopt_impl = True } d
2183showDeclImp o (PData _ _ _ _ _ d) = showDImp o { ppopt_impl = True } d
2176showDeclImp o (PParams _ ns ps) = text "params" <+> braces (text (show ns) <> line <> showDecls o ps <> line)
2184showDeclImp 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)
2177showDeclImp o (PNamespace n fc ps) = text "namespace" <+> text n <> braces (line <> showDecls o ps <> line)
2186showDeclImp o (PNamespace n fc ps) = text "namespace" <+> text n <> braces (line <> showDecls o ps <> line)
2178showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
2187showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
2179showDeclImp o (PClass _ _ _ cs n _ ps _ _ ds _ _)
2188showDeclImp o (PClass _ _ _ cs n _ ps _ _ ds _ _)
2180 = text "interface" <+> text (show cs) <+> text (show n) <+> text (show ps) <> line <> showDecls o ds
2189 = 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)
2182 = text "implementation" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds
2191 = text "implementation" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds
2183showDeclImp _ _ = text "..."
2192showDeclImp _ _ = text "..."
2184-- showDeclImp (PImport o) = "import " ++ o
2193-- showDeclImp (PImport o) = "import " ++ o