158 val empty : T = Name_Space.empty_table "locale"; |
158 val empty : T = Name_Space.empty_table "locale"; |
159 val extend = I; |
159 val extend = I; |
160 val merge = Name_Space.join_tables (K merge_locale); |
160 val merge = Name_Space.join_tables (K merge_locale); |
161 ); |
161 ); |
162 |
162 |
163 val intern = Name_Space.intern o #1 o Locales.get; |
163 val locale_space = Name_Space.space_of_table o Locales.get; |
|
164 val intern = Name_Space.intern o locale_space; |
164 fun check thy = #1 o Name_Space.check (Context.Theory thy) (Locales.get thy); |
165 fun check thy = #1 o Name_Space.check (Context.Theory thy) (Locales.get thy); |
165 |
166 |
166 fun extern thy = Name_Space.extern (Proof_Context.init_global thy) (#1 (Locales.get thy)); |
167 fun extern thy = Name_Space.extern (Proof_Context.init_global thy) (locale_space thy); |
167 |
168 |
168 fun markup_extern ctxt = |
169 fun markup_extern ctxt = |
169 Name_Space.markup_extern ctxt (#1 (Locales.get (Proof_Context.theory_of ctxt))); |
170 Name_Space.markup_extern ctxt (locale_space (Proof_Context.theory_of ctxt)); |
170 |
171 |
171 fun markup_name ctxt name = markup_extern ctxt name |-> Markup.markup; |
172 fun markup_name ctxt name = markup_extern ctxt name |-> Markup.markup; |
172 fun pretty_name ctxt name = markup_extern ctxt name |> Pretty.mark_str; |
173 fun pretty_name ctxt name = markup_extern ctxt name |> Pretty.mark_str; |
173 |
174 |
174 val get_locale = Symtab.lookup o #2 o Locales.get; |
175 val get_locale = Option.map #2 oo (Name_Space.lookup_key o Locales.get); |
175 val defined = Symtab.defined o #2 o Locales.get; |
176 val defined = is_some oo get_locale; |
176 |
177 |
177 fun the_locale thy name = |
178 fun the_locale thy name = |
178 (case get_locale thy name of |
179 (case get_locale thy name of |
179 SOME (Loc loc) => loc |
180 SOME (Loc loc) => loc |
180 | NONE => error ("Unknown locale " ^ quote name)); |
181 | NONE => error ("Unknown locale " ^ quote name)); |
187 (map (fn d => (d |> apsnd (rpair Morphism.identity), serial ())) dependencies, |
188 (map (fn d => (d |> apsnd (rpair Morphism.identity), serial ())) dependencies, |
188 Inttab.empty)))) #> snd); |
189 Inttab.empty)))) #> snd); |
189 (* FIXME Morphism.identity *) |
190 (* FIXME Morphism.identity *) |
190 |
191 |
191 fun change_locale name = |
192 fun change_locale name = |
192 Locales.map o apsnd o Symtab.map_entry name o map_locale o apsnd; |
193 Locales.map o Name_Space.map_table_entry name o map_locale o apsnd; |
193 |
194 |
194 |
195 |
195 (** Primitive operations **) |
196 (** Primitive operations **) |
196 |
197 |
197 fun params_of thy = snd o #parameters o the_locale thy; |
198 fun params_of thy = snd o #parameters o the_locale thy; |