Post has attachment

I was recently interviewed on Playing with Prolog, a YouTube channel with short videos about Prolog. I spoke about Mercury and introduced modes and determinisms.

Is there regular expression library or something similar available in Mercury? If not, what existing libraries might be helpful in making one, and would anyone find a regex library useful?

Post has attachment

Post has attachment

The first of the 14.01-beta release is now available from the downloads page.

Post has attachment

Post has attachment
Prolog API to Functional Trailing?

Dear All,

I am just reading:

Is there a Prolog API for the trailing. So that I can use functional trailing  from within Prolog without much C programming. I only need to be able to install a Prolog goal which is called once when the trail does an undo.

Best Regards

Regarding the use of existential typed data types, they are needed when an output parameter is constrained to some type class.  In the following code, the compiler complains about the first function, but the second compiles fine.

:- func errorRng = R <= ePRNG(R).

errorRng = Result :-
   random.init(2, Result).

:- type sup ->
   some [R]  (sup(R)  => ePRNG(R)).

:- func worksRng = sup.

worksRng = Result :-
   random.init(2, R),
   Result = 'new sup'(R).

I'm developing a module for a console based application where I want to put some predicates to edit the fields of some structure. I've started with the following predicate:

:- pred editField(string, pred(string, F), func(T, F) = T, T, T, io.state, io.state).
:- mode editField(in, in(pred(in, out) is semidet), in, in, out, di, uo) is det.
:- mode editField(in, in(pred(in, out) is det), in, in, out, di, uo) is det.

editField(FieldName, PredParseStringField, FuncUpdateField, !Variable, !IO) :-
io.format("Enter a new value for %s: ", [s(FieldName)], !IO),
io.read_line_as_string(ILine, !IO),
ILine = ok(Line)
PredParseStringField(string.strip(Line), NewValue)
!:Variable = FuncUpdateField(!.Variable, NewValue)
io.print("Invalid value!\n", !IO),
editField(FieldName, PredParseStringField, FuncUpdateField, !Variable, !IO)
editField(FieldName, PredParseStringField, FuncUpdateField, !Variable, !IO)

Now I want to put the information about the field name, the predicate to parse a string to a field value and the field update function into some existentially typed data type such as:

:- type field(T, F) ->
n  :: string,
p  :: pred(string, F),
u  :: func(T, F) = T

:- type field(T) ->
some [F]
f(field(T, F)).

But now I'm having problems when I want to deconstruct some field(T) value.  The compiler complains about the following code:
:- pred editFieldSup(field(T), T, T, io.state, io.state).
:- mode editFieldSup(in(ffield), in, out, di, uo) is det.

editFieldSup(FField, !Variable, !IO) :-
FField = f(Field).

I have previously run into problems when I tried to combine predicates with existential data types.  Is this some feature that is not supported by the compiler?

Post has attachment
My Ph.D. dissertation is now available on the Mercury Website.
Wait while more posts are being loaded