2

(以下の抜粋は、このテスト スイートからのもので、ここにある 2 つのファイルからなるプログラムの半分です。)

補助述語を 2 つの方法で定義しました。1 つはトップ レベルで ( と呼ばれますhelper)、もう 1 つはラムダとして ( と呼ばれHelperます)。以下のコードの最後の 3 行では、その補助述語を使用しています。使用するhelperと機能しますが、使用するHelperとエラーが発生します(以下)。

問題は、型レベルの述語の型シグネチャとモード シグネチャを指定できるが、ラムダのモード シグネチャしか指定できないことにあると思われます。(それが問題なら、どうすればいいのかわかりません。)

関連するコードは次のとおりです。

:- pred helper( query, int ).
:- mode helper( in, out ) is nondet.
helper( Q, F ) :-
  inQuery( fiveNumberSpace, Q, F ).

testQAnd = Res :-
    QQF = qqFind( qFind( list.filter( <(3) ) ) )
  , QQC = qqCond( qCond( func( Int )
                         = (if Int > 4 then no else yes) ) )
  , Helper = ( pred( Q :: in, F :: out ) is nondet :-
               inQuery( fiveNumberSpace, Q, F ) )

  % TODO Why can't I use Helper instead of helper for these?
  , solutions( helper( qqAnd( [QQF     ] ) ) , F1 )
  , solutions( helper( qqAnd( [QQF, QQC] ) ) , F2 )
  , solutions( helper( qqAnd( [     QQC] ) ) , F3 )

を使用して得られるエラーは次のHelperとおりです。

Making Mercury/cs/test.c
test.m:098: In clause for function `testQAnd'/0:
test.m:098:   in argument 1 of call to predicate `solutions'/2:
test.m:098:   in unification of argument
test.m:098:   and term `Helper(V_34)':
test.m:098:   type error in argument(s) of higher-order term (with arity 1).
test.m:098:   Functor (Helper) has type `pred(query.query, int)',
test.m:098:   expected type was `((func V_13) = V_14)'.
** Error making `Mercury/cs/test.c'.
4

1 に答える 1