implementation module StdStrictLists; class List l e where { cons :: .e u:(l .e) -> u:(l .e); decons :: !u:(l .e) -> (.e,u:(l .e)); }; class UList e where { cons_u :: !.e u:[#.e] -> u:[#.e]; decons_u :: !u:[#.e] -> (!.e,u:[#.e]); }; class UTSList e where { cons_uts :: !.e !u:[#.e!] -> u:[#.e!]; decons_uts :: !u:[#.e!] -> (!.e,!u:[#.e!]); }; nil :: .(l .e) | List l e; nil = code { pop_a 2 fillh _Nil 0 0 }; nil_u :: .[#.e] | UList e; nil_u = code { pop_a 2 fillh _Nil 0 0 }; nil_uts :: .[#.e!] | UTSList e; nil_uts = code { pop_a 2 fillh _Nil 0 0 }; instance List [] a where { cons a b = [a:b]; decons [a:b] = (a,b); } instance List [!] a where { cons a b = [!a:b]; decons [!a:b] = (a,b); } instance List [ !] a where { cons a b = [a:b!]; decons [a:b!] = (a,b); } instance List [!!] a where { cons a b = [!a:b!]; decons [!a:b!] = (a,b); } instance List [#] a | UList a where { cons a b = cons_u a b; decons a = decons_u a; } instance List [#!] a | UTSList a where { cons a b = cons_uts a b; decons a = decons_uts a; } instance UList a where { cons_u a b = code { print "cons_u of UList a" halt }; decons_u _ = code { print "decons_u of UList a" halt } } instance UList Int where { cons_u a b = code { fill_r _Consi 1 1 1 0 0 pop_b 1 pop_a 1 }; decons_u a = code { repl_r_args 1 1 } } instance UList Real where { cons_u a b = code { fill_r _Consr 1 2 1 0 0 pop_b 2 pop_a 1 }; decons_u a = code { repl_r_args 1 2 } } instance UList Char where { cons_u a b = code { fill_r _Consc 1 1 1 0 0 pop_b 1 pop_a 1 }; decons_u a = code { repl_r_args 1 1 } } instance UList Bool where { cons_u a b = code { fill_r _Consb 1 1 1 0 0 pop_b 1 pop_a 1 }; decons_u a = code { repl_r_args 1 1 } } instance UList File where { cons_u a b = code { fill_r _Consf 1 2 1 0 0 pop_b 2 pop_a 1 }; decons_u a = code { repl_r_args 1 2 } } instance UList {.a} where { cons_u a b = code { fill_r _Consa 2 0 2 0 0 pop_a 2 }; decons_u a = code { repl_r_args 2 0 } } instance UList {!.a} where { cons_u a b = code { fill_r _Consa 2 0 2 0 0 pop_a 2 }; decons_u a = code { repl_r_args 2 0 } } instance UList {#.a} where { cons_u a b = code { fill_r _Consa 2 0 2 0 0 pop_a 2 }; decons_u a = code { repl_r_args 2 0 } } instance UTSList a where { cons_uts a b = code { print "cons_uts of UTSList a" halt }; decons_uts _ = code { print "decons_uts of UTSList a" halt } } instance UTSList Int where { cons_uts a b = code { fill_r _Consits 1 1 1 0 0 pop_b 1 pop_a 1 }; decons_uts a = code { repl_r_args 1 1 } } instance UTSList Real where { cons_uts a b = code { fill_r _Consrts 1 2 1 0 0 pop_b 2 pop_a 1 }; decons_uts a = code { repl_r_args 1 2 } } instance UTSList Char where { cons_uts a b = code { fill_r _Conscts 1 1 1 0 0 pop_b 1 pop_a 1 }; decons_uts a = code { repl_r_args 1 1 } } instance UTSList Bool where { cons_uts a b = code { fill_r _Consbts 1 1 1 0 0 pop_b 1 pop_a 1 }; decons_uts a = code { repl_r_args 1 1 } } instance UTSList File where { cons_uts a b = code { fill_r _Consfts 1 2 1 0 0 pop_b 2 pop_a 1 }; decons_uts a = code { repl_r_args 1 2 } } instance UTSList {.a} where { cons_uts a b = code { fill_r _Consa 2 0 2 0 0 pop_a 2 }; decons_uts a = code { repl_r_args 2 0 } } instance UTSList {!.a} where { cons_uts a b = code { fill_r _Consa 2 0 2 0 0 pop_a 2 }; decons_uts a = code { repl_r_args 2 0 } } instance UTSList {#.a} where { cons_uts a b = code { fill_r _Consa 2 0 2 0 0 pop_a 2 }; decons_uts a = code { repl_r_args 2 0 } }