_SystemStrictLists.icl 3.68 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
implementation module _SystemStrictLists;

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 :: u:(l .e) | List l e , [u<=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 {
Camil Staps's avatar
Camil Staps committed
90 91
		fill_r _Consr 1 1 1 0 0
		pop_b 1
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
		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 {
Camil Staps's avatar
Camil Staps committed
186 187
		fill_r _Consrts 1 1 1 0 0
		pop_b 1
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
		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
	}
}