This module contains the implementation of a preprocessor for Curry programs in order to implement default rules and deterministic operations.
A default rule for a function f
processed by this preprocessor
must be defined as a rule defining the operation f'default
, e.g.,
nlookup key (_ ++ [(key,value)] ++ _) = Just value nlookup'default _ _ = Nothing
The concept of default rules and their implementation are described in
Sergio Antoy, Michael Hanus: Default Rules for Curry Theory and Practice of Logic Programming, Vol. 17, No. 2, pp. 121-147, 2017
An operation can be marked as deterministic by decorating the
result type with DET
, e.g.,
psort :: [Int] -> DET [Int]
The concept of deterministic operations and their implementation are described in
Sergio Antoy, Michael Hanus: Eliminating Irrelevant Non-determinism in Functional Logic Programs Proc. 19th Int. Symp. on Practical Aspects of Declarative Languages, Springer LNCS 10137, pp. 1-18, 2017
This preprocessor can be invoked by the Curry preprocessor currypp
with the option defaultrules
(provided as a FRONTEND option,
see the example programs in the directory examples/DefaultRules
).
Author: Michael Hanus
Version: November 2021
translateDefaultRulesAndDetOps
:: Int -> [String] -> String -> CurryProg -> IO (Maybe CurryProg)
Start default rules/deterministic operations transformation in "preprocessor mode". |
Start default rules/deterministic operations transformation
in "preprocessor mode".
It is assumed that the Curry program passed as the last argument
was read with |