logic - ADT properties in Mercury -


I do not know why Mercury (10.04) can not predict the determination of the next snippet:

 < Code>: - pred load_freqs (int :: in, io.res (list): out, io :: di, io :: uo Load_freqs (CPU, ResFreqs, IO): - open_input (cpu_fn (cpu, "Available_fractures"), resstream, IO), (resistor = IoOk (stream) -> gt; recefrec = io.ok ([]); ResStream = io.error (error), ResFreqs = io.error (Err) .  

This complains:

 cpugear.m: 075: in 'load_freqs' (inside, out, die, u): cpugear.m: 075: Error: determinism Announcement is not satisfied Cpugear.m: 075: Declaration of 'DAT', Estimated 'Assured' Cpugear.m: 080: Integration of 'Ristream' and 'io.error (Err)' may fail Cpugear.m: 076 : The prediction for 'cpugear.load_freqs' / 4: section of cpugear.m: 076: Warning: The variable' CPU 'occurs only once in this area. Cpugear.m: 078: Segment `cpugear.load_freqs' / 4: Cpugear.m: 078: For warnings: The variable `stream 'occurs only once in this area. 

but with IO Res only io.ok / 1 and io.error / 1 . And the next snippet of code is compiled well:

 : - pred read_freqs (io.res (io.input_stream) :: in, io.res (list (float)) :: out, io :: di, io :: uo Read_freqs (io.ok (stream), io.ok ([]), Io, Io. Read_freqs (io.error (error), io.error (error) , IO, IO)  

Update # 1 : It can also decide for:

 : - pred read_freqs (Bool :: in, IO .res (io.input_stream) :: in, io.res (list (float)) :: out, io :: di, io :: uo is Read_freqs (no, resstream, io.ok ([]), Io, IO): - ResStream = io.ok (_) Read_freqs (F, io.ok (_), io.ok ([]), Io, IO): - F = yes Read_freqs (yes , Io.error (error), io.error (A Read_freqs (F, ResStream, io.error (error), IO, IO): - ResStream = io.error (error), F = None Conditionalism (below) My reading of the rules is that for this,  

-> should be replaced with Mercury reference manual with ,

:

If-if-then-else the status is not unsuccessful If so, then the other is equal to the combination of the situation and "again" part, and its determinism is calculated accordingly. Otherwise, if-then the other might fail if the "so" part or "other" part may fail.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -