src/HOLCF/Tools/Domain/domain_syntax.ML
changeset 35460 8cb42aa19358
parent 35446 b719dad322fa
child 35462 f5461b02d754
equal deleted inserted replaced
35459:3d8acfae6fb8 35460:8cb42aa19358
    62         fun esc (c::cs) = if c mem ["'","_","(",")","/"] then "'"::c::esc cs
    62         fun esc (c::cs) = if c mem ["'","_","(",")","/"] then "'"::c::esc cs
    63                           else      c::esc cs
    63                           else      c::esc cs
    64           | esc []      = []
    64           | esc []      = []
    65       in implode o esc o Symbol.explode end;
    65       in implode o esc o Symbol.explode end;
    66 
    66 
    67       fun dis_name_ con =
       
    68           Binding.name ("is_" ^ strip_esc (Binding.name_of con));
       
    69       fun mat_name_ con =
    67       fun mat_name_ con =
    70           Binding.name ("match_" ^ strip_esc (Binding.name_of con));
    68           Binding.name ("match_" ^ strip_esc (Binding.name_of con));
    71       fun pat_name_ con =
    69       fun pat_name_ con =
    72           Binding.name (strip_esc (Binding.name_of con) ^ "_pat");
    70           Binding.name (strip_esc (Binding.name_of con) ^ "_pat");
    73       fun dis (con,args,mx) =
       
    74           (dis_name_ con, dtype->>trT,
       
    75            Mixfix(escape ("is_" ^ Binding.name_of con), [], Syntax.max_pri));
       
    76       (* strictly speaking, these constants have one argument,
    71       (* strictly speaking, these constants have one argument,
    77        but the mixfix (without arguments) is introduced only
    72        but the mixfix (without arguments) is introduced only
    78            to generate parse rules for non-alphanumeric names*)
    73            to generate parse rules for non-alphanumeric names*)
    79       fun freetvar s n =
    74       fun freetvar s n =
    80           let val tvar = mk_TFree (s ^ string_of_int n)
    75           let val tvar = mk_TFree (s ^ string_of_int n)
    93            (mapn pat_arg_typ 1 args)
    88            (mapn pat_arg_typ 1 args)
    94              --->
    89              --->
    95              mk_patT (dtype, mk_ctupleT (map (freetvar "t") (1 upto length args))),
    90              mk_patT (dtype, mk_ctupleT (map (freetvar "t") (1 upto length args))),
    96            Mixfix(escape (Binding.name_of con ^ "_pat"), [], Syntax.max_pri));
    91            Mixfix(escape (Binding.name_of con ^ "_pat"), [], Syntax.max_pri));
    97     in
    92     in
    98     val consts_dis = map dis cons';
       
    99     val consts_mat = map mat cons';
    93     val consts_mat = map mat cons';
   100     val consts_pat = map pat cons';
    94     val consts_pat = map pat cons';
   101     end;
    95     end;
   102 
    96 
   103 (* ----- constants concerning induction ------------------------------------- *)
    97 (* ----- constants concerning induction ------------------------------------- *)
   163     end;
   157     end;
   164     val optional_consts =
   158     val optional_consts =
   165         if definitional then [] else [const_rep, const_abs, const_copy];
   159         if definitional then [] else [const_rep, const_abs, const_copy];
   166 
   160 
   167   in (optional_consts @ [const_when] @ 
   161   in (optional_consts @ [const_when] @ 
   168       consts_dis @ consts_mat @ consts_pat @
   162       consts_mat @ consts_pat @
   169       [const_take, const_finite],
   163       [const_take, const_finite],
   170       (case_trans false :: case_trans true :: (abscon_trans false @ abscon_trans true @ Case_trans)))
   164       (case_trans false :: case_trans true :: (abscon_trans false @ abscon_trans true @ Case_trans)))
   171   end; (* let *)
   165   end; (* let *)
   172 
   166 
   173 (* ----- putting all the syntax stuff together ------------------------------ *)
   167 (* ----- putting all the syntax stuff together ------------------------------ *)