author | Walther Neuper <walther.neuper@jku.at> |
Tue, 21 Apr 2020 11:28:20 +0200 | |
changeset 59896 | 3a746a4bb75f |
parent 59894 | b9e10434530c |
child 59897 | 8cba439d0454 |
permissions | -rw-r--r-- |
walther@59892 | 1 |
(* Title: "BaseDefinitions/check-unique.sml" |
walther@59892 | 2 |
Author: Walther Neuper |
walther@59892 | 3 |
(c) due to copyright terms |
walther@59892 | 4 |
*) |
walther@59892 | 5 |
|
walther@59892 | 6 |
"-----------------------------------------------------------------------------------------------"; |
walther@59892 | 7 |
"table of contents -----------------------------------------------------------------------------"; |
walther@59892 | 8 |
"-----------------------------------------------------------------------------------------------"; |
walther@59892 | 9 |
"----------- re-build check_pblguh_unique with high order funs ---------------------------------"; |
walther@59892 | 10 |
"-----------------------------------------------------------------------------------------------"; |
walther@59892 | 11 |
"-----------------------------------------------------------------------------------------------"; |
walther@59892 | 12 |
"-----------------------------------------------------------------------------------------------"; |
walther@59892 | 13 |
|
walther@59892 | 14 |
|
walther@59892 | 15 |
"----------- re-build check_pblguh_unique with high order funs ---------------------------------"; |
walther@59892 | 16 |
"----------- re-build check_pblguh_unique with high order funs ---------------------------------"; |
walther@59892 | 17 |
"----------- re-build check_pblguh_unique with high order funs ---------------------------------"; |
walther@59892 | 18 |
(*------- auxiliary format for fn*) |
walther@59892 | 19 |
fun pbl_select_guh pbt = |
walther@59892 | 20 |
let |
walther@59892 | 21 |
val {guh, ...} = (**)(pbt: pbt)(** )(pbt: met)( **) |
walther@59892 | 22 |
in guh end; |
walther@59892 | 23 |
pbl_select_guh: pbt -> guh;(**) |
walther@59892 | 24 |
|
walther@59892 | 25 |
fun met_select_guh pbt = |
walther@59892 | 26 |
let |
walther@59892 | 27 |
val {guh, ...} = (pbt: met) |
walther@59892 | 28 |
in guh end; |
walther@59892 | 29 |
met_select_guh: met -> guh;(**) |
walther@59892 | 30 |
|
walther@59892 | 31 |
(*------- hint: build higher order functions be replacing the selector by a variable argument *) |
walther@59892 | 32 |
(* collect*) |
walther@59892 | 33 |
fun collect select_guh pbls = |
walther@59892 | 34 |
let |
walther@59892 | 35 |
fun node coll (Store.Ptyp (_, [n], ns)) = [select_guh n] @ (nodes coll ns) |
walther@59892 | 36 |
| node _ _ = raise ERROR "collect_guhs: too general Store.Ptyp" |
walther@59892 | 37 |
and nodes coll [] = coll |
walther@59892 | 38 |
| nodes coll (n :: ns) = (node coll n) @ (nodes coll ns); |
walther@59892 | 39 |
in nodes [] pbls end; |
walther@59892 | 40 |
|
walther@59893 | 41 |
collect: ('a -> 'b) -> 'a Store.ptyp list -> 'b list; |
walther@59893 | 42 |
collect pbl_select_guh: pbt Store.ptyp list -> guh list; |
walther@59893 | 43 |
collect met_select_guh: met Store.ptyp list -> guh list; |
walther@59892 | 44 |
|
walther@59892 | 45 |
fun message select store guh = |
walther@59892 | 46 |
if member op = (select store) guh |
walther@59892 | 47 |
then error ("Check_Unique failed with \"" ^ guh ^ "\";\n" ^ |
walther@59892 | 48 |
"use \"sort_guhs()\" for a list of guhs;\n" ^ |
walther@59892 | 49 |
"consider setting \"Check_Unique.on := false\"") |
walther@59892 | 50 |
else (); |
walther@59892 | 51 |
|
walther@59892 | 52 |
message: ('a -> guh list ) -> 'a -> guh -> unit; |
walther@59893 | 53 |
(message (collect pbl_select_guh)): pbt Store.ptyp list -> guh -> unit; |
walther@59893 | 54 |
(message (collect met_select_guh)): met Store.ptyp list -> guh -> unit; |
walther@59892 | 55 |
|
walther@59894 | 56 |
(Check_Unique.collect (#guh : Probl_Def.T -> Check_Unique.guh)): pbt Store.ptyp list -> guh list; |
walther@59896 | 57 |
(Check_Unique.collect (#guh : Meth_Def.T -> Check_Unique.guh)): met Store.ptyp list -> guh list; |
walther@59892 | 58 |
|
walther@59894 | 59 |
val check_pblguh_unique = message (Check_Unique.collect (#guh : Probl_Def.T -> Check_Unique.guh)); |
walther@59893 | 60 |
check_pblguh_unique: pbt Store.ptyp list -> guh -> unit |
walther@59892 | 61 |
; |
walther@59896 | 62 |
val check_metguh_unique = message (Check_Unique.collect (#guh : Meth_Def.T -> Check_Unique.guh)); |
walther@59893 | 63 |
check_metguh_unique: met Store.ptyp list -> guh -> unit |
walther@59892 | 64 |
; |