src/Pure/ProofGeneral/pgip_types.ML
author wenzelm
Mon, 13 May 2013 22:49:00 +0200
changeset 51973 e116eb9e5e17
parent 51972 39052352427d
child 51985 f6c04bf0123d
permissions -rw-r--r--
removed obsolete PGIP material;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     1
(*  Title:      Pure/ProofGeneral/pgip_types.ML
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     2
    Author:     David Aspinall
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     3
21940
fbd068dd4d29 minor tuning;
wenzelm
parents: 21902
diff changeset
     4
PGIP abstraction: types and conversions.
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     5
*)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     6
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     7
signature PGIPTYPES =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     8
sig
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     9
    (* Types and values (used for preferences and dialogs) *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    10
40292
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
    11
    datatype pgiptype =
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
    12
        Pgipnull | Pgipbool | Pgipint of int option * int option | Pgipnat | Pgipreal
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
    13
      | Pgipstring | Pgipconst of string | Pgipchoice of pgipdtype list
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    14
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    15
    and pgipdtype = Pgipdtype of string option * pgiptype  (* type with opt. description *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    16
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    17
    exception PGIP of string
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21858
diff changeset
    18
 
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    19
    (* Values as XML strings *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    20
    val read_pgipint       : (int option * int option) -> string -> int (* raises PGIP *)
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    21
    val read_pgipnat       : string -> int                              (* raises PGIP *)
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    22
    val read_pgipbool      : string -> bool                             (* raises PGIP *)
40292
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
    23
    val read_pgipreal      : string -> real                             (* raises PGIP *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    24
    val read_pgipstring    : string -> string                           (* raises PGIP *)
40292
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
    25
    val real_to_pgstring   : real -> string
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    26
    val int_to_pgstring    : int -> string
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    27
    val bool_to_pgstring   : bool -> string
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    28
    val string_to_pgstring : string -> string
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    29
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    30
    (* PGIP datatypes *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    31
    val pgiptype_to_xml   : pgiptype -> XML.tree
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    32
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    33
    (* XML utils, only for PGIP code *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    34
    val attr           : string -> string -> XML.attributes
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    35
    val opt_attr       : string -> string option -> XML.attributes
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    36
    val opt_attr_map   : ('a -> string) -> string -> 'a option -> XML.attributes
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    37
    val get_attr       : string -> XML.attributes -> string           (* raises PGIP *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    38
    val get_attr_opt   : string -> XML.attributes -> string option
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    39
    val get_attr_dflt  : string -> string -> XML.attributes -> string
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    40
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    41
51973
e116eb9e5e17 removed obsolete PGIP material;
wenzelm
parents: 51972
diff changeset
    42
structure PgipTypes : PGIPTYPES =
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    43
struct
51973
e116eb9e5e17 removed obsolete PGIP material;
wenzelm
parents: 51972
diff changeset
    44
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    45
exception PGIP of string
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    46
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21858
diff changeset
    47
(** XML utils **)
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21858
diff changeset
    48
28017
4919bd124a58 type Properties.T;
wenzelm
parents: 24133
diff changeset
    49
fun get_attr_opt attr attrs = Properties.get attrs attr
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    50
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    51
fun get_attr attr attrs =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    52
    (case get_attr_opt attr attrs of
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    53
         SOME value => value
21973
e7c9b0d3ce82 Quote arguments in PGIP exceptions. Tune comment.
aspinall
parents: 21944
diff changeset
    54
       | NONE => raise PGIP ("Missing attribute: " ^ quote attr))
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    55
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    56
fun get_attr_dflt attr dflt attrs = the_default dflt (get_attr_opt attr attrs)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    57
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    58
fun attr x y = [(x,y)] : XML.attributes
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    59
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    60
fun opt_attr_map f attr_name opt_val = 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    61
    case opt_val of NONE => [] | SOME v => [(attr_name,f v)]
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    62
 (* or, if you've got function-itis: 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    63
    the_default [] (Option.map (single o (pair attr_name) o f) opt_val)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    64
  *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    65
21902
8e5e2571c716 made SML/NJ happy
haftmann
parents: 21867
diff changeset
    66
fun opt_attr attr_name = opt_attr_map I attr_name
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    67
21867
8750fbc28d5c Add abstraction for objtypes and documents.
aspinall
parents: 21858
diff changeset
    68
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    69
(** Types and values **)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    70
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    71
(* readers and writers for values represented in XML strings *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    72
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    73
fun read_pgipbool s =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    74
    (case s of 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    75
         "false" => false 
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    76
       | "true" => true 
21973
e7c9b0d3ce82 Quote arguments in PGIP exceptions. Tune comment.
aspinall
parents: 21944
diff changeset
    77
       | _ => raise PGIP ("Invalid boolean value: " ^ quote s))
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    78
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    79
local
24133
75063f96618f added int type constraints to accomodate hacked SML/NJ;
wenzelm
parents: 23753
diff changeset
    80
    fun int_in_range (NONE,NONE) (_: int) = true
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    81
      | int_in_range (SOME min,NONE) i = min<= i
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    82
      | int_in_range (NONE,SOME max) i = i<=max
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    83
      | int_in_range (SOME min,SOME max) i = min<= i andalso i<=max
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    84
in
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    85
fun read_pgipint range s =
22009
b0c966b30066 approximate Syntax.read_int/nat by Int.fromString -- avoids dependency on Syntax module;
wenzelm
parents: 22003
diff changeset
    86
    (case Int.fromString s of 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    87
         SOME i => if int_in_range range i then i
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    88
                   else raise PGIP ("Out of range integer value: " ^ quote s)
21973
e7c9b0d3ce82 Quote arguments in PGIP exceptions. Tune comment.
aspinall
parents: 21944
diff changeset
    89
       | NONE => raise PGIP ("Invalid integer value: " ^ quote s))
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    90
end;
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    91
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    92
fun read_pgipnat s =
22009
b0c966b30066 approximate Syntax.read_int/nat by Int.fromString -- avoids dependency on Syntax module;
wenzelm
parents: 22003
diff changeset
    93
    (case Int.fromString s of 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
    94
         SOME i => if i >= 0 then i
22009
b0c966b30066 approximate Syntax.read_int/nat by Int.fromString -- avoids dependency on Syntax module;
wenzelm
parents: 22003
diff changeset
    95
                   else raise PGIP ("Invalid natural number: " ^ quote s)
21973
e7c9b0d3ce82 Quote arguments in PGIP exceptions. Tune comment.
aspinall
parents: 21944
diff changeset
    96
       | NONE => raise PGIP ("Invalid natural number: " ^ quote s))
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    97
40292
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
    98
fun read_pgipreal s =
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
    99
    (case Real.fromString s of
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
   100
         SOME x => x
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
   101
       | NONE => raise PGIP ("Invalid floating-point number: " ^ quote s))
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
   102
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   103
(* NB: we can maybe do without xml decode/encode here. *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   104
fun read_pgipstring s =  (* non-empty strings, XML escapes decoded *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   105
    (case XML.parse_string s of
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   106
         SOME s => s
21973
e7c9b0d3ce82 Quote arguments in PGIP exceptions. Tune comment.
aspinall
parents: 21944
diff changeset
   107
       | NONE => raise PGIP ("Expected a non-empty string: " ^ quote s))
28397
389c5e494605 handle _ should be avoided (spurious Interrupt will spoil the game);
wenzelm
parents: 28020
diff changeset
   108
    handle _ => raise PGIP ("Invalid XML string syntax: " ^ quote s)  (* FIXME avoid handle _ *)
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   109
21944
e877a5a78522 signed_string_of_int;
wenzelm
parents: 21940
diff changeset
   110
val int_to_pgstring = signed_string_of_int
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   111
41516
3a70387b5e01 smart_string_of_real: print integer values without fractional part;
wenzelm
parents: 40292
diff changeset
   112
val real_to_pgstring = smart_string_of_real;
3a70387b5e01 smart_string_of_real: print integer values without fractional part;
wenzelm
parents: 40292
diff changeset
   113
40292
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
   114
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   115
fun string_to_pgstring s = XML.text s
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   116
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   117
fun bool_to_pgstring b = if b then "true" else "false"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   118
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   119
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   120
(* PGIP datatypes.
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   121
   
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   122
   This is a reflection of the type structure of PGIP configuration,
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   123
   which is meant for setting up user dialogs and preference settings.
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   124
   These are configured declaratively in XML, using a syntax for types
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   125
   and values which is like a (vastly cut down) form of XML Schema
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   126
   Datatypes.
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   127
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   128
   The prover needs to interpret the strings representing the typed
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   129
   values, at least for the types it expects from the dialogs it
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   130
   configures.  Here we go further and construct a type-safe
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   131
   encapsulation of these values, which would be useful for more
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   132
   advanced cases (e.g. generating and processing forms).  
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   133
*)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   134
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   135
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   136
datatype pgiptype = 
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   137
         Pgipnull                            (* unit type: unique element is empty string *)
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   138
       | Pgipbool                            (* booleans: "true" or "false" *)
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   139
       | Pgipint of int option * int option  (* ranged integers, should be XSD canonical *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   140
       | Pgipnat                             (* naturals: non-negative integers (convenience) *)
40292
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
   141
       | Pgipreal                            (* floating-point numbers *)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   142
       | Pgipstring                          (* non-empty strings *)
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   143
       | Pgipconst of string                 (* singleton type *)
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   144
       | Pgipchoice of pgipdtype list        (* union type *)
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   145
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   146
(* Compared with the PGIP schema, we push descriptions of types inside choices. *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   147
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   148
and pgipdtype = Pgipdtype of string option * pgiptype
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   149
40292
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
   150
datatype pgipuval =
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
   151
    Pgvalnull | Pgvalbool of bool | Pgvalint of int | Pgvalnat of int | Pgvalreal of real
ba13793594f0 support for real valued preferences;
wenzelm
parents: 38228
diff changeset
   152
  | Pgvalstring of string | Pgvalconst of string
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   153
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   154
type pgipval = pgiptype * pgipuval      (* type-safe values *)
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   155
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   156
fun pgipdtype_to_xml (desco,ty) = 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   157
    let
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   158
        val desc_attr = opt_attr "descr" desco
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   159
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   160
        val elt = case ty of
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   161
                      Pgipnull => "pgipnull"
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   162
                    | Pgipbool => "pgipbool"
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   163
                    | Pgipint _ => "pgipint"
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   164
                    | Pgipnat => "pgipint"
41733
775da08dae1b clarified comment -- ancienct PG 3.7.x is still in use;
wenzelm
parents: 41516
diff changeset
   165
                    | Pgipreal => "pgipint"  (*sic!*)  (*required for PG 4.0 and 3.7.x*)
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   166
                    | Pgipstring => "pgipstring"
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   167
                    | Pgipconst _ => "pgipconst"
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   168
                    | Pgipchoice _ => "pgipchoice"
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   169
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   170
        fun range_attr r v = attr r (int_to_pgstring v)
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   171
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   172
        val attrs = case ty of 
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   173
                        Pgipint (SOME min,SOME max) => (range_attr "min" min)@(range_attr "max" max)
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   174
                      | Pgipint (SOME min,NONE) => (range_attr "min" min)
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   175
                      | Pgipint (NONE,SOME max) => (range_attr "max" max)
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   176
                      | Pgipnat => (range_attr "min" 0)
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   177
                      | Pgipconst nm => attr "name" nm
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   178
                      | _ => []
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   179
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   180
        fun destpgipdtype (Pgipdtype x) = x
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   181
28020
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   182
        val typargs = case ty of
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   183
                          Pgipchoice ds => map destpgipdtype ds
1ff5167592ba get rid of tabs;
wenzelm
parents: 28017
diff changeset
   184
                        | _ => []
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   185
    in 
38228
ada3ab6b9085 simplified type XML.tree: embed Markup.T directly, avoid slightly odd triple;
wenzelm
parents: 29606
diff changeset
   186
        XML.Elem ((elt, desc_attr @ attrs), map pgipdtype_to_xml typargs)
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   187
    end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   188
21940
fbd068dd4d29 minor tuning;
wenzelm
parents: 21902
diff changeset
   189
val pgiptype_to_xml = pgipdtype_to_xml o pair NONE
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   190
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   191
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
   192