trealla-prolog / trealla

A compact, efficient Prolog interpreter written in plain-old C.
MIT License
252 stars 11 forks source link

must_be/2 "a collection of fragments?" #13

Closed flexoron closed 1 year ago

flexoron commented 1 year ago

v2.0.10

?- must_be(positive_int, +-).
   true.
?- must_be(positive_int, \0 + - 1).
   true.

?- must_be(flix,flux).
   true.
%  may_be
?- must_be(flux,flix).
   true.

Ludwig van B's Symphony No. 10 in E♭ major is a hypothetical work (1827) ... In 2019, artificial intelligence technology was used to reconstruct ... (wikipedia). Not all hope is lost.

flexoron commented 1 year ago

v2.0.11

Because I don't know all about which type identifiers are expected to be processed, I close this issue now.

?- must_be(flix,flux). error(type_error(type,flix),must_be/2). % expected

infradig commented 1 year ago

Look in library/error.pl for the types checked.

On Fri, 19 Aug 2022, 21:42 flexoron, @.***> wrote:

v2.0.11

Because I don't know all about which type identifiers are expected to be processed, I close this issue now.

?- must_be(flix,flux). error(type_error(type,flix),must_be/2). % expected

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/13#issuecomment-1220576383, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSESLJBGFEGFLJFD7533VZ5XKJANCNFSM57AF627Q . You are receiving this because you commented.Message ID: @.***>

flexoron commented 1 year ago

error.pl Currently, the following types are supported: boolean,chars, ...

?- must_be(boolean,hmm).
   true. % unexpected

?- must_be(chars,hmm).
   error(type_error(type,chars),must_be/2). % unexpected

Expecting something like:
?- must_be(character,hmm).
   error(type_error(character,hmm),must_be/2). % expected
infradig commented 1 year ago

Trealla doesn't actually use error.pl, it's just there for reference. Must have missed a few.

On Fri, 19 Aug 2022, 22:13 flexoron, @.***> wrote:

Reopened #13 https://github.com/trealla-prolog/trealla/issues/13.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/13#event-7221755469, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEUN2B337DORLHWO6DTVZ526XANCNFSM57AF627Q . You are receiving this because you commented.Message ID: @.***>

UWN commented 1 year ago

Please note that chars is not a type to be reported. In stead, use either list or character whichever one is violated.

flexoron commented 1 year ago

So, non-characters in a list are not found:

?- must_be(character,1).
   error(type_error(character,1),must_be/2).

?- must_be(list,[a,b,1,c]).
   true.

?- must_be(chars,[a,b,1,c]). % character-lists are not supported?
error(type_error(chars,[a,b,1,c]),must_be/2).  % example (not implemented and not expected)
flexoron commented 1 year ago

Sometimes baffling

?- must_be(character, "a").
   true.
?- must_be(character, [a]).
   error(type_error(character,"a"),must_be/2). % might be reported as ... error(character,[a] ... ?
flexoron commented 1 year ago

v2.0.12

?- must_be(chars,a).
   true.

?- must_be(chars,abc).
   error(type_error(list,abc),must_be/2). % unexpected

?- must_be(chars,"abc").
   error(type_error(list,"abc"),must_be/2). % unexpected

?- must_be(chars,[a,b,c]).
   error(type_error(list,"abc"),must_be/2). % unexpected

?- must_be(chars,[a,b,1,c]).
   error(type_error(list,[a,b,1,c]),must_be/2). % somehow expected, perhaps ...error(character,1)...
flexoron commented 1 year ago

v2.0.13

?- must_be(chars,"").
   true.
?- must_be(chars,[]).
   true.

No character is a character? After all it reads "must be".

infradig commented 1 year ago

Chars means char list. Of which the empty list is an instance.

On Sat, 20 Aug 2022, 09:28 flexoron, @.***> wrote:

v2.0.13

?- must_be(chars,""). true. ?- must_be(chars,[]). true.

No character is a character? After all it reads "must be".

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/13#issuecomment-1221167896, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEUSCTZ3VSB3WAEL6Y3V2AKDFANCNFSM57AF627Q . You are receiving this because you commented.Message ID: @.***>

flexoron commented 1 year ago

In that case the issue can be closed. Thank you very much indeed.