Home
Manual
Contents
1. WuiSpec e WuiSpec f WuiSpec g gt WuiSpec h gt WuiSpec i WuiSpec j gt WuiSpec k gt WuiSpec 1 WuiSpec m wList WuiSpec a WuiSpec a WUI combinator for list structures where the list elements are vertically aligned in a table wListWithHeadings String WuiSpec a WuiSpec a Add headings to a standard WUI for list structures wHList WuiSpec a WuiSpec a WUI combinator for list structures where the list elements are horizontally aligned in a table wMatrix WuiSpec a WuiSpec a WUI for matrices i e list of list of elements visualized as a matrix wMaybe WuiSpec Bool WuiSpec a a WuiSpec Maybe a WUI for Maybe values It is constructed from a WUI for Booleans and a WUI for the potential values Nothing corresponds to a selection of False in the Boolean WUI The value WUI is shown after the Boolean WUI 195 wCheckMaybe WuiSpec a gt HtmlExp a WuiSpec Maybe a A WUI for Maybe values where a check box is used to select Just The value WUI is shown after the check box wRadioMaybe WuiSpec a gt HtmlExp gt HtmlExp a WuiSpec Maybe a A WUI for Maybe values where radio buttons are used to switch between Nothing and Just The value WUI is shown after the radio button WUI wEither WuiSpec a WuiSpec b WuiSpec Either a b WUI for union types Here we provide only the implementation for Either ty
2. an input element first arg with an associated event handler tpyically a submit button data HtmlForm The data type for representing HTML forms active web pages and return values of HTML forms Exported constructors e HtmlForm String FormParam gt HtmlExp HtmlForm HtmlForm t ps hs an HTML form with title t optional parameters e g cookies ps and contents hs e HtmlAnswer String String HtmlForm HtmlAnswer t c an answer in an arbitrary format where t is the content type e g text plain and c is the contents data FormParam The possible parameters of an HTML form The parameters of a cookie FormCookie are its name and value and optional parameters expiration date domain path e g the path makes the cookie valid for all documents on the server security which are collected in a list 164 Exported constructors FormCookie String gt String CookieParam FormParam FormCookie name value params a cookie to be sent to the client s browser FormCSS String FormParam FormCSS s a URL for a CSS file for this form FormJScript String FormParam FormJScript s a URL for a Javascript file for this form FormOnSubmit String FormParam FormOnSubmit s a JavaScript statement to be executed when the form is submitted i e lt form onsubmit s gt FormTarget String FormPara
3. Int HtmlExp A selection button with a reference a list of name value pairs and a preselected item in this list The names are shown in the selection and the value is returned for the selected name multipleSelection CgiRef gt String String Bool HtmlExp 173 A selection button with a reference and a list of name value flag pairs The names are shown in the selection and the value is returned if the corresponding name is selected If flag is True the corresonding name is initially selected If more than one name has been selected all values are returned in one string where the values are separated by newline lt code gt 1n lt code gt characters hiddenfield String gt String HtmlExp A hidden field to pass a value referenced by a fixed name This function should be used with care since it may cause conflicts with the CGI based implementation of this library htmlQuote String String Quotes special characters lt gt amp umlauts in a string as HTML special characters htmlIsoUmlauts String String Translates umlauts in iso 8859 1 encoding into HTML special characters addAttr HtmlExp gt String String HtmlExp Adds an attribute name value pair to an HTML element addAttrs HtmlExp gt String String HtmlExp Adds a list of attributes name value pair to an HTML element addClass HtmlExp String HtmlExp Adds a class attribute to an HTML element
4. KiC52 The Kiel Curry System Version 2 User Manual Version 0 5 0 of 2015 11 30 Michael Hanus editor Additional Contributors Bernd Brafel Bjorn Peem ller Fabian Reck Jan Rasmus Tikovsky 1 University of Kiel Germany mh informatik uni kiel de 2 University of Kiel Germany bbr informatik uni kiel de 3 University of Kiel Germany bjp informatik uni kiel de 4 University of Kiel Germany fre informatik uni kiel de 4 University of Kiel Germany jrt informatik uni kiel de Contents Preface 1 Overview of KiCS2 LI dream o occiso ad AE a Me e a A BOR LI GemralUs 2 chee Dba Raw a A a a dd o de DDS Lao HOC Loss dad di A a a a A Ee 14 Modals ti Rit ci oa a Ch a a a ee he ee 2 Using the Interactive Environment of KiCS2 21i e 1 AER 2a Commands ol RICSZ ue e a a a RA A A O id A 23 Oitiomwat RiGee ob sk wink a PRR de a A da eS 24 Bource Pile prone o eae siasa hbad eee hee ee ewe eS La Using KiCS2 la Bate Mode aosda cao g oaoa at ec ae aai a 2 6 Command Line Editing lt se 262 0005 atea ae a ee ee es 2T CUSHION ak a a Geek Rk Ew AA 28 Emacs Interface 2 ceo bee AREER ds ee eS Extensions 31 Narrowing om Imt Literals e s gt ae ad a ra Se He eae ee 3 2 Recursive Variable Bindings 0 0 0 eee ee ee mo Panetional Paters oidor SE A ek ee ee O 3 4 Order of Pattern Matching 0 000 eee ee ee ee Recognized Syntax of Curry 4 1 Notational Conventions 2
5. WuiSpec i WUI combinator for constructors of arity 8 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types w9Tuple WuiSpec a WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f gt WuiSpec g WuiSpec h gt WuiSpec i gt WuiSpec a b c d e f g h i WUI combinator for tuples of arity 9 wCons9 la gt b gt c gt d gt e gt f gt g gt h gt i j WuiSpec a gt WuiSpec b gt WuiSpec c gt WuiSpec d gt WuiSpec e gt WuiSpec f WuiSpec g WuiSpec h gt WuiSpec i WuiSpec j WUI combinator for constructors of arity 9 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types wi0Tuple WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f gt WuiSpec g gt WuiSpec h WuiSpec i WuiSpec j gt WuiSpec a b c d e f g h i j WUI combinator for tuples of arity 10 wCons10 a gt b gt c gt d gt e gt f gt g gt h gt i gt j gt k gt WuiSpec a gt WuiSpec b WuiSpec c WuiSpec d gt WuiSpec e WuiSpec f WuiSpec g gt WuiSpec h gt WuiSpec i WuiSpec j WuiSpec k WUI combinator for constructors of arity 10 The first argument is the ternary con structor The further arguments are the WUI specifications for
6. _ x is considered as syntactic sugar for the expanded definition f _ x _ f x where f 42 _ x However as patterns are usually implemented in a more efficient way without introducing auxiliary operations 3 4 Order of Pattern Matching Curry allows multiple occurrences of pattern variables in standard patterns These are an abbrevi ation of equational constraints between pattern variables Functional patterns might also contain multiple occurrences of pattern variables For instance the operation f _ x _ x _ x returns all elements with at least two occurrences in a list If functional patterns as well as multiple occurrences of pattern variables occur in a pattern defining an operation there are various orders to match an expression against such an operation In the current implementation the order is as follows 1 Standard pattern matching First it is checked whether the constructor patterns match Thus functional patterns and multiple occurrences of pattern variables are ignored 2 Functional pattern matching In the next phase functional patterns are matched but occur rences of standard pattern variables in the functional patterns are ignored 3 Non linear patterns If standard and functional pattern matching is successful the equational constraints which correspond to multiple occurrences pattern variables are solved 4 Guards Finally the guards supplied by the programmer are chec
7. gt HtmlExp Provides a style for a block of HTML elements The style argument is the name of a style class defined in an external style sheet This element is used in contrast to style for larger blocks of HTML elements since a line break is placed before and after these elements inline HtmlExp gt HtmlExp Joins a list of HTML elements into a single HTML element Although this construction has no rendering it is sometimes useful for programming when several HTML elements must be put together block HtmlExp HtmlExp Joins a list of HTML elements into a block A line break is placed before and after these elements button String gt CgiRef gt String IO HtmlForm HtmlExp Submit button with a label string and an event handler resetbutton String HtmlExp Reset button with a label string imageButton String gt CgiRef String gt 10 HtmlForm gt HtmlExp Submit button in form of an imag textfield CgiRef String HtmlExp 172 Input text field with a reference and an initial contents password CgiRef HtmlExp Input text field where the entered text is obscured with a reference textarea CgiRef Int Int String HtmlExp Input text area with a reference height width and initial contents checkbox CgiRef String HtmlExp A checkbox with a reference and a value The value is returned if checkbox is on 9999 other
8. A Exported top level test functions ae nodule testList testl test2 test3 OK all OK prefix Loading module testSort f AAA y A A Figure 2 Snapshot of CurryTest s graphical interface tested i e the corresponding assertions are checked and the results Ok or failure are reported together with the name of each assertion For our example above we obtain the following successful protocol Testing module TestList OK OK all OK prefix All tests successfully passed There is also a graphical interface that summarizes the results more nicely In order to start this 199 interface one has to add the parameter window or w e g executing a test suite by currytest window TestList or currytest w TestList A snapshot of the interface is shown in Figure 2 34 9 CurryPP A Preprocessor for Curry Programs The Curry preprocessor currypp implements various transformations on Curry source programs It supports some experimental language extensions that might become part of the standard parser of Curry in some future version Currently the Curry preprocessor supports the following extensions that will be described below in more detail Integrated code This extension allows to integrate code written in some other language into Curry programs like regular expressions format specifications printf HTML and XML code Sequential rules If this feature is
9. CPattern CRhs gt CExpr CTyped CExpr CTypeExpr CExpr CRecConstr String String gt String String CExpr gt CExpr 210 e CRecUpdate CExpr gt String String CExpr CExpr data CLiteral Data type for representing literals occurring in an expression It is either an integer a float or a character constant Exported constructors e CIntc Int CLiteral e CFloatc Float CLiteral e CCharc Char CLiteral e CStringc String CLiteral data CStatement Data type for representing statements in do expressions and list comprehensions Exported constructors e CSExpr CExpr CStatement e CSPat CPattern CExpr CStatement e CSLet CLocalDecl CStatement data CCaseType Type of case expressions Exported constructors e CRigid CCaseType e CFlex CCaseType Exported functions version String Current version of AbstractCurry pre String gt String String Converts a string into a qualified name of the Prelude A 5 2 Library AbstractCurry Files This library defines various I O actions to read Curry programs and transform them into the AbstractCurry representation and to write AbstractCurry files Assumption an abstract Curry program is stored in file with extension acy in the subdirectory CUrry 211 Exported functions readCurry String IO CurryProg I O action which parses a Curry program and returns the corresponding t
10. IO action to run a Widget in a new window runInitGUI String Widget GuiPort IO ReconfigureItem gt 10 IO action to run a Widget in a new window The GUI events are processed after executing an initial action on the GUI runInitGUIwithParams String String gt Widget gt GuiPort gt I0 ReconfigureItem gt I0 O IO action to run a Widget in a new window The GUI events are processed after executing an initial action on the GUI runControlledGUI String gt Widget String GuiPort I0 Handle gt I0 O Runs a Widget in a new GUI window and process GUI events In addition an event handler is provided that process messages received from an external stream identified by a handle third argument This operation is useful to run a GUI that should react on user events as well as messages written to the given handle runConfigControlledGUI String gt Widget String GuiPort gt I0 Reconfigureltem gt Handle gt 10 82 Runs a Widget in a new GUI window and process GUI events In addition an event handler is provided that process messages received from an external stream identified by a handle third argument This operation is useful to run a GUI that should react on user events as well as messages written to the given handle runInitControlledGUI String Widget String gt GuiPort gt 10 gt GuiPort IO Reconfigureltem gt H
11. alignment of information inside a widget where the argument must be n ne e se s sw wW nw or center Background String ConfItem Background the background color Foreground String ConfItem Foreground the foreground color Handler Event GuiPort gt IO Reconfigureltem ConfItem Handler an event handler associated to a widget The event handler returns a list of widget ref configuration pairs that are applied after the handler in order to configure GUI widgets Height Int ConfItem Height the height of a widget chars for text pixels for graphics CheckInit String ConfItem CheckInit initial value for checkbuttons CanvasItems CanvasItem ConflItem Canvasltems list of items contained in a canvas List String gt ConfItem List list of values shown in a listbox 76 e Menu Menultem ConfItem Menu the items of a menu button e WRef WidgetRef ConfItem WRef a reference to this widget e Text String ConfItem Text an initial text contents e Width Int gt ConfItem Width the width of a widget chars for text pixels for graphics e Fill ConfItem Fill fill widget in both directions e FillX Confltem Fil1X fill widget in horizontal direction e FillY Confltem FillY fill widget in vertical direction e TclOption String ConfIte
12. gt IO String Bool Combines two actions and combines their results Used by the currytest tool checkAssertion String String Bool gt IO String Bool Assertion a gt IO String Bool Executes and checks an assertion and process the result by an I O action Used by the currytest tool writeAssertResult String Bool IO Int Prints the results of assertion checking If failures occurred the return code is positive Used by the currytest tool showTestMod Int String gt I0 Sends message to GUI for showing test of a module Used by the currytest tool showTestCase Int gt String Bool gt IO String Bool Sends message to GUI for showing result of executing a test case Used by the currytest tool showTestEnd Int gt 10 Sends message to GUI for showing end of module test Used by the currytest tool showTestCompileError Int gt 10 Sends message to GUI for showing compilation errors in a module test Used by the currytest tool A 2 3 Library Char Library with some useful functions on characters Exported functions isAscii Char Bool Returns true if the argument is an ASCII character isLatini Char Bool Returns true if the argument is an Latin 1 character isAsciiLower Char Bool Returns true if the argument is an ASCII lowercase letter 50 isAsciiUpper Char Bool Returns true if the argument is an ASCII uppercase letter i
13. w4Tuple WuiSpec a gt WuiSpec b WuiSpec c WuiSpec d gt WuiSpec a b c d WUI combinator for tuples of arity 4 wCons4 la gt b gt c gt d gt e gt WuiSpec a gt WuiSpec b gt WuiSpec c gt WuiSpec d gt WuiSpec e WUI combinator for constructors of arity 4 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types wCons4JS Maybe JSExp gt JSExp gt a gt b gt lt c gt d gt e WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e woTuple WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec a b c d e WUI combinator for tuples of arity 5 wConsb a gt b gt c gt d gt e gt f WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e WuiSpec f WUI combinator for constructors of arity 5 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types wCons5JS Maybe JSExp gt JSExp gt a gt b gt c gt d gt e gt f gt WuiSpec a gt WuiSpec b gt WuiSpec c WuiSpec d gt WuiSpec e gt WuiSpec f 192 w6Tuple WuiSpec a WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f WuiSpec a b c d e f WUI combinator for tuples of arity 6 wCons6 la gt b gt c gt d
14. Adds sound to given HTML form The functions adds two different declarations for sound one invented by Microsoft for the internet explorer one introduced for netscape As neither is an official part of HTML addsound might not work on all systems and browsers The greatest chance is by using sound files in MID format pageEnc String PageParam An encoding scheme for a HTML page pageCSS String PageParam A URL for a CSS file for a HTML page pageMetaInfo String String PageParam 168 Meta information for a HTML page The argument is a list of attributes included in the meta tag in the header for this page pageLinkInfo String String PageParam Link information for a HTML page The argument is a list of attributes included in the link tag in the header for this page pageBodyAttr String String gt PageParam Optional attribute for the body element of the web page More than one occurrence is allowed i e all such attributes are collected page String HtmlExp gt HtmlPage A basic HTML web page with the default encoding standardPage String gt HtmlExp HtmlPage A standard HTML web page where the title is included in the body as the first header addPageParam HtmlPage PageParam HtmlPage Adds a parameter to an HTML page htxt String HtmlExp Basic text as HTML expression The text may contain special HTML chars like lt gt amp which w
15. Int get number of missing arguments if expression is combined letBinds Expr gt Int Expr get indices of variables in let declaration letBody Expr Expr get body of let declaration freeVars Expr gt Int get variable indices from declaration of free variables freeExpr Expr Expr get expression from declaration of free variables orExps Expr Expr get expressions from or expression caseType Expr CaseType get case type of case expression caseExpr Expr Expr get scrutinee of case expression caseBranches Expr BranchExpr get branch expressions from case expression isVar Expr Bool is expression a variable isLit Expr Bool is expression a literal expression isComb Expr Bool 238 is expression combined isLet Expr Bool is expression a let expression isFree Expr Bool is expression a declaration of free variables isOr Expr Bool is expression an or expression isCase Expr Bool is expression a case expression trExpr Int gt a gt Literal gt a gt CombType gt String String gt a gt a gt Int a gt a gt a gt Int gt a gt a gt a gt a gt a gt CaseType gt a gt b gt a gt Pattern gt a gt b gt a gt TypeExpr a gt Expr gt a transform expression updVars Int Expr Expr Expr update all variables in given expression updLiterals
16. Literal gt Expr Expr Expr update all literals in given expression updCombs CombType gt String String Expr gt Expr Expr Expr update all combined expressions in given expression updLets Int Expr Expr Expr gt Expr Expr update all let expressions in given expression updFrees Int gt Expr Expr gt Expr Expr update all free declarations in given expression updOrs Expr gt Expr Expr gt Expr Expr update all or expressions in given expression updCases CaseType Expr BranchExpr Expr Expr Expr update all case expressions in given expression updBranches Pattern Expr BranchExpr Expr Expr update all case branches in given expression 239 updTypeds Expr gt TypeExpr Expr gt Expr Expr update all typed expressions in given expression isFuncCall Expr Bool is expression a call of a function where all arguments are provided isFuncPartCall Expr Bool is expression a partial function call isConsCall Expr Bool is expression a call of a constructor isConsPartCall Expr Bool is expression a partial constructor call isGround Expr Bool is expression fully evaluated allVars Expr gt Int get all variables also pattern variables in expression rnmAllVars Int gt Int gt Expr Expr rename all variables also in patterns in expression updQNames
17. The document char c contains the literal character c The character should not be a newline n the function line should be used for line breaks string String Doc The document string s concatenates all characters in s using line for newline characters and char for all other characters It is used instead of text whenever the text contains newline characters int Int Doc The document int i shows the literal integer i using text float Float Doc The document float f shows the literal float f using text lparen Doc The document lparen contains a left parenthesis rparen Doc 115 The document rparen contains a right parenthesis langle Doc The document langle contains a left angle lt rangle Doc The document rangle contains a right angle gt lbrace Doc The document lbrace contains a left brace rbrace Doc The document rbrace contains a right brace lbracket Doc The document lbracket contains a left square bracket rbracket Doc The document rbracket contains a right square bracket squote Doc The document squote contains a single quote dquote Doc The document dquote contains a double quote semi Doc The document semi contains a semi colon colon Doc The document colon contains a colon comma Doc The document comma contains a comma space Doc The document space contains a single
18. gt String String Xm1Exp Takes an XML converter and returns a function that extends XML data with the representation of a given value xmlRead XmlConv a Elem b gt XmlExp gt b Takes an XML converter and an XML expression and returns a corresponding Curry value xmlShow XmlConv a Elem b gt b XmlExp Takes an XML converter and a value and returns a corresponding XML expression int XmlConv NotRepeatable NoElem Int Creates an XML converter for integer values Integer values must not be used in repe titions and do not represent XML elements float XmlConv NotRepeatable NoElem Float Creates an XML converter for float values Float values must not be used in repetitions and do not represent XML elements char XmlConv NotRepeatable NoElem Char Creates an XML converter for character values Character values must not be used in repetitions and do not represent XML elements string XmlConv NotRepeatable NoElem String Creates an XML converter for string values String values must not be used in repeti tions and do not represent XML elements 1 XmlConv a b c gt XmlConv a b c gt XmlConv ab c Parallel composition of XML converters element String XmlConv a b c gt XmlConv Repeatable Elem c Takes an arbitrary XML converter and returns a converter representing an XML element that contains the corresponding data XML elements may be used in repetitions empty a XmlCo
19. Expr Rule e External String Rule data CaseType Data type for classifying case expressions Case expressions can be either flexible or rigid in Curry Exported constructors e Rigid CaseType e Flex CaseType data CombType Data type for classifying combinations i e a function constructor applied to some arguments Exported constructors e FuncCall CombType FuncCall a call to a function where all arguments are provided e ConsCall CombType ConsCall a call with a constructor at the top all arguments are provided e FuncPartCall Int gt CombType FuncPartCall a partial call to a function i e not all arguments are provided where the parameter is the number of missing arguments e ConsPartCall Int CombType ConsPartCall a partial call to a constructor i e not all arguments are provided where the parameter is the number of missing arguments data Expr 225 Data type for representing expressions Remarks if then else expressions are represented as function calls if el then e2 else e3 is represented as Comb FuncCall Prelude if_then_else e1 e2 e3 Higher order applications are represented as calls to the external function apply For instance the rule app fx fx is represented as Rule 0 1 Comb FuncCall Prelude apply Var 0 Var 1 A conditional rule is represented as a call to an external function cond where the fi
20. String IO Maybe String Look up a specific configuration variable as specified by user in his rc file Upper case lowercase is ignored for the variable names getRcVars String I0 Maybe String Look up configuration variables as specified by user in his rc file Uppercase lowercase is ignored for the variable names splitModuleFileName String String gt String String Split the FilePath of a module into the directory prefix and the FilePath correspond ing to the module name For instance the call splitModuleFileName Data Set lib Data Set curry evaluates to 1ib Data Set curry This can be useful to compute output directories while retaining the hierarchical module structure splitModuleldentifiers String gt String Split up the components of a module identifier For instance splitModuleldentifiers Data Set evaluates to Data Set joinModuleldentifiers String String Join the components of a module identifier For instance joinModuleIdentifiers Data Set evaluates to Data Set stripCurrySuffix String String Strips the suffix curry or lcurry from a file name 58 modNameToPath String String Transforms a hierarchical module name into a path name i e replace the dots in the name by directory separator chars currySubdir String Name of the sub directory where auxiliary files fint fcy etc are stored inCurrySubdir St
21. UACY FrontendTarget UACY Untyped without type checking AbstractCurry file ending with uacy HTML FrontendTarget HTML colored HTML representation of source program CY FrontendTarget CY source representation employed by the frontend FrontendParams Abstract data type for representing parameters supported by the front end of the Curry compiler Exported constructors Exported functions curryCompiler String The name of the Curry compiler e g pakcs or kics2 curryCompilerMajorVersion Int The major version number of the Curry compiler curryCompilerMinorVersion Int The minor version number of the Curry compiler curryRuntime String The name of the run time environment e g sicstus swi or ghc 57 curryRuntimeMajorVersion Int The major version number of the Curry run time environment curryRuntimeMinorVersion Int The minor version number of the Curry run time environment installDir String Path of the main installation directory of the Curry compiler rcFileName 10 String The name of the file specifying configuration parameters of the current distribution This file must have the usual format of property files see description in module Prop ertyFile rcFileContents 10 String String Returns the current configuration parameters of the distribution This action yields the list of pairs var val getRcVar
22. Visibility gt Visibility FuncDecl gt FuncDecl update visibility of function updFuncType TypeExpr TypeExpr gt FuncDecl gt FuncDecl update type of function updFuncRule Rule gt Rule gt FuncDecl gt FuncDecl update rule of function isExternal FuncDecl Bool is function externally defined allVarsInFunc FuncDecl gt Int 235 get variable names in a function declaration funcArgs FuncDecl gt Int get arguments of function if not externally defined funcBody FuncDecl Expr get body of function if not externally defined funcRHS FuncDecl Expr rnmAllVarsInFunc Int Int gt FuncDecl gt FuncDecl rename all variables in function updQNamesInFunc String String gt String String FuncDecl gt FuncDecl update all qualified names in function updFuncArgs Int gt Int FuncDecl gt FuncDecl update arguments of function if not externally defined updFuncBody Expr Expr FuncDecl gt FuncDecl update body of function if not externally defined trRule Int gt Expr gt a gt String gt a gt Rule gt a transform rule ruleArgs Rule gt Int get rules arguments if it s not external ruleBody Rule Expr get rules body if it s not external ruleExtDecl Rule String get rules external declaration isRuleExternal Rule Bool is rule external updRule Int
23. a gt a a gt a gt a 10a gt a gt IOa IO version of mapFamily mapChildFamiliesI0 a gt b b gt a gt b gt b b gt b gt b gt ID b a gt IOa IO version of mapChildFamilies evalFamilyI0 a gt a a gt a gt a gt I0 Maybe a a gt IOa IO version of eval Family evalChildFamiliesI0 a gt b b gt a gt b gt b b gt D gt b gt IO Maybe b gt a gt IOa IO version of evalChildFamilies A 3 12 Library Rewriting Term Library for representation of first order terms This library is the basis of other libraries for the manipulation of first order terms e g unification of terms Therefore this library also defines other structures like term equations or positions Exported types type Varldx Int Variable index identifying a variable type TermEq a Term a Term a The type of an equation type TermEqs a Term a Term a The type of multiple equations type Pos Int 160 A position in a term represented as a list of integers Arguments are enumerated from 0 data Term Representation of a first order terms It is parameterized over the kind of function symbols e g strings Exported constructors e TermVar Int Terma TermVar i The variable with index i e TermCons a gt Term a gt Term a TermCons name args The constructor with constructor name an
24. curry or lcurry into the name of the file containing the corresponding AbstractCurry program untypedAbstractCurryFileName String String Transforms a name of a Curry program with or without suffix curry or lcurry into the name of the file containing the corresponding untyped AbstractCurry program readAbstractCurryFile String IO CurryProg 212 I O action which reads an AbstractCurry program from a file in acy format In contrast to readCurry this action does not parse a source program Thus the argument must be the name of an existing file with suffix acy containing an AbstractCurry program in acy format and the result is a Curry term representing this program It is currently predefined only in Curry2Prolog tryReadACYFile String gt IO Maybe CurryProg Tries to read an AbstractCurry file and returns e Left err where err specifies the error occurred e Right prog where prog is the AbstractCurry program writeAbstractCurryFile String CurryProg 10 Writes an AbstractCurry program into a file in acy format The first argument must be the name of the target file with suffix acy A 5 3 Library AbstractCurry Select This library provides some useful operations to select components in AbstractCurry programs i e it provides a collection of selector functions for AbstractCurry Exported functions imports CurryProg g
25. gt a Dynamic Int gt a Transaction Stores a new entry in the database under a given key The transaction fails if the key already exists cleanDB Int gt a Dynamic gt Transaction Deletes all entries from the database associated with a predicate closeDBHandles 10 Closes all database connections Should be called when no more database access will be necessary showTError TError String Transforms a transaction error into a string 99 A 2 26 Library List Library with some useful operations on lists Exported functions elemIndex a gt a Maybe Int Returns the index i of the first occurrence of an element in a list as Just i otherwise Nothing is returned elemIndices a gt a gt Int Returns the list of indices of occurrences of an element in a list find a gt Bool gt a gt Maybe a Returns the first element e of a list satisfying a predicate as Just e otherwise Nothing is returned findIndex a gt Bool gt a Maybe Int Returns the index i of the first occurrences of a list element satisfying a predicate as Just i otherwise Nothing is returned findIndices a Bool gt a gt Int Returns the list of indices of list elements satisfying a predicate nub a gt a Removes all duplicates in the argument list nubBy a a Bool gt a gt a Removes all duplicates in the argument list acco
26. gt e gt f g gt WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d gt WuiSpec e gt WuiSpec f WuiSpec g WUI combinator for constructors of arity 6 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types wCons6JS Maybe JSExp gt JSExp gt a gt b gt c gt d gt e gt gt go gt WuiSpec a WuiSpec b WuiSpec c WuiSpec d gt WuiSpec e WuiSpec f gt WuiSpec g w Tuple WuiSpec a WuiSpec b gt WuiSpec c WuiSpec d WuiSpec e gt WuiSpec f WuiSpec g gt WuiSpec a b c d e f g WUI combinator for tuples of arity 7 wCons7 la gt b gt c gt d gt e gt f gt g gt h gt WuiSpec a gt WuiSpec b gt WuiSpec c gt WuiSpec d WuiSpec e WuiSpec f gt WuiSpec g WuiSpec h WUI combinator for constructors of arity 7 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types wCons7JS Maybe JSExp gt JSExp gt a gt b gt c gt d gt e gt f f gt 8g gt b gt WuiSpec a WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e WuiSpec f gt WuiSpec g gt WuiSpec h wSTuple WuiSpec a WuiSpec b WuiSpec c WuiSpec d WuiSpec e gt WuiSpec f gt WuiSpec g gt WuiSpec h WuiSpec a b c d e f g h WUI combinator for tuples of a
27. in Curry corre sponds to the AbstractCurry term COp n fix p Exported constructors e COp String String gt CFixity gt Int gt COpDecl data CFixity Data type for operator associativity Exported constructors e CInfixOp CFixity e CInfixlOp CFixity 208 e CInfixrOp CFixity data CFuncDecl Data type for representing function declarations A function declaration in AbstractCurry is a term of the form CFunc name arity visibility type CRules eval CRule rule1 rulek and represents the function name defined by the rules rule1 rulek Note the variable indices are unique inside each rule Thus a function declaration consists of the name arity type and a list of rules A function declaration with the constructor CmtFunc is similarly to CFunc but has a comment as an additional first argument This comment could be used by pretty printers that generate a readable Curry program containing documentation comments Exported constructors e CFunc String String Int gt CVisibility CTypeExpr gt CRule gt CFuncDecl e CmtFunc String gt String String Int gt CVisibility CTypeExpr gt CRule gt CFuncDecl data CRule The general form of a function rule It consists of a list of patterns left hand side and the right hand side for these patterns Exported constructors e CRule CPattern gt CRhs gt CRule data CRhs Right hand side of a
28. makeValid String String isRelative String Bool isAbsolute String Bool A 2 15 Library Findall Library with some operations for encapsulating search Note that some of these operations are not fully declarative i e the results depend on the order of evaluation and program rules There are newer and better approaches the encpasulate search in particular set functions see module SetFunctions which should be used This library is included only for compatibility with PAKCS Exported functions getAllValues a gt 10 a Gets all values of an expression currently via an incomplete depth first strategy Conceptually all values are computed on a copy of the expression i e the evaluation of the expression does not share any results Moreover the evaluation suspends as long as the expression contains unbound variables Similar to Prolog s findall 67 getSomeValue a 10 a Gets a value of an expression currently via an incomplete depth first strategy The expression must have a value otherwise the computation fails Conceptually the value is computed on a copy of the expression i e the evaluation of the expression does not share any results Moreover the evaluation suspends as long as the expression contains unbound variables allValues a gt la Returns all values of an expression currently via an incomplete depth first strategy Conceptually all values are computed on a copy of
29. pPrint 107 ppRule 244 253 ppTVarIndex 244 252 ppType 221 ppTypeDecl 243 252 ppTypeDecls 243 252 ppTypeExp 244 252 ppTypeExport 243 251 ppTypeExpr 244 252 ppVarIndex 244 253 prdfs 12 pre 150 171 211 pre 151 preprocessor 35 pretty 120 prettyCurryProg 220 printAllValuesWith 128 printMemInfo 122 293 printValues 133 printValuesWith 128 ProcessInfo 120 product 102 profile 13 profileSpace 122 profileSpaceNF 122 profileTime 122 profileTimeNF 122 profiling 6 13 Prog 222 progFuncs 230 255 progImports 230 255 progName 230 255 progOps 230 255 program documentation 28 testing 33 progTypes 230 255 prompt 13 ProtocolMsg 49 publicConsNames 213 publicFuncNames 213 publicTypeNames 213 punctuate 112 pureio 13 puts 62 pVars 218 QName 206 222 Qualification 219 QualMode 242 qualMode 242 Query 95 Queue 142 quickSort 157 quiet 60 radio_main 173 radio_main_off 173 radio_other 173 range 233 258 rangle 116 rarrow 117 rbrace 116 rbracket 116 rcFileContents 58 rcFileName 58 rcParams 59 readAbstractCurryFile 212 readCgiServerMsg 177 readCompleteFile 91 readCSV 54 readCSVFile 54 readCSVFileWithDelims 54 readCSVWithDelims 54 readCurry 47 212 readCurryWithImports 212 readCurryWithParseOptions 212 readFileWithXmlDocs 198 readFlatCurry 47 228 readFlatCurryFile 229 readFlatCurrylInt 229 readFlatCurryIntWithImports
30. rts 15 Rule 224 ruleArgs 236 261 ruleBody 236 261 ruleExtDecl 236 261 runCgiServerCmd 177 runConfigControlledGUI 82 runControlledGUI 82 runcurry 40 runFormServerWithKey 175 runFormServerWithKeyAndFormParams 175 runGUI 82 runGUIwithParams 82 runHandlesControlledGUI 83 runInitControlledGUI 83 runInitGUI 82 runInitGUIwithParams 82 runInitHandlesControlledGUI 83 runJustT 97 runPassiveGUI 82 runQ 96 runT 96 safe 14 satisfy 107 scan 271 scanl 103 scanli 103 scanr 103 scanri1 103 scc 155 sClose 105 134 searchPathSeparator 64 SearchTree 7 127 138 searchTreeSize 127 139 second 71 section 170 SeekMode 88 295 seeText 84 setExtended 60 select 132 setFullPath 60 selection 173 setHtmlDir 60 selectionInitial 173 setIndentWith 220 selectValue 132 setInsertEquivalence 155 semi 116 setLayoutChoice 220 semiBraces 114 setLogfile 60 semiBracesSpaced 114 setModName 220 sendMail 179 setOverlapWarn 60 sendMailWithOptions 179 setPageWith 219 sep 112 setQualification 220 separatorChar 63 setQuiet 59 seqi 202 SetRBT 155 seq2 203 setRBT2list 156 seq3 203 setSpaced 114 seq4 204 setSpecials 60 seq5 204 setValue 83 seq6 205 showAFCSubst 267 segStrActions 50 showCProg 220 sequenceMaybe 104 showCSV 54 sequenceT 97 showCurryExpr 247 sequenceT_ 98 showCurryld 247 set 114 showCurryType 247 set functions 7 showCurryVar 247 seto 130
31. showHtmlExps HtmlExp gt String Transforms a list of HTML expressions into string representation showHtmlExp HtmlExp String Transforms a single HTML expression into string representation showHtmlPage HtmlPage String Transforms HTML page into string representation getUrlParameter IO String Gets the parameter attached to the URL of the script For instance if the script is called with URL http script cgi parameter then parameter is returned by this I O action Note that an URL parameter should be URL encoded to avoid the appearance of characters with a special meaning Use the functions urlencoded2string and string2urlencoded to decode and encode such parameters respectively urlencoded2string String String 174 Translates urlencoded string into equivalent ASCII string string2urlencoded String String Translates arbitrary strings into equivalent urlencoded string getCookies I0 String String Gets the cookies sent from the browser for the current CGI script The cookies are represented in the form of name value pairs since no other components are important here coordinates CgiRef gt String Maybe Int Int For image buttons retrieve the coordinates where the user clicked within the image runFormServerWithKey String gt String IO HtmlForm gt 10 The server implementing an HTML form possibly containing input fields It
32. then return loadpath else return dirName head args tail loadpath read Flat Curry FilelnLoadPath Current function analysis Nondeterministic Select analysis Deterministic operation Figure 1 Snapshot of the main window of CurryBrowser analyses are local i e they need only to consider the local definition of this function e g Calls directly Overlapping rules Pattern completeness where other analyses are global i e they consider the definitions of all functions directly or indirectly called by this function e g Depends on Solution complete Set valued Finally there are a few additional tools integrated into CurryBrowser for instance to visualize the import relation between all modules as a dependency graph These tools are available through the Tools menu More details about the use of CurryBrowser and all built in analyses are available through the Help menu of CurryBrowser 32 8 CurryTest A Tool for Testing Curry Programs Curry Test is a simple tool in the KiCS2 distribution to write and run repeatable tests Curry Test simplifies the task of writing test cases for a module and executing them The tool is easy to use Assume one has implemented a module MyMod and wants to write some test cases to test its functionality making regression tests in future versions etc For this purpose there is a system library Assertion Section A 2 2 which
33. 0 FieldPat y labeled pattern n gt 0 QLabelID Pattern see lexicon ValueDeclaration ValueDeclaration y n gt 0 FunctionDeclaration PatternDeclaration VariableID VariableID free n gt 0 FixityDeclaration Pattern Expr where LocalDefs InfixExpr TypeExpr expression type signature 24 InfirExpr NoOpExpr FunctExpr BasicExpr Alt GdAlts FBind Qual Stmt Literal GDataConstr FunctionName QFunctionName InfirExpr NoOpExpr QOp InfixExpr InfixExpr InfixExpr NoOpExpr SimplePat SimplePat gt Expr let LocalDefs in Expr if Expr then Expr else Expr case Expr of Alt Alt fcase Expr of Alt Alt do Stmt Stmt Expr FunctExpr FunctExpr BasicExpr QVariablelD QFunctionName GDataConstr Literal Expr Expr Expry Expr Expr Expr Expr Expr 1 L Expr Qual Qual J C InfixExpr QOp gt Q0p y InfixExpr QDataConstr FBind FBind y FBind labeled update n gt 0 BasicExpr gpataConstr FBind Pattern gt Expr where LocalDefs Pattern GdAlts where LocalDefs InfixExpr gt Expr GdAlts QLabelID Expr Expr let LocalDefs Pattern lt Expr Expr let LocalDefs Pattern lt Expr Int Char String Float O GLP QDataConstr FunctionID InfixOpID QFunctionID Q
34. Combines two transactions to execute them in sequence The result of the first trans action is ignored sequenceT Transaction a gt Transaction a Executes a list of transactions sequentially and computes a list of all results Snttp sqlite org lang 97 sequenceT_ Transaction a Transaction Executes a list of transactions sequentially ignoring their results mapT a Transaction b a gt Transaction b Applies a function that yields transactions to all elements of a list executes the trans action sequentially and collects their results mapT_ a Transaction b gt a Transaction Applies a function that yields transactions to all elements of a list executes the trans actions sequentially and ignores their results persistentSQLite String gt String gt String gt Int a Dynamic This function is used instead of dynamic or persistent to declare predicates whose facts are stored in an SQLite database If the provided database or the table do not exist they are created automatically when the declared predicate is accessed for the first time Multiple column names can be provided if the second argument of the predicate is a tuple with a matching arity Other record types are not supported If no column names are provided a table with a single column called info is created Columns of name rowid are not supported and lead to a run time error e
35. Define additional run time options passed to the executable generated by the Glasgow Haskell Compiler i e the parameters RTS o RTS are passed to the executable For in stance setting the option set rts H5b12m has the effect that the minimum heap size is set to 512 megabytes args arguments Define run time arguments passed to the executable generated by the Glasgow Haskell Compiler For instance setting the option set args first second has the effect that the I O operation getArgs see library System Section A 2 40 returns the value first second 2 4 Source File Options If the evaluation of operations in some main module loaded into KiCS2 requires specific options like an iterative deepening search strategy one can also put these options into the source code of this module in order to avoid setting these options every time when this module is loaded Such source file options must occur before the module header i e before the first declaration module header imports fixity declaration defining rules etc occurring in the module Each source file option must be in a line of the form KiCS2_OPTION opt e where opt is an option that can occur in a set command compare Section 2 3 Such a line in the source code which is a comment according to the syntax of Curry has the effect that this option is set by the KiCS2 command set opt whenever this module is load
36. Doc Indentation A 5 17 Library FlatCurry Annotated Goodies This library provides selector functions test and update operations as well as some useful auxiliary functions for FlatCurry data terms Most of the provided functions are based on general trans formation functions that replace constructors with user defined functions For recursive datatypes the transformations are defined inductively over the term structure This is quite usual for trans formations on FlatCurry terms so the provided functions can be used to implement specific trans formations without having to explicitly state the recursion Essentially the tedious part of such transformations descend in fairly complex term structures is abstracted away which hopefully makes the code more clear and brief Exported types type Update ab b gt b gt aa 254 Exported functions trProg String String TypeDec1 gt AFuncDecl a gt OpDecl gt b gt AProg a gt b transform program progName AProg a String get name from program progImports AProg a gt String get imports from program progTypes AProg a gt TypeDec1 get type declarations from program progFuncs AProg a gt AFuncDecl a get functions from program progOps AProg a OpDec1 get infix operators from program updProg String gt String gt String String gt TypeDecl gt TypeDec11 AFuncDecl a
37. Header 1 s a level 1 header with title s in a markdown document Exported functions fromMarkdownText String MarkdownElem Parse markdown document from its textual representation removeEscapes String gt String Remove the backlash of escaped markdown characters in a string 180 markdownEscapeChars String Escape characters supported by markdown markdownText2HTML String HtmlExpl Translate a markdown text into a partial HTML document markdownText2CompleteHTML String String String Translate a markdown text into a complete HTML text that can be viewed as a stan dalone document by a browser The first argument is the title of the document markdownText2LaTeX String String Translate a markdown text into a partial LaTeX document All characters with a special meaning in LaTeX like dollar or ampersand signs are quoted markdownText2LaTeXWithFormat String String String String Translate a markdown text into a partial LaTeX document where the first argument is a function to translate the basic text occurring in markdown elements to a LaTeX string For instance one can use a translation operation that supports passing mathematical formulas in LaTeX style instead of quoting all special characters markdownText2CompleteLaTeX String String Translate a markdown text into a complete LaTeX document that can be formatted as a standalone document formatMa
38. String String ARule a gt ARule a 261 update rule updRuleArgs Int a gt Int a ARule a gt ARule a update rules arguments updRuleBody AExpr a AExpr a ARule a gt ARule a update rules body updRuleExtDecl String String ARule a ARule a update rules external declaration allVarsInRule ARule a gt Int get variable names in a functions rule rnmAllVarsInRule Int gt Int gt ARule a gt ARule a rename all variables in rule updQNamesInRule String String String String ARule a gt ARule a update all qualified names in rule trCombType a gt Int gt a gt a gt Int gt a gt CombType gt a transform combination type isCombTypeFuncCall CombType Bool is type of combination FuncCall isCombTypeFuncPartCall CombType Bool is type of combination FuncPartCall isCombTypeConsCall CombType Bool is type of combination ConsCall isCombTypeConsPartCall CombType Bool is type of combination ConsPartCall missingArgs CombType Int varNr AExpr a gt Int get internal number of variable literal AExpr a Literal 262 get literal if expression is literal expression combType AExpr a CombType get combination type of a combined expression combName AExpr a gt String String get name of a combined expression combArgs AExpr a gt AExpr a get arguments of a combined expre
39. This is the default value The transformation is based on pre computed values for the prelude operations in order to decide whether the value False is not required as a result of a Boolean equality Hence the transformation can be efficiently performed without any complex anal ysis full Perform a complete required values analysis of the program see 4 and use this informa tion to optimize programs In most cases this does not yield better results so that the fast mode is sufficient Hence to turn off this optimization one can either modify the flag bindingoptimization in the configuration file kics2rc or dynamically pass this change to the invocation of KiCS2 by Dbindingoptimization no 27 6 CurryDoc A Documentation Generator for Curry Programs CurryDoc is a tool in the KiCS2 distribution that generates the documentation for a Curry program i e the main module and all its imported modules in HTML format The generated HTML pages contain information about all data types and functions exported by a module as well as links between the different entities Furthermore some information about the definitional status of functions like rigid flexible external complete or overlapping definitions are provided and combined with documentation comments provided by the programmer A documentation comment starts at the beginning of a line with also in literate pro grams All documentation comments immediately
40. anchor String HtmlExp HtmlExp An anchored text with a hypertext reference inside a document ulist HtmlExp HtmlExp Unordered list olist HtmlExp gt HtmlExp Ordered list litem HtmlExp HtmlExp A single list item usually not explicitly used dlist C HtmlExp HtmlExp HtmlExp Description list table HtmlExp HtmlExp Table with a matrix of items where each item is a list of HTML expressions headedTable HtmlExp gt HtmlExp Similar to table but introduces header tags for the first row addHeadings HtmlExp gt HtmlExp gt HtmlExp Add a row of items where each item is a list of HTML expressions as headings to a table If the first argument is not a table the headings are ignored hrule HtmlExp Horizontal rule 171 breakline HtmlExp Break a line image String String HtmlExp Image styleSheet String HtmlExp Defines a style sheet to be used in this HTML document style String gt HtmlExp gt HtmlExp Provides a style for HTML elements The style argument is the name of a style class defined in a style definition see styleSheet or in an external style sheet see form and page parameters FormCSS and PageCSs textstyle String String HtmlExp Provides a style for a basic text The style argument is the name of a style class defined in an external style sheet blockstyle String HtmlExp
41. answerText 168 anyC 53 APattern 251 appendStyledValue 84 appendValue 84 applyAt 142 applyE 217 applyF 217 applyJust 217 applyMaybe 217 applySubst 161 applyV 217 AProg 250 ArgDescr 72 ArgOrder 72 args 15 argTypes 214 234 259 Arity 206 250 Array 141 ARule 250 as pattern 18 asin 70 asinh 70 assert 55 assertEqual 49 assertEqualI0 49 assertI0 49 55 Assertion 49 assertSolutions 49 assertTrue 49 assertValues 49 aString 201 at 117 atan 70 atanh 70 attr 201 backslash 117 bar 117 baseName 63 282 baseType 216 best 7 bfs 12 bfsStrategy 127 139 bgBlack 119 bgBlue 120 bgCyan 120 bgGreen 119 bgMagenta 120 bgRed 119 bgWhite 120 bgYellow 120 bindings 13 binomial 87 bitAnd 87 bitNot 87 bitOr 87 bitTrunc 87 bitXor 87 black 119 blink 170 blinkRapid 118 blinkSlow 118 block 172 blockstyle 172 blue 119 bold 118 170 boolType 216 both 71 bquotes 115 braces 115 brackets 115 BranchExpr 227 branchExpr 240 265 branchPattern 240 265 breakline 172 buildGr 149 Button 85 button 172 CalendarTime 135 calendarTimeToString 137 callFrontend 61 callFrontendWithParams 61 CanvasItem 80 CanvasScroll 85 caseBranches 238 263 caseExpr 238 263 CaseType 225 caseType 238 263 cat 112 categorizeByltemKey 163 catMaybes 104 cBranch 217 CCaseType 211 cChar 218 CConsDecl 207 center 170 CExpr 210 CField
42. b gt AExpr a gt b transform expression updVars a gt Int gt AExpr a gt AExpr a gt AExpr a update all variables in given expression updLiterals a gt Literal gt AExpr a gt AExpr a gt AExpr a update all literals in given expression updCombs a gt CombType gt String String a AExpr a AExpr a gt AExpr a AExpr a update all combined expressions in given expression updLets a gt Int a AExpr a AExpr a gt AExpr a AExpr a gt AExpr a update all let expressions in given expression updFrees a gt Int a AExpr a gt AExpr a AExpr a AExpr a update all free declarations in given expression updOrs a gt AExpr a gt AExpr a gt AExpr a gt AExpr a gt AExpr a update all or expressions in given expression 264 updCases a gt CaseType AExpr a gt ABranchExpr a AExpr a AExpr a gt AExpr a update all case expressions in given expression updBranches APattern a gt AExpr a ABranchExpr a AExpr a gt AExpr a update all case branches in given expression updTypeds a gt AExpr a gt TypeExpr AExpr a gt AExpr a gt AExpr a update all typed expressions in given expression isFuncCall AExpr a gt Bool is expression a call of a function where all arguments are provided isFuncPartCall AExpr a Bool is expression a partial function call
43. context causes an error if the Node is not present in the Graph lab Graph a b gt Int Maybe a Find the label for a Node neighbors Graph a b gt Int gt Int Find the neighbors for a Node suc Graph a b gt Int gt Int Find all Nodes that have a link from the given Node pre Graph a b gt Int gt Int Find all Nodes that link to to the given Node lsuc Graph a b gt Int gt Int b Find all Nodes and their labels which are linked from the given Node 150 lpre Graph a b gt Int gt Int b Find all Nodes that link to the given Node and the label of each link out Graph a b gt Int gt Int Int b Find all outward bound LEdges for the given Node inn Graph ab gt Int gt Int Int b Find all inward bound LEdges for the given Node outdeg Graph a b gt Int Int The outward bound degree of the Node indeg Graph a b gt Int gt Int The inward bound degree of the Node deg Graph ab gt Int gt Int The degree of the Node gelem Int Graph a b gt Bool True if the Node is present in the Graph equal Graph a b Graph a b Bool graph equality node a Int Int b a Int gt Int The Node in a Context lab a Int Int b a Int b The label in a Context labNode a Int Int b a Int gt Int b The LNode from a Context neighbors a Int Int b a Int gt Int All Nodes linked to or from in a Cont
44. dea bc gt d gt e gt Values a 130 Combinator to transform a function of arity 4 into a corresponding set function that uses a given strategy to compute its values set5 la gt b gt c gt d gt e gt f gt a gt b gt c gt d gt oe gt Values f Combinator to transform a function of arity 5 into a corresponding set function set5With SearchTree a gt ValueSequence a gt b gt c gt de gt f a bd gt c gt d gt e gt f Values a Combinator to transform a function of arity 5 into a corresponding set function that uses a given strategy to compute its values set6 a gt b gt c gt d gt e gt f gt g gt a gt b gt c gt d e f Values g Combinator to transform a function of arity 6 into a corresponding set function set6With SearchTree a gt ValueSequence a gt b Y lt c gt d gt e gt gt 8g gt a gt b gt c gt d gt e gt gt 8g gt Values a Combinator to transform a function of arity 6 into a corresponding set function that uses a given strategy to compute its values set7 la lt b gt c gt d gt e gt f gt g8g gt h gt a gt b gt c gt d gt e gt f gt g8 Values h Combinator to transform a function of arity 7 into a corresponding set function set7With SearchTree a gt ValueSequence a gt b lt c gt d gt e gt gt g8g gt h gt a gt b gt c gt d gt e gt f gt g gt h gt Values a Combinator to transform a fu
45. deterministic value is only computed when the user requests it Thus one has also the possibility to terminate the enumeration of all values after having seen some values first Turn on off the first only mode In the first only mode only the first value of the main expression is printed instead of all values optimize Turn on off the optimization of the target program bindings Turn on off the binding mode If the binding mode is on default then the bindings of the free variables of the initial expression are printed together with the result of the expression time Turn on off the time mode If the time mode is on the cpu time and the elapsed time of the computation is always printed together with the result of an evaluation trace Turn on off the trace mode If the trace mode is on it is possible to trace the sources of failing computations profile only available when configured during installation see Section 1 1 Turn on off the profile mode If the profile mode is on expressions as well as programs are compiled with GHC s profiling capabilities enabled For expressions evaluation will automatically generate a file Main prof containing the profiling information of the evaluation For compiled programs the profiling has to be manually activated using runtime options when executed 13 kics2 set profile load MyProgram curry
46. get type declarations from program progFuncs Prog gt FuncDecl get functions from program progOps Prog OpDec1 get infix operators from program updProg String gt String String gt String gt TypeDecl gt TypeDecl FuncDec1 FuncDecl gt OpDec1 OpDec11 gt Prog gt Prog update program updProgName String gt String gt Prog Prog update name of program updProgImports String Stringl gt Prog Prog update imports of program updProgTypes TypeDec1 gt TypeDec11 gt Prog Prog update type declarations of program updProgFuncs FuncDec1 FuncDec1 gt Prog gt Prog update functions of program updProgOps OpDec1 gt OpDec1 gt Prog gt Prog update infix operators of program allVarsInProg Prog gt Int 230 get all program variables also from patterns updProgExps Expr gt Expr Prog gt Prog lift transformation on expressions to program rnmAllVarsInProg Int gt Int gt Prog gt Prog rename programs variables updQNamesInProg String String gt String String Prog Prog update all qualified names in program rnmProg String Prog Prog rename program update name of and all qualified names in program trType String String gt Visibility Int gt ConsDecl gt a gt String String Visibility I
47. gt AFuncDecl al gt OpDec1 OpDec1 1 AProg a AProg a update program updProgName String gt String gt AProg a gt AProg a update name of program updProgImports String gt Stringl gt AProg a AProg a update imports of program updProgTypes TypeDecl TypeDec11 gt AProg a gt AProg a update type declarations of program updProgFuncs AFuncDecl1 a gt AFuncDecl al gt AProg a AProg a update functions of program updProgOps OpDec1 gt OpDecl AProg a gt AProg a update infix operators of program allVarsInProg AProg a gt Int 259 get all program variables also from patterns updProgExps AExpr a AExpr a AProg a gt AProg a lift transformation on expressions to program rnmAllVarsInProg Int gt Int gt AProg a gt AProg a rename programs variables updQNamesInProg String String String String AProg a gt AProg a update all qualified names in program rnmProg String AProg a AProg a rename program update name of and all qualified names in program trType String String gt Visibility Int gt ConsDec1 gt a gt String String Visibility Int gt TypeExpr a TypeDecl gt a transform type declaration typeName TypeDecl gt String String get name of type declaration typeVisibility TypeDecl Visibility get visibility of type
48. gt 10 Adds a style value in a region of a TextEdit widget The region is specified a start and end position similarly to getCursorPosition Different styles can be combined e g to get bold blue text on a red background If Bold Italic and Underline are combined currently all but one of these are ignored This is an experimental function and might be changed in the future removeRegionStyle WidgetRef Int Int gt Int Int gt Style GuiPort gt 10 O Removes a style value in a region of a TextEdit widget The region is specified a start and end position similarly to getCursorPosition This is an experimental function and might be changed in the future getCursorPosition WidgetRef GuiPort gt 10 Int Int Get the position line column of the insertion cursor in a TextEdit widget Lines are numbered from 1 and columns are numbered from 0 seeText WidgetRef gt Int Int GuiPort gt 10 Adjust the view of a TextEdit widget so that the specified line column character is visible Lines are numbered from 1 and columns are numbered from 0 focusInput WidgetRef gt GuiPort 10 Sets the input focus of this GUI to the widget referred by the first argument This is useful for automatically selecting input entries in an application addCanvas WidgetRef gt CanvasItem gt GuiPort gt 10 Adds a list of canvas items to a canvas referred by the first argumen
49. gt Array c combine two arbitrary arrays combineSimilar a gt a gt a Array a gt Array a gt Array a the combination of two arrays with identical default function and a combinator which is neutral in the default can be implemented much more efficient A 3 2 Library Dequeue An implementation of double ended queues supporting access at both ends in constant amortized time Exported types data Queue The datatype of a queue Exported constructors 142 Exported functions empty Queue a The empty queue cons a gt Queue a gt Queue a Inserts an element at the front of the queue snoc a gt Queue a Queue a Inserts an element at the end of the queue isEmpty Queue a gt Bool Is the queue empty deqLength Queue a Int Returns the number of elements in the queue deqHead Queue a gt a The first element of the queue deqTail Queue a Queue a Removes an element at the front of the queue deqLast Queue a gt a The last element of the queue deqInit Queue a Queue a Removes an element at the end of the queue deqReverse Queue a gt Queue a Reverses a double ended queue rotate Queue a gt Queue a Moves the first element to the end of the queue matchHead Queue a Maybe a Queue a Matches the front of a queue matchHead q is equivalent to if isEmpty q then Nothing else Just deqHead q deqTail q but more efficient matchLast Queue a Mayb
50. last 102 LayoutChoice 219 lbrace 116 lbracket 116 ldeclsOfRule 215 LEdge 147 lefts 61 legChar 157 leqCharIgnoreCase 157 leqLexGerman 157 leqList 157 leqString 157 leqStringIgnoreCase 157 let 17 letBinds 238 263 letBody 238 263 line 108 linebreak 108 linesep 107 list 114 list2ac 218 list2CategorizedHtml 163 ListBoxScroll 85 listenOn 105 133 listenOnFresh 133 290 listPattern 218 listSpaced 114 listToDefaultArray 142 listToDeg 143 listToErrorArray 142 listToFM 144 listToMaybe 104 listType 216 litem 171 Literal 228 literal 237 262 LNode 147 local installation 6 log 69 logBase 69 logfile 60 lookup 154 lookupAFCSubst 267 lookupFileInPath 63 lookupFlatCurryFileInLoadPath 229 lookupFM 146 lookupModuleSourceInLoadPath 59 lookupRBT 158 lookupSubst 161 lookupWithDefaultFM 146 lparen 115 LPath 148 lpre 151 lpre 152 lsuc 150 lsuc 152 magenta 119 MailOption 178 main 53 mainWUI 188 196 makeRelative 67 makeValid 67 mapAccumES 62 mapAccumL 103 mapAccumR 103 mapChildFamilies 159 mapChildFamiliesI0 160 mapChildren 159 mapChildrenI0 160 mapES 62 mapFamily 159 mapFamilyl0 160 mapFM 145 mapMaybe 104 mapMMaybe 104 mapT 98 mapT_ 98 mapValues 132 markdown 28 MarkdownDoc 179 MarkdownElem 179 markdownEscapeChars 181 markdownText2CompleteHTML 181 markdownText2CompleteLaTeX 181 markdownText2HTML 1
51. takeExtension String gt String 64 replaceExtension String String String lt gt String gt String gt String dropExtension String gt String addExtension String String gt String hasExtension String gt Bool splitExtensions String gt String String dropExtensions String gt String takeExtensions String String splitDrive String gt String String joinDrive String String gt String takeDrive String String dropDrive String String hasDrive String Bool isDrive String Bool 65 splitFileName String gt String String replaceFileName String String String dropFileName String String takeFileName String String takeBaseName String String replaceBaseName String String String hasTrailingPathSeparator String Bool addTrailingPathSeparator String String dropTrailingPathSeparator String String takeDirectory String String replaceDirectory String String String combine String String String lt gt String gt String gt String splitPath String String 66 splitDirectories String gt String joinPath String String equalFilePath String String Bool makeRelative String String String normalise String String isValid String Bool
52. 246 readFlatCurryIntWithImportsInPath 246 readFlatCurryWithImports 246 readFlatCurryWithImportsInPath 246 readFlatCurryWithParseOptions 228 readFM 147 readGlobal 73 readHex 124 125 readHtmlFile 178 readInt 124 readI0Ref 92 readNat 124 readOct 125 readPropertyFile 124 readQTerm 126 readQTermFile 126 readQTermListFile 126 readScan 271 readsQTerm 126 readsTerm 126 readsUnqualifiedTerm 125 readTerm 126 readUnqualifiedTerm 126 readUnsafeXmlFile 198 readUntypedCurry 212 294 readUntypedCurryWithParseOptions 212 readXmlFile 198 recip 69 Reconfigureltem 77 red 119 RedBlackTree 154 redirect 168 registerCgiServer 177 registerPort 53 removeDirectory 56 removeEscapes 180 removeFile 56 removeRegionStyle 84 renameDirectory 56 renameFile 56 Rendering 182 189 renderList 188 196 renderTaggedTuple 188 196 renderTuple 188 196 rep 201 replace 102 replaceBaseName 66 replaceChildren 159 replaceChildrenI0 160 replaceDirectory 66 replaceExtension 65 replaceFileName 66 repseqi 202 repseq2 203 repseq3 203 repSeq4 204 repSeq5 204 repseq6 205 RequiredSpec 249 requires 249 resetbutton 172 resultType 214 234 259 returnES 62 returnT 97 rights 61 rnmAllVars 240 265 rnmAllVarsInFunc 236 261 rnmAl1lVarsInProg 231 256 rnmAllVarsInRule 237 262 rnmAllVarsInTypeExpr 234 259 rnmProg 231 256 rotate 143 round 69 row 82 rparen 115
53. Exported constructors e Clash Term a gt Term a gt UnificationError a Clash ti t2 Two term constructors with different names are supposed to be equal e OccurCheck Int gt Term a gt UnificationError a OccurCheck v t A term is supposed to be equal to a term in which it occurs as a subterm Exported functions unify Term a Term a Either UnificationError a FM Int Term a Unifies the given equations A 4 Libraries for Web Applications A 4 1 Library CategorizedHtmlList This library provides functions to categorize a list of entities into a HTML page with an index access e g A Z to these entities 162 Exported functions list2CategorizedHtml a HtmlExp gt b String gt a gt b Bool gt HtmlExp General categorization of a list of entries The item will occur in every category for which the boolean function categoryFun yields True categorizeByItemKey String HtmlExp HtmlExpl Categorize a list of entries with respect to the inial keys The categories are named as all initial characters of the keys of the items stringList2ItemList String String HtmlExp Convert a string list into an key item list The strings are used as keys and for the simple text layout A 4 2 Library HTML Library for HTML and CGI programming This paper contains a description of the basic ideas behind this library The installation o
54. GUI that should react on inputs provided by other processes e g via sockets setConfig WidgetRef gt ConfItem gt GuiPort gt I0 Changes the current configuration of a widget deprecated operation only included for backward compatibility Warning does not work for Command options exitGUI GuiPort gt I0 An event handler for terminating the GUI getValue WidgetRef GuiPort 10 String Gets the String value of a variable in a GUI setValue WidgetRef String gt GuiPort 10 Sets the String value of a variable in a GUI updateValue String String WidgetRef GuiPort gt 10 83 Updates the String value of a variable w r t to an update function appendValue WidgetRef gt String GuiPort gt I0 Appends a String value to the contents of a TextEdit widget and adjust the view to the end of the TextEdit widget appendStyledValue WidgetRef gt String Style gt GuiPort gt I0 Appends a String value with style tags to the contents of a TextEdit widget and adjust the view to the end of the TextEdit widget Different styles can be combined e g to get bold blue text on a red background If Bold Italic and Underline are combined currently all but one of these are ignored This is an experimental function and might be changed in the future addRegionStyle WidgetRef gt Int Int gt Int Int Style gt GuiPort
55. I0 An action that updates the contents of an XML file by some transformation on the XML document A 4 11 Library XmlConv Provides type based combinators to construct XML converters Arbitrary XML data can be rep resented as algebraic datatypes and vice versa See here for a description of this library Exported types type XmlReads a String String XmlExp a String String Xml1Exp Type of functions that consume some XML data to compute a result type XmlShows a a gt String String XmlExp gt String String Xm1Exp Type of functions that extend XML data corresponding to a given value type XElemConv a XmlConv Repeatable Elem a Type of converters for XML elements type XAttrConv a XmlConv NotRepeatable NoElem a Type of converters for attributes type XPrimConv a XmlConv NotRepeatable NoElem a Type of converters for primitive values type XOptConv a XmlConv NotRepeatable NoElem a Type of converters for optional values type XRepConv a XmlConv NotRepeatable NoElem a Type of converters for repetitions Shttp www ps informatik uni kiel de sebf projects xmlconv 199 Exported functions xmlReads XmlConv abc gt String String XmlExp gt c String String XmlExp Takes an XML converter and returns a function that consumes XML data and returns the remaining data along with the result xmlShows XmlConv a b c gt c gt String String XmlExp
56. LNodes and LEdges buildGr a Int Int b a Int Graph b a Build a Graph from a list of Contexts mkUGraph Int gt Int Int gt Graph O O Build a quasi unlabeled Graph from the list of Nodes and Edges insNode Int a Graph a b Graph a b Insert a LNode into the Graph insEdge Int Int a Graph b a gt Graph b a Insert a LEdge into the Graph delNode Int Graph a b Graph a b Remove a Node from the Graph delEdge Int Int Graph a b Graph a b Remove an Edge from the Graph insNodes Int a Graph a b gt Graph a b 149 Insert multiple LNodes into the Graph insEdges Int Int a Graph b a gt Graph b a Insert multiple LEdges into the Graph delNodes Int Graph a b gt Graph a b Remove multiple Nodes from the Graph delEdges Int Int gt Graph a b Graph a b Remove multiple Edges from the Graph isEmpty Graph a b Bool test if the given Graph is empty match Int gt Graph a b gt Maybe b Int Int a b Int Graph a b match is the complement side of amp decomposing a Graph into the MContext found for the given node and the remaining Graph noNodes Graph a b gt Int The number of Nodes in a Graph nodeRange Graph a b gt Int Int The minimum and maximum Node in a Graph context Graph a b gt Int gt b Int Int a b Int Find the context for the given Node In contrast to match
57. Literal Pattern Pattern update literal of pattern patExpr Pattern Expr build expression from pattern A 5 9 Library FlatCurry Pretty This library provides pretty printers for FlatCurry modules and all substructures e g expressions 241 Exported types data Options Options for pretty printing Exported constructors e Options Int QualMode String Options data QualMode Qualification mode determines whether identifiers are printed qualified or unqualified While QualNone and QualImports aim at readability there may be ambiguities due to shadowing On the contrary QualImports and QualA11 produce correct output at the cost of readability Exported constructors e QualNone QualMode QualNone no qualification only unqualified names e QualImportsButPrelude QualMode QualImportsButPrelude qualify all imports except those from the module Prelude e QualImports QualMode QualImports qualify all imports including Prelude e QualAll QualMode Qua1A11 qualify all names Exported functions indentWidth Options Int qualMode Options gt QualMode currentModule Options String 242 defaultOptions Options Default Options for pretty printing ppProg Options Prog Doc pretty print a FlatCurry module ppHeader Options String TypeDec1 FuncDecl Doc pretty print the module header ppExports Opt
58. Many options necessary to compile Curry programs are already set you can see them by setting the verbosity level to 2 or greater One has to be careful when providing additional options For instance in a global installation of KiCS2 see Section 1 1 libraries are pre compiled so that inconsistencies might occur if compilation options might be changed It is safe to pass specific GHC linking options For instance to enforce the static linking of libraries in order to generate an executable see command save that can be executed in another environment one could set the options set ghc static optl static optl pthread Other options are useful for experimental purposes but those should be used only in local installations see Section 1 1 to avoid inconsistent target codes for different libraries For instance setting the option set ghc DDISABLE_CS has the effect that the constraint store used to enable an efficient access to complex bindings is disabled Similarly 14 set ghc DSTRICT_VAL_BIND has the effect that expressions in a unification constraint are always fully evaluated instead of the evaluation to a head normal form only before unifying both sides Since these options influence the compilation of the run time system one should also enforce the e recompilation of Haskell programs by the GHC option fforce recomp e g one should set set ghc DDISABLE_CS fforce recomp rts opts
59. PAKCS as back end by other functional logic programming systems Exported functions flatCurry2XmlFile Prog gt String gt I0 Transforms a FlatCurry program term into a corresponding XML file flatCurry2Xml Prog XmlExp Transforms a FlatCurry program term into a corresponding XML expression xmlFile2FlatCurry String gt 10 Prog Reads an XML file with a FlatCurry program and returns the FlatCurry program xml2FlatCurry XmlExp Prog Transforms an XML term into a FlatCurry program A 5 13 Library FlatCurry FlexRigid This library provides a function to compute the rigid flex status of a FlatCurry expression right hand side of a function definition 247 Exported types data FlexRigidResult Datatype for representing a flex rigid status of an expression Exported constructors e UnknownFR FlexRigidResult e ConflictFR FlexRigidResult e KnownFlex FlexRigidResult e KnownRigid FlexRigidResult Exported functions getFlexRigid Expr gt FlexRigidResult Computes the rigid flex status of a FlatCurry expression This function checks all cases in this expression If the expression has rigid as well as flex cases which cannot be the case for source level programs but might occur after some program transformations the result ConflictFR is returned A 5 14 Library FlatCurry Compact This module contains functions to reduce the size of FlatCurry programs by combining the main module and
60. Spicey 43 split 101 splitBaseName 63 splitDirectories 67 splitDirectoryBaseName 63 splitDrive 65 splitExtension 64 splitExtensions 65 splitFileName 66 splitFM 145 splitModuleFileName 58 splitModuleIdentifiers 58 splitOn 101 splitPath 63 66 splitSearchPath 64 splitSet 52 sqrt 69 squote 116 squotes 114 standardForm 168 standardPage 169 star 107 stderr 88 stdin 88 stdout 88 Strategy 127 138 string 115 200 string2ac 218 string2urlencoded 175 stringList2ItemList 163 stringPattern 218 stringType 216 stripCurrySuffix 58 stripSuffix 63 strong 170 Style 80 style 172 styleSheet 172 submitForm 177 subset 52 297 Subst 161 subst 268 substBranch 268 substExpr 268 substFunc 268 substPattern 268 substRule 268 substSnd 268 suc 150 suc 151 suffixSeparatorChar 63 sum 102 supply 12 system 135 table 171 TableRBT 158 tableRBT2list 158 tabulator stops 7 tag0f 198 tails 102 takeBaseName 66 takeDirectory 66 takeDrive 65 takeExtension 64 takeExtensions 65 takeFileName 66 tan 70 tanh 70 tConsArgs 233 258 tConsName 233 258 teletype 171 Term 161 TermEq 160 TermEqs 160 terminal 106 TError 96 TErrorKind 96 testing programs 33 testScan 271 text 107 textarea 173 TextEditScroll 85 textfield 172 textOf 198 textOfXm1 198 textstyle 172 tilde 117 time 13 toCalendarTime 136 toClockTime 136 toDayString 13
61. String String gt String String Expr Expr update all qualified names in expression trBranch Pattern Expr gt a gt BranchExpr gt a transform branch expression branchPattern BranchExpr Pattern get pattern from branch expression branchExpr BranchExpr Expr get expression from branch expression updBranch Pattern gt Pattern Expr Expr BranchExpr BranchExpr update branch expression updBranchPattern Pattern Pattern BranchExpr gt BranchExpr update pattern of branch expression 240 updBranchExpr Expr gt Expr BranchExpr BranchExpr update expression of branch expression trPattern String String gt Int gt a gt Literal gt a gt Pattern gt a transform pattern patCons Pattern String String get name from constructor pattern patArgs Pattern gt Int get arguments from constructor pattern patLiteral Pattern gt Literal get literal from literal pattern isConsPattern Pattern Bool is pattern a constructor pattern updPattern String String String String L Int gt Int gt Literal gt Literal gt Pattern Pattern update pattern updPatCons String String String String gt Pattern gt Pattern update constructors name of pattern updPatArgs Int Int gt Pattern gt Pattern update arguments of constructor pattern updPatLiteral Literal
62. Usually the message stream comes from an external port Thus this operation im plements a committed choice over receiving input from an IO handle or an external port Note that the implementation of this operation works only with Sicstus Prolog 3 8 5 or higher due to a bug in previous versions of Sicstus Prolog hWaitForInputsOrMsg Handle gt a I0 Either Int a Waits until input is available on some of the given handles or a message in the message stream Usually the message stream comes from an external port Thus this operation implements a committed choice over receiving input from IO handles or an external port Note that the implementation of this operation works only with Sicstus Prolog 3 8 5 or higher due to a bug in previous versions of Sicstus Prolog 89 hReady Handle gt IO Bool Checks whether an input is available on a given handle hGetChar Handle IO Char Reads a character from an input handle and returns it Throws an error if the end of file has been reached hGetLine Handle gt 10 String Reads a line from an input handle and returns it Throws an error if the end of file has been reached while reading the first character If the end of file is reached later in the line it ist treated as a line terminator and the partial line is returned hGetContents Handle IO String Reads the complete contents from an input handle and closes the input handle before returning the
63. WUI is shown after the radio button WUI wEither WuiSpec a WuiSpec b WuiSpec Either a b 187 WUI for union types Here we provide only the implementation for Either types since other types with more alternatives can be easily reduced to this case wTree WuiSpec a gt WuiSpec WTree a WUI for tree types The rendering specifies the rendering of inner nodes Leaves are shown with their default rendering renderTuple HtmlExp gt HtmlExp Standard rendering of tuples as a table with a single row Thus the elements are horizontally aligned renderTaggedTuple String gt HtmlExp gt HtmlExp Standard rendering of tuples with a tag for each element Thus each is preceded by a tag that is set in bold and all elements are vertically aligned renderList HtmlExp gt HtmlExp Standard rendering of lists as a table with a row for each item Thus the elements are vertically aligned mainWUI WuiSpec a gt a a gt IO HtmlForm gt 10 HtmlForm Generates an HTML form from a WUI data specification an initial value and an update form wui2html WuiSpec a a gt a IO HtmlForm HtmlExp WuiHandler Generates HTML editors and a handler from a WUI data specification an initial value and an update form wuilnForm WuiSpec a gt a a IO HtmlForm HtmlExp WuiHandler gt 10 HtmlForm 10 HtmlForm Puts a WUI into a HTML form contai
64. a document before pretty printing it fillBreak Int Doc Doc The document fillBreak i d first renders document d It than appends spaces until the width is equal to i If the width of d is already larger than i the nesting level is increased by i and a line is appended When we redefine ptype in the previous example to use fillBreak we get a useful variation of the previous output ptype name tp fillBreak 6 text name lt gt text lt gt text tp The output will now be let empty Doc nest Int gt Doc gt Doc linebreak Doc Note that fillBreak is not guaranteed to be linear time bounded since it has to com pute the width of a document before pretty printing it bold Doc Doc The document bold d displays document d with bold text faint Doc Doc The document faint d displays document d with faint text blinkSlow Doc Doc The document blinkSlow d displays document d with slowly blinking text rarely supported blinkRapid Doc Doc The document blinkRapid d displays document d with rapidly blinking text rarely supported italic Doc gt Doc 118 The document italic d displays document d with italicized text rarely supported underline Doc gt Doc The document underline d displays document d with underlined text crossout Doc Doc The document crossout d displays document d with crossed out text inverse Doc gt Doc The d
65. a free variable the constructors Neg and Pos denote negative and positive numbers without 0 while the constructors O and I denote a 0 and 1 bit where the least significant bit comes first That is Pos I 0 _x4 1 0 _x4 2x 0 _x4 1 4x_x4 1 which meets the output above 3 2 Recursive Variable Bindings Local variable declarations introduced by let or where can be mutually recursive in KiCS2 For instance the declaration 17 onesb let ones 1 ones in take 5 ones introduces the local variable ones which is bound to a cyclic structure representing an infinite list of 1 s Similarly the definition onetwo n take n one2 where 1 twol twol 2 one2 one2 introduces a local variables one2 that represents an infinite list of alternating 1 s and 2 s so that the expression onetwo 6 evaluates to 1 2 1 2 1 2 3 3 Functional Patterns Functional patterns 1 are a useful extension to code operations in a more readable way Fur thermore defining operations with functional patterns avoids problems caused by strict equality and leads to programs that are potentially more efficient Consider the definition of an operation to compute the last element of a list xs based on the prelude operation for list concatenation last xs _ y xs y where y free uu Since the equality constrain evaluates both sides to a constructor term all elements of the list x
66. all imports into a single program that contains only the functions directly or indirectly called from a set of main functions Exported types data Option Options to guide the compactification process Exported constructors e Verbose Option Verbose for more output e Main String gt Option Main optimize for one main unqualified function supplied here e Exports Option Exports 248 data optimize w r t the exported functions of the module only InitFuncs String String gt Option InitFuncs optimize w r t given list of initially required functions Required RequiredSpec Option Required list of functions that are implicitly required and thus should not be deleted if the corresponding module is imported Import String gt Option Import module that should always be imported useful in combination with option InitFuncs RequiredSpec Data type to specify requirements of functions Exported constructors Exported functions requires String String gt String String RequiredSpec fun requires reqfun specifies that the use of the function fun implies the application of function regfun alwaysRequired String String RequiredSpec alwaysRequired fun specifies that the function fun should be always present if the corresponding module is loaded defaultRequired RequiredSpec Functions that are im
67. as hello world hang Int Doc Doc 108 The combinator hang implements hanging indentation The document hang i d renders document d with a nesting level set to the current column plus i The following example uses hanging indentation for some text test hang 4 f111Sep map text words the hang combinator indents these words Which lays out on a page with a width of 20 characters as the hang combinator indents these words The hang combinator is implemented as hang ix align nest i x align Doc Doc The document align d renders document d with the nesting level set to the current column It is used for example to implement hang As an example we will put a document right above another one regardless of the current nesting level x y align x y test text hi lt gt text nice text world which will be layed out as hi nice world indent Int Doc Doc The document indent i d indents document d with i spaces test indent 4 fillSep map text words the indent combinator indents these words Which lays out with a page width of 20 as 109 the indent combinator indents these words combine Doc Doc gt Doc gt Doc The document combine c d1 d2 combines document di and d2 with document c in between using lt gt with identity empty Thus the following equations hold combine c dl empty d1 combine c
68. before a definition of a datatype or top level function are kept together 2 The documentation comments for the complete module occur before the first module or import line in the module The comments can also contain several special tags These tags must be the first thing on its line in the documentation comment and continues until the next tag is encountered or until the end of the comment The following tags are recognized Cauthor comment Specifies the author of a module only reasonable in module comments version comment Specifies the version of a module only reasonable in module comments cons id comment A comment for the constructor id of a datatype only reasonable in datatype comments Cparam id comment A comment for function parameter id only reasonable in function comments Due to pattern matching this need not be the name of a parameter given in the declaration of the function but all parameters for this functions must be commented in left to right order if they are commented at all return comment A comment for the return value of a function only reasonable in function comments The comment of a documented entity can be any string in Markdown s syntax the currently sup ported set of elements is described in detail in the appendix For instance it can contain Markdown annotations for emphasizing elements e g _verb_ strong elements e g important code elements e g 3 4 code
69. contains the necessary definitions for writing tests In particular it exports an abstract polymorphic type Assertion a together with the following operations assertTrue String Bool gt Assertion assertEqual String gt a gt a Assertion a assertValues String gt a la Assertion a assertSolutions String a Bool a Assertion a assertl0 String gt IO a gt a Assertion a assertEquall0 String gt IO a gt IO a Assertion a The expression assertTrue s b is an assertion named s that the expression b has the value True Similarly the expression assertEqual s e ez asserts that the expressions e and ez must be equal i e e1 e2 must hold the expression assertValues s e vs asserts that vs is the multiset of all values of e and the expression assertSolutions s c us asserts that the constraint abstraction c has the multiset of solutions vs Furthermore the expression assertI0 s a v asserts that the I O action a yields the value v whenever it is executed and the expression assertEqualI0 s aj az asserts that the I O actions a and az yield equal values The name s provided as a first argument in each assertion is used in the protocol produced by the test tool One can define a test program by importing the module to be tested together with the module Assertion and defining top level functions of type Assertion in this module which mus
70. empty d2 d2 combine c dl d2 dl lt gt c lt gt d2 if neither di nor d2 are empty lt gt Doc Doc gt Doc The document x lt gt y concatenates document x and document y It is an associative operation having empty as a left and right unit lt gt Doc Doc gt Doc The document x lt gt y concatenates document x and y with a space in between with identity empty Doc gt Doc gt Doc The document x y concatenates document x and y with a line in between with identity empty lt gt Doc Doc gt Doc The document x lt gt y concatenates document x and y with a blank line in between with identity empty lt gt Doc Doc gt Doc The document x lt gt y concatenates document x and y with a softline in between with identity empty This effectively puts x and y either next to each other with a space in between or underneath each other lt gt Doc gt Doc Doc The document x lt gt y concatenates document x and y with a linebreak in be tween with identity empty lt gt Doc gt Doc gt Doc The document x lt gt y concatenates document x and y with a softbreak in be tween with identity empty This effectively puts x and y either right next to each other or underneath each other 110 lt gt Doc gt Doc gt Doc The document x lt gt y concatenates document x and y with a hardline in be
71. for a given cgi environment returned as Just v If the value is not legal Nothing is returned The second component of the result contains an HTML edit expression together with a WUI state to edit the value again Exported constructors data WTree A simple tree structure to demonstrate the construction of WUls for tree types Exported constructors e WLeaf a WTree a e WNode WTree a WTree a Exported functions wuiHandler2button String WuiHandler HtmlExp Transform a WUI handler into a submit button with a given label string withRendering WuiSpec a gt HtmlExp HtmlExp gt WuiSpec a Puts a new rendering function into a WUI specification withError WuiSpec a String WuiSpec a Puts a new error message into a WUI specification withCondition WuiSpec a gt a Bool WuiSpec a 189 Puts a new condition into a WUI specification withConditionJS WuiSpec a gt a Bool gt WuiSpec a Puts a new JavaScript implementation of the condition into a WUI specification withConditionJSName WuiSpec a gt a gt Bool String gt WuiSpec a Puts a new JavaScript implementation of the condition into a WUI specification transformWSpec a gt b b gt a gt WuiSpec a gt WuiSpec b Transforms a WUI specification from one type to another adaptWSpec a gt b WuiSpec a gt WuiSpec b Adapt a WUI specification to a new type For this
72. function updFuncRule ARule a gt ARule a gt AFuncDecl a gt AFuncDecl a update rule of function isExternal AFuncDecl a gt Bool is function externally defined 260 allVarsInFunc AFuncDecl a gt Int get variable names in a function declaration funcArgs AFuncDecl a gt Int a get arguments of function if not externally defined funcBody AFuncDecl a gt AExpr a get body of function if not externally defined funcRHS AFuncDecl a gt AExpr a rnmAllVarsInFunc Int gt Int gt AFuncDecl a AFuncDecl a rename all variables in function updQNamesInFunc String String gt String String AFuncDecl a gt AFuncDecl a update all qualified names in function updFuncArgs Int a Int a AFuncDecl a AFuncDecl a update arguments of function if not externally defined updFuncBody AExpr a gt AExpr a gt AFuncDecl a AFuncDecl a update body of function if not externally defined trRule a gt Int a gt AExpr a gt b gt a gt String gt b gt ARule a gt b transform rule ruleArgs ARule a gt Int a get rules arguments if it s not external ruleBody ARule a AExpr a get rules body if it s not external ruleExtDecl ARule a gt String get rules external declaration isRuleExternal ARule a gt Bool is rule external updRule a a gt Int a J gt Int a AExpr a gt AExpr a gt
73. gt Int gt Expr gt Expr gt String String Rule gt Rule update rule updRuleArgs Int gt Int Rule Rule 236 update rules arguments updRuleBody Expr gt Expr gt Rule gt Rule update rules body updRuleExtDecl String String Rule gt Rule update rules external declaration allVarsInRule Rule gt Int get variable names in a functions rule rnmAllVarsInRule Int gt Int gt Rule gt Rule rename all variables in rule updQNamesInRule String String gt String String Rule gt Rule update all qualified names in rule trCombType a gt Int gt a gt a gt Int gt a gt CombType gt a transform combination type isCombTypeFuncCall CombType Bool is type of combination FuncCall isCombTypeFuncPartCall CombType Bool is type of combination FuncPartCall isCombTypeConsCall CombType Bool is type of combination ConsCall isCombTypeConsPartCall CombType Bool is type of combination ConsPartCall missingArgs CombType Int varNr Expr Int get internal number of variable literal Expr Literal get literal if expression is literal expression combType Expr CombType 237 get combination type of a combined expression combName Expr gt String String get name of a combined expression combArgs Expr Expr get arguments of a combined expression missingCombArgs Expr
74. gt WuiSpec a WuiSpec b WuiSpec c WUI combinator for constructors of arity 2 The first argument is the binary con structor The second and third arguments are the WUI specifications for the argument types wTriple WuiSpec a WuiSpec b gt WuiSpec c gt WuiSpec a b c 184 WUI combinator for triples wCons3 a gt b c gt d WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d WUI combinator for constructors of arity 3 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types w4Tuple WuiSpec a WuiSpec b WuiSpec c gt WuiSpec d WuiSpec a b c d WUI combinator for tuples of arity 4 wCons4 a gt b gt c d e gt WuiSpec a gt WuiSpec b gt WuiSpec c gt WuiSpec d gt WuiSpec e WUI combinator for constructors of arity 4 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types woTuple WuiSpec a WuiSpec b WuiSpec c WuiSpec d WuiSpec e gt WuiSpec a b c d e WUI combinator for tuples of arity 5 wConsb a gt b c d gt e gt f gt WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e WuiSpec f WUI combinator for constructors of arity 5 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument typ
75. h b gt XmlConv i j c gt XmlConv NotRepeatable NoElem d Creates an XML converter representing a sequence of arbitrary XML data The se quence must not be used in repetitions and does not represent an XML element repSeq3 a gt b c d gt XmlConv Repeatable e a XmlConv Repeatable f b XmlConv Repeatable g c XmlConv NotRepeatable NoElem d Creates an XML converter that represents a repetition of a sequence of repeatable XML data The repetition may be used in other repetitions and does not represent an XML element This combinator is provided because converters for repeatable sequences cannot be constructed by the seq combinators eSeq3 String gt a gt b gt c gt d gt XmlConv e f a gt XmlConv g h b gt XmlConv i j c gt XmlConv Repeatable Elem d 203 Creates an XML converter for compound values represented as an XML element with children that correspond to the values components The element can be used in repe titions eRepSeq3 String gt a gt b gt c gt d XmlConv Repeatable e a gt XmlConv Repeatable f b XmlConv Repeatable g c XmlConv Repeatable Elem d Creates an XML converter for repetitions of sequences represented as an XML element that can be used in repetitions sega la gt b gt c gt d gt e gt XmlConv f g a gt XmlConv h ib gt XmlConv jk c gt XmlConv 1 m d gt XmlConv NotRepeatable NoElem e Creates an XML converter rep
76. header for this form formBodyAttr String String FormParam Optional attribute for the body element of the HTML form More than one occurrence is allowed i e all such attributes are collected form String HtmlExp gt HtmlForm A basic HTML form for active web pages with the default encoding and a default background 167 standardForm String gt HtmlExp gt HtmlForm A standard HTML form for active web pages where the title is included in the body as the first header cookieForm String gt String String HtmlExp gt HtmlForm An HTML form with simple cookies The cookies are sent to the client s browser together with this form addCookies String String HtmlForm HtmlForm Add simple cookie to HTML form The cookies are sent to the client s browser together with this form answerText String HtmlForm A textual result instead of an HTML form as a result for active web pages answerEncText String String HtmlForm A textual result instead of an HTML form as a result for active web pages where the encoding is given as the first parameter addFormParam HtmlForm FormParam HtmlForm Adds a parameter to an HTML form redirect Int String HtmlForm HtmlForm Adds redirection to given HTML form expires Int HtmlForm HtmlForm Adds expire time to given HTML form addSound String Bool HtmlForm HtmlForm
77. initiated by the user cannot lead to an inconsistent state of the database The idea of this tool which is part of the distribution of KiCS2 is described in detail in 18 Thus we describe only the basic steps to use this tool in order to generate a web application First one has to create a textual description of the entity relationship model as a Curry term of type ERD w r t the type definitions given in module kics2home currytoo1s erd2curry ERD curry and store it in some file e g mymodel erdterm The directory kics2home currytools spicey contains two examples for such ERD term files Blog erdterm This is a simple ER model for a blog with entries comments and tags as presented in the paper 18 Uni erdterm This is an ER model for university lectures as presented in the paper 8 Then change to the directory in which you want to create the project sources Execute the command spiceup mymodel erdterm with the path to the ERD term file as a parameter spiceup is a program stored in kics2home bin where kics2home is the installation directory of KiCS2 see Section 1 2 You can also provide a path name i e the name of a directory where the database files should be stored e g spiceup dbpath DBDIR mymodel erdterm If the parameter dbpath DBDIR is not provided then DBDIR is set to the current directory Since this specification will be used in the generated web programs a relative datab
78. it is used by KiCS2 if called on a terminal If it should not be used e g because it is executed in an editor with readline functionality one can call KiCS2 with the parameter noreadline which must occur as the first parameter 2 7 Customization In order to customize the behavior of KiCS2 to your own preferences there is a configuration file which is read by KiCS2 when it is invoked When you start KiCS2 for the first time a standard e version of this configuration file is copied with the name kics2rc into your home directory The file contains definitions of various settings e g about showing warnings using Curry extensions programs etc After you have started KiCS2 for the first time look into this file and adapt it to your own preferences 2 8 Emacs Interface Emacs is a powerful programmable editor suitable for program development It is freely available for many platforms see http www emacs org The distribution of KiCS2 contains also a special Curry mode that supports the development of Curry programs in the Emacs environment This mode includes support for syntax highlighting finding declarations in the current buffer and loading Curry programs into KiCS2 in an Emacs shell The Curry mode has been adapted from a similar mode for Haskell programs Its installation is described in the file README in directory kics2home tools emacs which also contains the sources of the Curry mode and a short des
79. latex document e g ngerman showLatexDocs HtmlExp gt String Transforms a list of HTML expressions into a string representation of a complete LaTeX document where each list entry appears on a separate page showLatexDocsWithPackages HtmlExp String gt String Transforms a list of HTML expressions into a string representation of a complete LaTeX document where each list entry appears on a separate page The variable packages holds the packages to add to the latex document e g ngerman germanLatexDoc HtmlExp gt String show german latex document intForm IO HtmlForm gt 10 Execute an HTML form in interactive mode intFormMain String String String gt String Bool String 10 HtmlForm gt I0 Execute an HTML form in interactive mode with various parameters A 4 3 Library HtmlCgi Library to support CGI programming in the HTML library It is only intended as an auxiliary library to implement dynamic web pages according to the HTML library It contains a simple script that is installed for a dynamic web page and which sends the user input to the real application server implementing the application Exported types data CgiServerMsg The messages to comunicate between the cgi script and the server program CgiSubmit env cgienv nextpage pass the environment and show next page where env are the values of the environment variables
80. like C_Char into the corresponding Haskell types like Char Note that the Curry related types contain information about non deterministic or constrained values see 10 9 that are meaningless in Haskell To solve this conversion problem the implementation of KiCS2 provides a family of operations to perform these conversions for the predefined types occurring in the standard prelude For instance fromCurry converts a Curry type into the corresponding Haskell type and toCurry converts the Haskell type into the corresponding Curry type Thus we complete our example with the definition note that we simply ignore the final argument representing the constraint store external_d_C_prim_sconc si s2 toCurry fromCurry si fromCurry s2 String Here we use Haskell s concatenation operation to concatenate the string arguments The Oly type annotation String is necessary because is a polymorphic function so that the type inference system of Haskell has problems to determine the right instance of the conversion function The conversion between Curry types and Haskell types i e the family of conversion operation fromCurry and toCurry is defined in the KiCS2 implementation for all standard data types In particular it is also defined on function types so that one can easily implement external Curry I O lONote that all translated Curry modules are imported in the Haskell code fully qualified in order to avoid
81. list element with two lines Next list element It contains two paragraphs Final list element This is formatted as follows e First list element with two lines e Next list element It contains two paragraphs e Final list element Instead of a star one can also put dashes or plus to mark unordered list items Furthermore one could nest lists Thus the input text Color Yellow Read Blue BW Black White is formatted as e Color 273 Yellow Read Blue e BW Black White Similarly ordered lists i e with numbering each item are introduced by a number followed by a dot and at least one blank All following lines belonging to the same numbered item must have the same indent as the first line The actual value of the number is not important Thus the input 1 First element 99 Second element is formatted as 1 First element 2 Second element A quotation block is marked by putting a right angle followed by a blank in front of each line gt This is gt a quotation It will be formatted as a quote element This is a quotation A block containing program code starts with a blank line and is marked by intending each input line by at least four spaces where all following lines must have at least the same indentation as the first non blank character of the first line f x y let z x y in z z The indentation is removed in the output f x y let
82. not cover all aspects of Prolog but might be useful for applications generating Prolog programs Exported types data PlClause A Prolog clause is either a program clause consisting of a head and a body or a directive or a query without a head Exported constructors e PlClause String PlTerm PlGoal PlClause e PlDirective PlGoall gt PlClause e PlQuery PlGoal gt PlClause data PlGoal A Prolog goal is a literal a negated goal or a conditional 122 Exported constructors e PlLit String gt PlTerm PlGoal e PlNeg PlGoal gt PlGoal e PlCond PlGoal PlGoa1 PlGoal gt PlGoal data PlTerm A Prolog term is a variable atom number or structure Exported constructors e PlVar String PlTerm e PlAtom String PlTerm PlInt Int PlTerm e PlFloat Float PlTerm e PlStruct String PlTerm PlTerm Exported functions plList PlTerm PlTerm A Prolog list of Prolog terms showPlProg PlClause gt String Shows a Prolog program in standard Prolog syntax showPlClause PlClause String showPlGoals PlGoal gt String showPlGoal PlGoal String showPlTerm PlTerm String A 2 33 Library PropertyFile A library to read and update files containing properties in the usual equational syntax i e a property is defined by a line of the form prop value where prop starts with a letter
83. only those keys that are bound in both of the given maps and combines the elements as in add ToFM_C foldFM a gt b gt c gt c gt c FMaboc Folds finite map by given function mapFM a gt b gt c FMa b gt Mac Applies a given function on every element in the map filterFM a gt b gt Bool gt FMa b gt Mab Yields a new finite map with only those key element pairs matching the given predicate sizeFM FM a b Int How many elements does given map contain eqFM FM a b FM a b Bool Do two given maps contain the same key element pairs 145 isEmptyFM FM a b gt Bool Is the given finite map empty elemFM a gt FM a b gt Bool Does given map contain given key lookupFM FM a b gt a Maybe b Retrieves element bound to given key lookupWithDefaultFM FM a b gt b gt a gt b Retrieves element bound to given key If the element is not contained in map return default value keyOrder FM a b gt a gt a Bool Retrieves the ordering on which the given finite map is built minFM FM a b gt Maybe a b Retrieves the smallest key element pair in the finite map according to the basic key ordering maxFM FM a b Maybe a b Retrieves the greatest key element pair in the finite map according to the basic key ordering fmToList FM a b gt a b Builds a list of key element pairs The list is ordered by the initially given irreflexive
84. order predicate on keys keysFM FM a b gt a Retrieves a list of keys contained in finite map The list is ordered by the initially given irreflexive order predicate on keys eltsFM FM a b b Retrieves a list of elements contained in finite map The list is ordered by the initially given irreflexive order predicate on keys fmToListPreOrder FM a b gt a b Retrieves list of key element pairs in preorder of the internal tree Useful for lists that will be retransformed into a tree or to match any elements regardless of basic order fmSortBy a gt a Bool gt a gt a Sorts a given list by inserting and retrieving from finite map Duplicates are deleted 146 showFM FM a b gt String Transforms a finite map into a string For efficiency reasons the tree structure is shown which is valid for reading only if one uses the same ordering predicate readFM a a Bool gt String gt FM ab Transforms a string representation of a finite map into a finite map One has two provide the same ordering predicate as used in the original finite map A 3 4 Library GraphInductive Library for inductive graphs port of a Haskell library by Martin Erwig In this library graphs are composed and decomposed in an inductive way The key idea is as follows A graph is either empty or it consists of node context and a graph g which are put together by a constructor amp amp This cons
85. other literals like float or character con stants Exported constructors Branch Pattern Expr BranchExpr 227 data Pattern Data type for representing patterns in case expressions Exported constructors e Pattern String String gt Int Pattern e LPattern Literal Pattern data Literal Data type for representing literals occurring in an expression or case branch It is either an integer a float or a character constant Exported constructors e Intc Int gt Literal e Floatc Float Literal e Charc Char Literal Exported functions showQNameInModule String gt String String String Translates a given qualified type name into external name relative to a module Thus names not defined in this module except for names defined in the prelude are prefixed with their module name A 5 7 Library FlatCurry Files This library supports meta programming i e the manipulation of Curry programs in Curry This library defines I O actions Exported functions readFlatCurry String IO Prog I O action which parses a Curry program and returns the corresponding FlatCurry program Thus the argument is the module path without suffix curry or lcurry and the result is a FlatCurry term representing this program readFlatCurryWithParseOptions String FrontendParams gt I0 Prog I O action which parses a Curry program with respect to some parser opt
86. par 170 parallel 12 parens 115 parensIf 115 parseHtmlString 178 Parser 106 parser 14 ParserRep 106 parseXmlString 199 partition 52 101 partitionEithers 61 password 173 patArgs 241 266 patCons 241 266 patExpr 241 266 292 Path 148 path 8 12 pathSeparator 64 pathSeparatorChar 63 pathSeparators 64 patLiteral 241 266 Pattern 228 pattern functional 18 pChar 218 permutations 101 permute 52 persistentSQLite 98 pi 69 plainCode 271 PlClause 122 PlGoal 122 plList 123 PlTerm 123 plusFM 145 plusFM_C 145 pNil 218 popupMessage 84 Pos 160 pow 86 ppAVarIndex 253 ppBranch 245 253 ppCaseType 245 253 ppCExpr 221 ppCFuncDecl 221 ppCFuncDeclWithoutSig 221 ppCFuncSignature 221 ppCLiteral 221 ppComb 244 253 ppConsDecl 244 252 ppConsDecls 244 252 ppConsExports 243 251 ppCOpDecl 220 ppCPattern 221 ppCStatement 221 ppCTypeDecl 220 ppCTypeExpr 221 ppCurryProg 220 ppDecl 245 253 ppDecls 244 253 ppExp 244 253 ppExports 220 243 251 ppExpr 244 253 ppFixity 243 252 ppFunc 221 ppFuncDecl 244 253 ppFuncDecls 244 252 ppFuncExports 243 252 ppHeader 243 251 ppImport 243 252 ppImports 220 243 252 ppInfixOp 254 ppInfixQOp 245 ppLiteral 244 253 ppMName 220 ppName 245 ppOpDec1 243 252 ppOpDecls 243 252 ppPattern 245 253 ppPrefixOp 245 254 ppPrefixQUOp 245 ppProg 243 251 ppQFunc 221 ppQName 245 254 ppQType 221
87. parser with representation recognizing a terminal satisfying a given predicate star a gt b gt b gt a gt b gt b A star combinator for parsers The returned parser repeats zero or more times a parser p with representation and returns the representation of all parsers in a list some a gt b gt b gt a gt b gt b A some combinator for parsers The returned parser repeats the argument parser with representation at least once A 2 30 Library Pretty This library provides pretty printing combinators The interface is that of Daan Leijen s library linear time bounded implementation by Olaf Chitil Note that the implementation of fill and fillBreak is not linear time bounded Support of ANSI escape codes for formatting and colorisation of documents in text terminals see https en wikipedia org wiki ANSlIescapecode Exported types data Doc The abstract data type Doc represents pretty documents Exported constructors Exported functions pPrint Doc gt String Standard printing with a column length of 80 empty Doc The empty document isEmpty Doc Bool Is the document empty text String Doc The document text s contains the literal string s The string shouldn t contain any newline n characters If the string contains newline characters the function string should be used linesep String Doc 107 The document linesep s advances to the
88. purpose the first argument must be a transformation mapping values from the old type to the new type This function must be bijective and operationally invertible i e the inverse must be computable by narrowing Otherwise use transformWSpec wHidden WuiSpec a A hidden widget for a value that is not shown in the WUI Usually this is used in components of larger structures e g internal identifiers data base keys wConstant a HtmlExp WuiSpec a A widget for values that are shown but cannot be modified The first argument is a mapping of the value into a HTML expression to show this value wInt WuiSpec Int A widget for editing integer values wString WuiSpec String A widget for editing string values wStringSize Int WuiSpec String A widget for editing string values with a size attribute wRequiredString WuiSpec String A widget for editing string values that are required to be non empty wRequiredStringSize Int WuiSpec String A widget with a size attribute for editing string values that are required to be non empty wTextArea Int Int WuiSpec String A widget for editing string values in a text area The argument specifies the height and width of the text area 190 wSelect a gt String la gt WuiSpec a A widget to select a value from a given list of values The current value should be contained in the value list and is preselected The first argument is a mapping f
89. selected value Thus selectValue has always at most one value It fails if the value set is empty NOTE The usage of this operation is only safe i e does not destroy completeness if all values in the argument set are identical mapValues a gt b Values a gt Values b Accumulates all elements of a multiset of values by applying a binary operation This is similarly to fold on lists but the binary operation must be commutative so that the result is independent of the order of applying this operation to all elements in the multiset foldValues a gt a gt a gt a gt Values a gt a Accumulates all elements of a multiset of values by applying a binary operation This is similarly to fold on lists but the binary operation must be commutative so that the result is independent of the order of applying this operation to all elements in the multiset minValue a a gt Bool gt Values a gt a Returns the minimal element of a non empty multiset of values with respect to a given total ordering on the elements maxValue a gt a gt Bool gt Values a gt a Returns the maximal element of a non empty multiset of value with respect to a given total ordering on the elements 132 values2list Values a gt I0 la Puts all elements of a multiset of values in a list Since the order of the elements in the list might depend on the time of the computation this operation is an I O action printVal
90. showEscape 253 setOWith 130 showFlatFunc 247 set1 130 showFlatProg 246 setiWith 130 showFlatType 246 set2 130 showFM 147 set2With 130 showGraph 153 set3 130 showHtmlExp 174 set3With 130 showHtmlExps 174 set4 130 showHtmlPage 174 set4With 130 showJSExp 94 set5 131 showJSFDecl 94 set5With 131 showJSStat 94 set6 131 showLatexDoc 175 set6With 131 showLatexDocs 176 set7 131 showLatexDocsWithPackages 176 set7With 131 showLatexDocWithPackages 175 setAssoc 91 showLatexExp 175 setConfig 83 showLatexExps 175 setCurrentDirectory 55 showMemInfo 122 setEnviron 134 showP1Clause 123 296 showPlGoal 123 showPlGoals 123 showP1Prog 123 showPlTerm 123 showQNameInModule 228 showQTerm 125 showSearchTree 127 139 showSubst 161 showTerm 125 showTError 99 showTestCase 50 showTestCompileError 50 showTestEnd 50 showTestMod 50 showXmlDoc 198 showXmlDocWithParams 198 simpleRule 217 sin 70 singleton variables 7 sinh 70 sizedSubset 52 sizeFM 145 sleep 135 snoc 143 Socket 105 133 socketAccept 105 133 socketName 105 softbreak 108 softline 108 solveAll 7 some 107 someDBInfos 98 someDBKeyInfos 99 someDBKeyProjections 99 someDBKeys 98 someSearchTree 127 139 someSolution 68 someValue 68 129 140 someValueWith 129 140 sort 155 sortBy 102 sortRBT 156 sortValues 133 sortValuesBy 133 source file option 15 space 116 specials 60 spiceup 43
91. the Just constructor or return the provided default value if the argument is Nothing listToMaybe a Maybe a Return Nothing on an empty list or Just x where x is the first list element maybeToList Maybe a gt a Return an empty list for Nothing or a singleton list for Just x catMaybes Maybe a gt a Return the list of all Just values mapMaybe a gt Maybe b gt a gt b Apply a function which may throw out elements using the Nothing constructor to a list of elements gt gt Maybe a gt a Maybe b Maybe b Monadic bind for Maybe Maybe can be interpreted as a monad where Nothing is interpreted as the error case by this monadic binding sequenceMaybe Maybe a Maybe la Monadic sequence for Maybe mapMMaybe a Maybe b a gt Maybe b Monadic map for Maybe mplus Maybe a Maybe a gt Maybe a Combine two Maybes returning the first Just value if any 104 A 2 28 Library NamedSocket Library to support network programming with sockets that are addressed by symbolic names In contrast to raw sockets see library Socket this library uses the Curry Port Name Server to provide sockets that are addressed by symbolic names rather than numbers In standard applications the server side uses the operations listenOn and socketAccept to provide some service on a named socket and the client side uses the operation connectToSocket to request a servic
92. the argument types wiiTuple WuiSpec a WuiSpec b WuiSpec c gt WuiSpec d gt WuiSpec e gt WuiSpec f gt WuiSpec g gt WuiSpec h WuiSpec i gt WuiSpec j WuiSpec k gt WuiSpec a b c d e f g h i j k WUI combinator for tuples of arity 11 wConsl1 la lt b gt c gt d gt e gt f gt g gt h gt i gt j gt k gt 01l gt WuiSpec a gt WuiSpec b gt WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f WuiSpec g gt WuiSpec h gt WuiSpec i WuiSpec j WuiSpec k gt WuiSpec 1 WUI combinator for constructors of arity 11 The first argument is the ternary con structor The further arguments are the WUI specifications for the argument types wi2Tuple WuiSpec a WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f WuiSpec g WuiSpec h WuiSpec i WuiSpec j WuiSpec k gt WuiSpec 1 gt WuiSpec a b c d e f g h i j k 1 186 WUI combinator for tuples of arity 12 wCons12 la lt b gt c gt d gt e gt fl gt g gt h gt i gt j gt k gt 1l gt m gt WuiSpec a WuiSpec b WuiSpec c WuiSpec d WuiSpec e gt WuiSpec f gt WuiSpec g gt WuiSpec h gt WuiSpec i WuiSpec j WuiSpec k WuiSpec 1 gt WuiSpec m WUI combinator for constructors of arity 12 The first argument is the ternary con structor The further arguments are the WUI specifications for the argument types wJoinTuple WuiSpec a
93. the expression i e the evaluation of the expression does not share any results Note that this operation is not purely declarative since the ordering of the computed values depends on the ordering of the program rules someValue aa Returns some value for an expression currently via an incomplete depth first strat egy If the expression has no value the computation fails Conceptually the value is computed on a copy of the expression i e the evaluation of the expression does not share any results Note that this operation is not purely declarative since the computed value depends on the ordering of the program rules Thus this operation should be used only if the expression has a single value allSolutions a gt Bool gt la Returns all values satisfying a predicate i e all arguments such that the predicate applied to the argument can be evaluated to True currently via an incomplete depth first strategy Note that this operation is not purely declarative since the ordering of the computed values depends on the ordering of the program rules someSolution a Bool gt a Returns some values satisfying a predicate i e some argument such that the predicate applied to the argument can be evaluated to True currently via an incomplete depth first strategy Tf there is no value satisfying the predicate the computation fails Note that this operation is not purely declarative since the ordering of t
94. this module are I O actions in order to avoid some anomalities in the old concept Exported functions getAllValues a gt 10 la Gets all values of an expression currently via an incomplete depth first strategy Conceptually all values are computed on a copy of the expression i e the evaluation of the expression does not share any results Moreover the evaluation suspends as long as the expression contains unbound variables getOneValue a IO Maybe a Gets one value of an expression currently via an incomplete left to right strategy Returns Nothing if the search space is finitely failed getAllSolutions a gt Bool gt I0 la Gets all solutions to a constraint currently via an incomplete depth first left to right strategy Conceptually all solutions are computed on a copy of the constraint i e the evaluation of the constraint does not share any results Moreover this evaluation suspends if the constraints contain unbound variables Similar to Prolog s findall getOneSolution a Bool gt 10 Maybe a Gets one solution to a constraint currently via an incomplete left to right strategy Returns Nothing if the search space is finitely failed getAllFailures a gt a Bool gt I0 la Returns a list of values that do not satisfy a given constraint 48 A 2 2 Library Assertion This module defines the datatype and operations for the Curry module tester curryte
95. ti rere siesas LI Pe e ei SO ee BA Se Re a i Se a ee a ee a eS 421 Case Mode 2 ce ke sd sama ea 4 2 2 Identifiers and Keywords 0 00 eee eee eee Boo o IIA AA Numeric and Character Literals ccoo is di IOMA e a so EE aE a ote ae a ee ae A i Ia AA Context Free Grammar 6 64 4444 64 daa e a Optimization of Curry Programs CurryDoc A Documentation Generator for Curry Programs CurryBrowser A Tool for Analyzing and Browsing Curry Programs CurryTest A Tool for Testing Curry Programs 16 16 17 Iz 17 18 19 20 20 20 20 20 21 21 22 23 27 28 31 33 9 CurryPP A Preprocessor for Curry Programs 35 21 Mescated Cale oe id a ee A ee a ee Gee 35 9 1 1 Regular Expressions e 36 9 1 2 Format Specifications sis ce ee eae aa pa diaa a es 36 91 3 HTML Code 2 co aaien e oie eee e a oaa e A a aaa 37 gild AMG EEES u oroke a e a en ee A a A E da 38 9 2 Sequential Rules lt lt lt ee as 38 Og Debito Biles coc s oeo ap ee pa g we Ba RA ee ee 39 10 runcurry Running Curry Programs 40 11 ERD2Curry A Tool to Generate Programs from ER Specifications 42 12 Spicey An ER based Web Framework 43 13 Technical Problems 44 Bibliography 45 A Libraries of the KiCS2 Distribution 47 A 1 AbstractCurry and FlatCurry Meta Programming in Curry 47 A 2 General Libraries gt o cso ereere diadala es 48 ADI Library Aloha oe e iia a a agre belua gop RS Bae Baa 48 A22 Lib
96. tree via iterative deepening search idsStrategy SearchTree a gt ValueSequence a 139 allValuesIDSwith Int Int gt Int gt SearchTree a gt a Return the list of all values in a search tree via iterative deepening search The first argument is the initial depth bound and the second argument is a function to increase the depth in each iteration idsStrategyWith Int Int Int SearchTree a ValueSequence a Return all values in a search tree via iterative deepening search The first argument is the initial depth bound and the second argument is a function to increase the depth in each iteration getAllValuesWith SearchTree a ValueSequence a gt a gt I0 la Gets all values of an expression w r t a search strategy A search strategy is an opera tion to traverse a search tree and collect all values e g dfsStrategy or bfsStrategy Conceptually all values are computed on a copy of the expression i e the evaluation of the expression does not share any results Moreover the evaluation suspends as long as the expression contains unbound variables someValue a gt a Returns some value for an expression Note that this operation is not purely declarative since the computed value depends on the ordering of the program rules Thus this operation should be used only if the expression has a single value It fails if the expression has no value someValueWith SearchTree a gt
97. tref env tref 9 1 4 XML Expressions The foreign language tag xml introduces a notation for XML expressions see KiCS2 library XML The syntax is similar to the language tag html1 i e the use of the layout rule avoids closing tags and Curry expressions evaluating to strings String and XML expressions Xm1Exp can be included by enclosing them in curly and double curly brackets respectively The following example program shows its use OPTIONS_CYMAKE F pgmF currypp optF foreigncode import HTML import XML main 10 main putStrLn showXmlDoc head xml lt contact gt lt entry gt lt phone gt 49 431 8807271 lt name gt Hanus lt first gt Michael lt email gt mh informatik uni kiel de lt email gt hanus email uni kiel de lt entry gt lt name gt Smith lt first gt Bill lt phone gt 1 987 742 9388 a 9 2 Sequential Rules If the Curry preprocessor is called with the option seqrules then all rules in the Curry module are interpreted in a sequential manner i e a rule is applied only if all previous rules defining the same operation are not applicable either because the left hand side s pattern does not match or the condition is not satisfiable The idea and detailed semantics of sequential rules are described in 3 Sequential rules are useful and preferable over rules with multiple guards if the patterns are non trivial e g functional patterns or the conditio
98. tween with identity empty This effectively puts x and y underneath each other compose Doc gt Doc Doc gt Doc gt Doc The document compose f xs concatenates all documents xs with function f Func tion f should be like lt gt and so on hsep Doc Doc The document hsep xs concatenates all documents xs horizontally with lt gt vsep Doc Doc The document vsep xs concatenates all documents xs vertically with Ifa group undoes the line breaks inserted by vsep all documents are separated with a space someText map text words text to lay out test text some lt gt vsep someText This is layed out as some text to lay out The align combinator can be used to align the documents under their first element test text some lt gt align vsep someText This is printed as some text to lay out vsepBlank Doc gt Doc The document vsep xs concatenates all documents xs vertically with lt gt Ifa group undoes the line breaks inserted by vsepBlank all documents are separated with a space 111 fillSep Doc gt Doc The document fillSep xs concatenates documents xs horizontally with lt gt as long as its fits the page than inserts a line and continues doing that for all documents in xs fillSep xs foldr lt gt empty xs sep Doc gt Doc The document sep xs concatenates all documents xs either h
99. used all rules in a Curry module are interpreted as sequential i e a rule is applied only if all previous rules defining the same operation are not applicable The idea of sequential rules are described in 3 Default rules If this feature is used one can add a default rule to operations defined in a Curry module This provides a similar power than sequential rules but with a better operational behavior The idea of default rules are described in 5 The preprocessor is an executable named currypp which is stored in the directory kics2home bin In order to apply the preprocessor when loading a Curry source program into KiCS2 one has to add an option line at the beginning of the source program For instance in order to use default rules in a Curry program one has to put the line OPTIONS_CYMAKE F pgmF currypp optF defaultrules at the beginning of the program This option tells the KiCS2 front end to process the Curry source program with currypp before actually parsing the source text The option defaultrules has to be replaced by seqrules if the sequential rule matching should be replaced To support integrated code one has to set the option foreigncode which can also be combined with either defaultrules or seqrules If one wants to see the result of the 144 transformation one can also set the option o This has the effect that the transformed source program is stored in the f
100. value 1 if it is checked Entry Confltem Widget Entry an entry widget for entering single lines Label Confltem Widget Label a label for showing a text ListBox ConfItem Widget ListBox a widget containing a list of items for selection 74 data Message ConfItem Widget Message a message for showing simple string values MenuButton ConfItem gt Widget MenuButton a button with a pull down menu Scale Int gt Int gt ConfItem gt Widget Scale a scale widget to input values by a slider ScrollH WidgetRef gt ConfItem gt Widget ScrollH a horizontal scroll bar ScrollV WidgetRef gt ConfItem gt Widget ScrollV a vertical scroll bar TextEdit ConfItem Widget TextEdit a text editor widget to show and manipulate larger text paragraphs Row ConfCollection Widget Widget Row a horizontal alignment of widgets Col ConfCollection Widget gt Widget Col a vertical alignment of widgets Matrix ConfCollection gt Widget Widget Matrix a 2 dimensional matrix alignment of widgets ConfItem The data type for possible configurations of a widget 79 Exported constructors Active Bool ConfItem Active define the active state for buttons entries etc Anchor String ConfItem Anchor
101. z x y in z z To visualize the structure of a document one can also put a line containing only blanks and at least three dashes stars would also work in the source text This is formatted as a horizontal line 274 B 3 Headers The are two forms to mark headers In the first form one can underline the main header in the source text by equal signs and the second level header by dashes First level header Alternatively and for more levels one can prefix the header line by up to six hash characters where the number of characters corresponds to the header level where level 1 is the main header Main header Level 2 header Level 3 H H Level 4 HH HH Level 5 HHHHHH Level 6 275 C Auxiliary Files During the translation and execution of a Curry program with KiCS2 various intermediate repre sentations of the source program are created and stored in different files which are shortly explained in this section If you use KiCS2 it is not necessary to know about these auxiliary files because they are automatically generated and updated You should only remember the command for deleting all auxiliary files cleancurry see Section 1 2 to clean up your directories The various components of KiCS2 create the following auxiliary files prog fcy This file contains the Curry program in the so called FlatCurry representation where all functions are global i e lambda lifting has been per
102. 004 The University Court of the University of Glasgow All rights reserved Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions are met this list of conditions and the following disclaimer this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW AND THE CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPE CIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES INCLUDING BUT NOT LIMITED 71 TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE DATA OR PROFITS OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFT WARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Exported types data ArgOrder Exported constructors e RequireOrder ArgOrder a e Permute ArgOrder a e ReturnInO
103. 1 Library Traversal ocacion 158 A 3 12 Library Rewriting Term lt o oocomo sens sas sa 160 A 3 13 Library Rewriting Substitution scrire dgra 161 A 3 14 Library Rewriting Unification e 162 A 3 15 Library Rewriting UnificationSpec lt s sea tero cedet kea PE aes 162 Libraries for Web Applications 000 eee ee ee 162 A 4 1 Library CategorizedHtmlList 0 0 0 0000002 ee eee 162 ee Labs A ok bala ede ele ER oe he Bk Ew Swe es 163 AAS Library Html occiso EEA GD RM Ge Ae wae Head ew pO 176 Add Library HimlParmer a5 4 Pee wk Ae era Mb Re Pa BA Ba 178 AAD Labra Mail e 65 toog ee ek a ica ee PG ae Ree a als 178 Ab Library Mrkla see ee pos ele a ee be eek eo A 179 AAT Libry URL cocos aci a bey Be a aa 181 All Lab OD 0 o te ected oe OO e aos Be oe ee ges 182 AAY Library WUS esc bee che Adda Od eR eS eee RASS HS 188 AE AMG ses cea be we ee eb a we R E He Be Gea 197 A411 Libreoy Mone oe ee ea a ee Ee A OR ee als 199 2 5 Libraries tor Meta Programimin o sc cs ee a ee ees 206 A 5 1 Library AbstractCurry Types 000 eee eee eee 206 A 5 2 Library AbstractCurry Files o ee 211 A 5 3 Library AbstractCurry Select e ee ee eee 213 A 5 4 Library AbstractCurry Build oes e sea ec kori eo e ro e e E 216 A 5 5 Library AbstractCurry Pretty e 219 ADO Library PlatCuriy Types sc ek ee a de e we e 222 AST Library PlatCurre F
104. 11 and the 25th Workshop on Logic Programming WLP 2011 pages 22 33 INFSYS Research Report 1843 11 06 TU Wien 2011 B Brafel M Hanus B Peem ller and F Reck KiCS2 A new compiler from Curry to Haskell In Proc of the 20th International Workshop on Functional and Constraint Logic Programming WFLP 2011 pages 1 18 Springer LNCS 6816 2011 M Hanus A unified computation model for functional and logic programming In Proc of the 24th ACM Symposium on Principles of Programming Languages Paris pages 80 93 1997 M Hanus Distributed programming in a multi paradigm declarative language In Proc of the International Conference on Principles and Practice of Declarative Programming PPDP 99 pages 376 395 Springer LNCS 1702 1999 45 13 14 18 19 20 21 22 M Hanus A functional logic programming approach to graphical user interfaces In Inter national Workshop on Practical Aspects of Declarative Languages PADL 00 pages 47 62 Springer LNCS 1753 2000 M Hanus High level server side web scripting in Curry In Proc of the Third International Symposium on Practical Aspects of Declarative Languages PADL 01 pages 76 92 Springer LNCS 1990 2001 M Hanus A generic analysis environment for declarative programs In Proc of the ACM SIG PLAN 2005 Workshop on Curry and Functional Logic Programming WCFLP 2005 pages 43 48 ACM Press 2005 M Hanus CurryBrowser A generic an
105. 2 3 14159 9 1 3 HTML Code The foreign language tag html1 introduces a notation for HTML expressions see KiCS2 library HTML with the standard HTML syntax extended by a layout rule so that closing tags can be omitted In order to include strings computed by Curry expressions into these HTML syntax these Curry expressions must be enclosed in curly brackets The following example program shows its use OPTIONS_CYMAKE F pgmF currypp optF foreigncode import HTML htmlPage String HtmlExp htmlPage name html lt html gt lt head gt lt title gt Simple Test lt body gt lt hi gt Hello name lt h1 gt lt p gt Bye lt p gt Bye lt h2 gt reverse name Bye If a Curry expression computes an HTML expression i e it is of type HtmlExp instead of String it can be integrated into the HTML syntax by double curly brackets The following simple example taken from 14 shows the use of this feature OPTIONS_CYMAKE F pgmF currypp optF foreigncode import HTML main IO HtmlForm main return form Question html Enter a string textfield tref lt hr gt button Reverse string revhandler button Duplicate string duphandler where tref free revhandler env return form Answer html lt hi gt Reversed input reverse env tref 37 duphandler env return form Answer html lt h1 gt Duplicated input env
106. 206 CFieldDecl 208 CFixity 208 cfunc 217 CFuncDecl 209 CgiEnv 163 CgiRef 163 CgiServerMsg 176 cgiServerRegistry 177 char 115 200 checkAssertion 50 checkbox 173 checkedbox 173 childFamilies 159 children 159 choices 12 choose 131 chooseColor 86 chooseValue 132 cleancurry 6 cleanDB 99 CLiteral 211 CLocalDecl 209 ClockTime 135 clockTimeToInt 136 closeDBHandles 99 Cmd 85 cmp 14 cmpChar 157 283 cmpList 157 cmpString 157 cmtfunc 217 code 170 col 82 colon 116 Color 81 ColVal 95 combArgs 238 263 combine 66 110 142 combineSimilar 142 combName 238 263 CombType 225 combType 237 263 comma 116 Command 85 comment documentation 28 compareCalendarTime 137 compareClockTime 137 compareDate 137 compose 111 computeCompactFlatCurry 249 concatMapES 62 concurrency 7 ConfCollection 79 ConfigButton 85 ConfItem 75 connectToCommand 91 connectToSocket 106 134 connectToSocketRepeat 105 connectToSocketWait 106 cons 143 consArgs 232 257 consArity 232 257 ConsDecl 223 consName 214 232 257 constF 217 constructors 213 consVis 214 consVisibility 232 257 Context 148 context 150 Context 148 cookieForm 168 CookieParam 166 coordinates 175 COpDecl1 208 copyFile 56 cos 70 cosh 70 CPattern 210 cpnsAlive 53 cpnsshow 53 cpnsStart 53 cpnsstop 53 cpvar 218 createDirectory 55 createDirectoryIfMissing 56 CRhs 209 cro
107. 500 The type constructors OP_List and C_Char of the prelude Curry_Prelude correspond to the Curry type constructors for lists and characters The Haskell operation external_d_C_prim_sconc is the external operation to be implemented in Haskell by the programmer The additional argument of type ConstStore represents the current set of constraints when this operation is called This argument is intended to provide a more efficient access to binding constraints and can be ignored in standard operations If String curry contains the code of the Curry function sconc described above the Haskell code implementing the external operations occurring in the module String must be in the file External_String hs which is located in the same directory as the file String curry The KiCS2 compiler appends the code contained in External_String hs to the generated code stored in the file curry kics2 Curry_String hs In order to complete our example we have to write into the file External_String hs a definition of the Haskell function external_d_C_prim_sconc Thus we start with the following definitions import qualified Curry_Prelude as CP external_d_C_prim_sconc CP OP_List CP C_Char CP OP_List CP C_Char gt ConstStore CP OP_List CP C_Char First we import the standard prelude with the name CP in order to shorten the writing of type decla rations In order to write the final code of this operation we have to convert the Curry related types
108. 7 Token 270 Tokens 270 toLower 51 toTimeString 137 toUpper 51 toUTCTime 136 toVar 218 trace 13 54 138 traceld 54 tracel0 55 traceShow 54 traceShowld 55 Transaction 95 transformQ 96 transformWspec 183 190 transpose 101 Traversable 158 trBranch 240 265 trCombType 237 262 trCons 232 257 tree2list 155 trExpr 239 264 trFunc 235 260 trOp 234 259 trPattern 241 266 trProg 230 255 trRule 236 261 trType 231 256 trTypeExpr 233 258 truncate 69 try 7 tryParse 212 tryReadACYFile 213 tryReadCurryFile 212 tryReadCurryWithImports 212 tupled 114 298 tupledSpaced 114 tupleExpr 217 tuplePattern 218 tupleType 216 TVarIndex 222 tVarIndex 233 258 tvarsOfType 214 typeCons 214 typeConsDecls 231 256 TypeDecl 222 TypeEnv 269 TypeExpr 223 typeName 214 231 256 typeParams 231 256 types 213 typeSyn 231 256 typeVis 214 typeVisibility 231 256 UContext 148 UDecomp 148 UEdge 147 ufold 152 UGr 148 ulist 171 unAnnExpr 267 unAnnFuncDecl 267 unAnnPattern 267 unAnnProg 267 unAnnRule 267 underline 119 unfoldr 103 UnificationError 162 unify 162 union 100 unionBy 100 unionRBT 156 unitFM 144 unitType 216 UNode 147 unregisterCgiServer 177 unregisterPort 53 unsafePerforml0 138 unscan 271 unsetEnviron 134 untypedAbstractCurryFileName 212 UPath 148 Update 229 254 update 142 154 updateDBEntry 99 updateFile 91 updat
109. 8 Library NamedSocket ore e coea ae e aaa Oe ee Se A Oe Has 105 Ao Labrie Poe e poeu ok eo ace re eh oe ee Ge ee Sk a ees 106 24 2390 Library Pretty src 404 4 2444440 OMY Ge Rae ee ee Re we pO 107 FB a Library Prode oct Sew betwee ba Se ea wa 120 A292 Library Prolog co coe ee eK ph ica a RG be Ge ee a a 122 A 2 33 Library PropertyFile e 123 4 2304 Library Read o sa aoso ociosas a a a 124 2 230 Library Rea uUmerne ias Ew A a Te E 124 A 2 36 Library ReadShowTerm 02002 eee eee eee 125 A237 Library Search Tee o oe s A ae a AE ee we ee Bs 126 A 2 38 Library SetFunctions lt lt corer d o 1 Reps 129 A 439 Library Sockel e resida iaa a a e a is 133 AQAQ Library System cocos BR a A Ei a 134 AJAI Library Time cosa oe a 135 4 242 Library Unsale o os he Re aa a a 138 A 2 43 Library UnsafeSearch Tree e 138 A 2 44 Library ValueSequence 2 2 140 Data Structures and Algorithme socia ida ee Sl 141 Aal Array s 4 hh to hace te eo ee eh ee Bk EO Re ee d 141 A 3 2 Library Dequeue 2 2 ee 142 As Library FimteMap osas tdi a aaa gop a Se BaP aS 144 ASA Library Graphinductive e e lt sacs s acc iaa a a a 147 mo Library Randon oa S a a ee S 153 A 3 6 Library RedBlackTree 020002 eee 154 Poot o e EA Eee a 155 438 Library SARBI o occurred ca a e a a 155 e A ee ee a A Ee we ee TE 156 4 3 10 Library TableR BT o oces ke Ra ROR ee Re 157 231
110. 81 markdownText2LaTex 181 markdownText2LaTeXWithFormat 181 match 150 matchAny 149 matchHead 143 matchLast 143 matrix 82 max3 87 maxFM 146 maximum 103 maximumBy 103 maxlist 87 maxValue 132 maybeToList 104 maybeType 216 MContext 148 Menultenm 79 mergeSort 157 min3 87 minFM 146 minimum 103 minimumBy 103 minlist 87 minusFM 145 minValue 132 missingArgs 237 262 missingCombArgs 238 263 291 mkGraph 149 mkUGraph 149 MName 206 modify 62 modifylI0ORef 92 modNameToPath 59 modsOf Type 214 mplus 104 multipleSelection 173 nav 170 nbsp 169 neighbors 150 neighbors 151 nest 108 newDBEntry 99 newDBKeyEntry 99 newIORef 92 newNodes 152 newTreeLike 154 nextBoolean 154 nextInt 153 nextIntRange 153 nmap 153 noChildren 159 Node 147 node 151 nodeRange 150 nodes 152 noGuard 217 noHandlerPage 177 noindex 30 noNodes 150 normalise 67 notEmpty 131 nub 100 nubBy 100 odd 87 olist 171 on 71 once 7 onlyindex 30 OpDecl 223 openFile 88 operation external 278 opFixity 234 259 opName 234 259 opPrecedence 234 259 opt 201 OptDescr 72 optimize 13 Option 248 option in source file 15 Options 219 242 options 219 orC 53 orExps 238 263 out 151 out 152 outdeg 151 outdeg 152 overlapWarn 60 page 169 pageBodyAttr 169 pageCss 168 pageEnc 168 pageLinkInfo 169 pageMetalnfo 168 PageParam 166
111. 84 191 wRadioMaybe 187 196 wRadioSelect 184 191 wRequiredString 183 190 wRequiredStringSize 183 190 writeAbstractCurryFile 213 writeAssertResult 50 writeCSVFile 54 writeFCY 229 writeGlobal 73 writelORef 92 writeQTermFile 126 writeQTermListFile 126 writeXmlFile 198 writeXmlFileWithParams 198 wSelect 184 191 wSelectBool 184 191 wSelectInt 184 191 wString 183 190 wotringSize 183 190 wTextArea 183 190 WTree 182 189 wTree 188 196 wTriple 184 192 wui2html 188 196 WuiHandler 182 189 wuiHandler2button 182 189 wuilnForm 188 196 WuiSpec 182 189 wuiWithErrorForm 188 196 XAttrConv 199 XElemConv 199 xml 198 xml2FlatCurry 247 XmlDocParams 197 XmlExp 197 xmlFile2FlatCurry 247 xmlRead 200 XmlReads 199 xmlReads 200 xmlShow 200 XmlShows 199 xmlShows 200 XOptConv 199 XPrimConv 199 XRepConv 199 xtxt 198 yellow 119 301
112. All other lines e g blank lines or lines starting with are considered as comment lines and are ignored 123 Exported functions readPropertyFile String gt I0 String String Reads a property file and returns the list of properties Returns empty list if the property file does not exist updatePropertyFile String gt String String gt I0 Update a property in a property file or add it if it is not already there A 2 34 Library Read Library with some functions for reading special tokens This library is included for backward compatibility You should use the library ReadNumeric which provides a better interface for these functions Exported functions readNat String Int Read a natural number in a string The string might contain leadings blanks and the the number is read up to the first non digit readInt String Int Read a possibly negative integer in a string The string might contain leadings blanks and the the integer is read up to the first non digit readHex String Int Read a hexadecimal number in a string The string might contain leadings blanks and the the integer is read up to the first non heaxdecimal digit A 2 35 Library ReadNumeric Library with some functions for reading and converting numeric tokens Exported functions readInt String Maybe Int String Read a possibly negative integer as a first token in a string The string might conta
113. CES e scanr a gt b gt b gt b gt a gt b scanr is the right to left dual of scanl scanri a a gt a gt a gt al scanri is a variant of scanr that has no starting value argument mapAccumL a gt b gt a c a gt b gt a c The mapAccumL function behaves like a combination of map and foldl it applies a function to each element of a list passing an accumulating parameter from left to right and returning a final value of this accumulator together with the new list mapAccumR a gt b gt a c a gt b gt a c The mapAccumR function behaves like a combination of map and foldr it applies a function to each element of a list passing an accumulating parameter from right to left and returning a final value of this accumulator together with the new list cycle a gt a Builds an infinite list from a finite one unfoldr a gt Maybe b a gt a gt b Builds a list from a seed value 103 A 2 27 Library Maybe Library with some useful functions on the Maybe datatype Exported functions isJust Maybe a gt Bool Return True iff the argument is of the form Just _ isNothing Maybe a Bool Return True iff the argument is of the form Nothing fromJust Maybe a gt a Extract the argument from the Just constructor and throw an error if the argument is Nothing fromMaybe a gt Maybe a gt a Extract the argument from
114. CRule or a case expression It is either a simple unconditional right hand side or a list of guards with their corresponding right hand sides and a list of local declarations Exported constructors e CSimpleRhs CExpr gt CLocalDec1 CRhs e CGuardedRhs CExpr CExpr gt CLocalDec1 CRhs data CLocalDecl Data type for representing local let where declarations Exported constructors 209 data CLocalFunc CFuncDecl CLocalDecl CLocalPat CPattern CRhs CLocalDecl CLocalVars Int String gt CLocalDecl CPattern Data type for representing pattern expressions Exported constructors data CPVar Int String CPattern CPLit CLiteral CPattern CPComb String String CPattern gt CPattern CPAs Int String gt CPattern gt CPattern CPFuncComb String String gt CPattern gt CPattern CPLazy CPattern gt CPattern CPRecord String String String String CPattern CPattern CExpr Data type for representing Curry expressions Exported constructors CVar Int String CExpr CLit CLiteral CExpr CSymbol String String gt CExpr CApply CExpr CExpr CExpr CLambda CPattern gt CExpr CExpr CLetDecl CLocalDecl CExpr CExpr CDoExpr CStatement gt CExpr CListComp CExpr gt CStatement gt CExpr CCase CCaseType gt CExpr
115. Creates a new directory with the given name if it does not already exist If the first parameter is True it will also create all missing parent directories removeDirectory String gt 10 Deletes a directory from the file system renameDirectory String String gt I0 Renames a directory getHomeDirectory 10 String Returns the home directory of the current user getTemporaryDirectory 10 String Returns the temporary directory of the operating system getAbsolutePath String 10 String Convert a path name into an absolute one For instance a leading is replaced by the current home directory removeFile String gt 10 Deletes a file from the file system renameFile String String gt I0 Renames a file copyFile String String gt I0 Copy the contents from one file to another file A 2 10 Library Distribution This module contains functions to obtain information concerning the current distribution of the Curry implementation e g compiler version load paths front end Exported types data FrontendTarget Data type for representing the different target files that can be produced by the front end of the Curry compiler Exported constructors e FCY FrontendTarget FCY 56 data FlatCurry file ending with fcy FINT FrontendTarget FINT FlatCurry interface file ending with fint ACY FrontendTarget ACY AbstractCurry file ending with acy
116. Curry Port Name Server CPNS to implement symbolic names for named sockets in Curry If some other process uses this port on the machine the distribution facilities defined in the module NamedSocket cannot be used If these features do not work you can try to find out whether this port is in use by the shell command netstat a fgrep 8767 or similar The CPNS is implemented as a demon listening on its port 8767 in order to serve requests about registering a new symbolic name for a named socket or asking the physical port number of an registered named socket The demon will be automatically started for the first time on a machine when a user runs a program using named sockets It can also be manually started and terminated by the scripts kics2home cpns start and kics2home cpns stop If the demon is already running the command kics2home cpns start does nothing so it can be always executed before invoking a Curry program using named sockets If you detect any further technical problem please write to kics2 curry language org 44 References 1 10 11 12 S Antoy and M Hanus Declarative programming with function patterns In Proceedings of the International Symposium on Logic based Program Synthesis and Transformation LOP STR 05 pages 6 22 Springer LNCS 3901 2005 S Antoy and M Hanus Set functions for functional logic programming In Proceedings of the 11th ACM SIGPLAN International Conference o
117. Decl OpDecl update operator declaration updOpName String String gt String String OpDecl gt OpDecl update name of operator declaration updOpFixity Fixity gt Fixity OpDecl OpDecl update fixity of operator declaration updOpPrecedence Int Int OpDecl gt OpDecl update precedence of operator declaration 259 trFunc String String gt Int gt Visibility gt TypeExpr ARule a gt b gt AFuncDecl a gt b transform function funcName AFuncDecl a gt String String get name of function funcArity AFuncDecl a gt Int get arity of function funcVisibility AFuncDecl a Visibility get visibility of function funcType AFuncDecl a TypeExpr get type of function funcRule AFuncDecl a ARule a get rule of function updFunc String String gt String String Int gt Int gt Visibility gt Visibility TypeExpr gt TypeExpr ARule a ARule a gt AFuncDecl a gt AFuncDecl a update function updFuncName String String gt String String AFuncDecl a AFuncDecl a update name of function updFuncArity Int gt Int gt AFuncDecl a gt AFuncDecl a update arity of function updFuncVisibility Visibility gt Visibility gt AFuncDecl a gt AFuncDecl a update visibility of function updFuncType TypeExpr TypeExpr AFuncDecl a gt AFuncDecl a update type of
118. Handler Generates HTML editors and a handler from a WUI data specification an initial value and an update form In addition to wui2html we can provide a skeleton form used to show illegal inputs 196 A 4 10 Library XML Library for processing XML data Warning the structure of this library is not stable and might be changed in the future Exported types data XmlExp The data type for representing XML expressions Exported constructors e XText String XmlExp XText a text string PCDATA e XElem String gt String String XmlExp gt XmlExp XElem an XML element with tag field attributes and a list of XML elements as contents data Encoding The data type for encodings used in the XML document Exported constructors e StandardEnc Encoding e Iso88591Enc Encoding data XmlDocParams The data type for XML document parameters Exported constructors e Enc Encoding XmlDocParams Enc the encoding for a document e DtdUrl String XmlDocParams DtdUrl the url of the DTD for a document 197 Exported functions tagOf XmlExp String Returns the tag of an XML element or empty for a textual element elemsOf XmlExp gt XmlExp Returns the child elements an XML element textOf XmlExp gt String Extracts the textual contents of a list of XML expressions Useful auxiliary function when transforming XML expressions into other data structur
119. If conditional JSSwitch JSExp gt JSBranch gt JSStat JSSwitch switch statement JSPCall String gt JSExp gt JSStat JSPCall 93 procedure call e JSReturn JSExp JSStat JSReturn return statement e JSVarDecl Int gt JSStat JSVarDecl local variable declaration data JSBranch Exported constructors e JSCase String JSStat JSBranch JSCase case branch e JSDefault JSStat JSBranch JSDefault default branch data JSFDecl Exported constructors e JSFDecl String gt Int gt JSStat gt JSFDecl Exported functions showJSExp JSExp String Shows a JavaScript expression as a string in JavaScript syntax showJSStat Int JSStat String Shows a JavaScript statement as a string in JavaScript syntax with indenting showJSFDecl JSFDecl String Shows a JavaScript function declaration as a string in JavaScript syntax jsConsTerm String gt JSExp gt JSExp Representation of constructor terms in JavaScript 94 A 2 25 Library KeyDatabaseSQLite This module provides a general interface for databases persistent predicates where each entry consists of a key and an info part The key is an integer and the info is arbitrary All functions are parameterized with a dynamic predicate that takes an integer key as a first parameter This module reimplements the interface of the module KeyDa
120. InfixOpID 25 infix operator application unary int minus unary float minus lambda expression n gt 0 let expression conditional case expression n gt 0 fcase expression n gt 0 do expression n gt 0 function application variable anonymous free variable qualified function general constructor parenthesized expression tuple n gt 1 finite list n gt 0 arithmetic sequence left section right section list comprehension n gt 1 labeled construction n gt 0 function qualified function Variable DataConstr QDataConstr QFunOp ConsOp QOp QConsOp GConSym VariableID InficOpID DataConstrID InfirOpID QDataConstrID QConsOp QInficOpID GFunctionID InficOpID DataConstrID QFunOp QConsOp GConSym QDataConstrID QInfizOpID 26 variable constructor qualified constructor qualified function operator constructor operator qualified operator qualified constructor operator general constructor symbol 5 Optimization of Curry Programs After the invocation of the Curry front end which parses a Curry program and translates it into the intermediate FlatCurry representation KiCS2 applies a transformation to optimize Boolean equalities occurring in the Curry program The ideas and details of this optimization are described in 4 Therefore we sketch only some basic
121. Int gt Int Int gt SearchTree a gt la Return all values in a search tree via iterative deepening search The first argument is the initial depth bound and the second argument is a function to increase the depth in each iteration allValuesDiag SearchTree a gt a Return all values in a search tree via diagonalization search strategy getAllValuesWith SearchTree a ValueSequence a gt a gt I0 la Gets all values of an expression w r t a search strategy A search strategy is an opera tion to traverse a search tree and collect all values e g dfsStrategy or bfsStrategy Conceptually all values are computed on a copy of the expression i e the evaluation of the expression does not share any results printAllValuesWith SearchTree a ValueSequence a a gt I0 Prints all values of an expression w r t a search strategy A search strategy is an opera tion to traverse a search tree and collect all values e g dfsStrategy or bfsStrategy Conceptually all printed values are computed on a copy of the expression i e the evaluation of the expression does not share any results printValuesWith SearchTree a ValueSequence a gt a gt I0 128 Prints the values of an expression w r t a search strategy on demand by the user Thus the user must type lt enter gt lt enter gt before another value is computed and printed A search strategy is an operation to traverse a search tree and co
122. ML converter representing a sequence of arbitrary XML data The se quence must not be used in repetitions and does not represent an XML element repSegb a b gt c gt d gt e f gt XmlConv Repeatable g a gt XmlConv Repeatable h b XmlConv Repeatable i c XmlConv Repeatable j d gt XmlConv Repeatable k e XmlConv NotRepeatable NoElem f 204 Creates an XML converter that represents a repetition of a sequence of repeatable XML data The repetition may be used in other repetitions and does not represent an XML element This combinator is provided because converters for repeatable sequences cannot be constructed by the seq combinators eSeq5 String gt la gt b gt c gt d gt e gt f gt XmlConv g ha gt XmlConv i j b gt XmlConv k 1 c XmlConv m n d gt XmlConv o p e XmlConv Repeatable Elem f Creates an XML converter for compound values represented as an XML element with children that correspond to the values components The element can be used in repe titions eRepSeq5 String gt a gt b gt c gt d e gt f gt XmlConv Repeatable g a gt XmlConv Repeatable h b gt XmlConv Repeatable ic gt XmlConv Repeatable j d gt XmlConv Repeatable k e gt XmlConv Repeatable Elem f Creates an XML converter for repetitions of sequences represented as an XML element that can be used in repetitions seq6 a gt b gt c gt d
123. ValueSequence a gt a gt a Returns some value for an expression w r t a search strategy A search strategy is an operation to traverse a search tree and collect all values e g dfsStrategy or bfsStrategy Note that this operation is not purely declarative since the computed value depends on the ordering of the program rules Thus this operation should be used only if the expression has a single value It fails if the expression has no value A 2 44 Library ValueSequence This library defines a data structure for sequence of values It is used in search trees module SearchTree as well as in set functions module SetFunctions Using sequence of values rather than standard lists of values is necessary to get the behavior of set functions w r t finite failures right as described in the paper J Christiansen M Hanus F Reck D Seidel A Semantics for Weakly Encapsulated Search in Functional Logic Programs Proc 15th International Conference on Principles and Practice of Declarative Programming PPDP 13 pp 49 60 ACM Press 2013 140 Exported types data ValueSequence A value sequence is an abstract sequence of values It also contains failure elements in order to implement the semantics of set functions w r t failures in the intended manner Exported constructors Exported functions emptyVS ValueSequence a An empty sequence of values addVS a ValueSequence a ValueSequence a Adds a value to a seq
124. a gt Either b a Replace the current state modify a gt a gt a gt Either b a Modify the current state mapES a gt b gt Either c d b gt la gt b gt Either c d b Map a monadic function on all elements of a list by sequencing the effects concatMapES a gt b gt Either c d b gt a gt b gt Either c d b Same as concatMap but for a monadic function mapAccumES a gt b gt c gt Either d a e c gt a gt b gt c gt Either d Ca Le c Same as mapES but with an additional accumulator threaded through 62 A 2 13 Library FileGoodies A collection of useful operations when dealing with files Exported functions separatorChar Char The character for separating hierarchies in file names On UNIX systems the value is pathSeparatorChar Char The character for separating names in path expressions On UNIX systems the value is suffixSeparatorChar Char The character for separating suffixes in file names On UNIX systems the value is isAbsolute String Bool Is the argument an absolute name dirName String String 999 Extracts the directoy prefix of a given Unix file name Returns if there is no prefix baseName String String Extracts the base name without directoy prefix of a given Unix file name splitDirectoryBaseName String String String Splits a Unix file name into the directory prefix a
125. a prefix of another isSuffix0f a a Bool Checks whether a list is a suffix of another isInfix0f a gt a Bool Checks whether a list is contained in another sortBy a gt a gt Bool gt a gt a Sorts a list w r t an ordering relation by the insertion method insertBy a gt a gt Bool gt a gt a gt a Inserts an object into a list according to an ordering relation last a gt a Returns the last element of a non empty list init la gt a Returns the input list with the last element removed sum Int gt Int Returns the sum of a list of integers product Int gt Int 102 Returns the product of a list of integers maximum a gt a Returns the maximum of a non empty list maximumBy a gt a Ordering gt a gt a Returns the maximum of a non empty list according to the given comparison function minimum a gt a Returns the minimum of a non empty list minimumBy a gt a Ordering gt a gt a Returns the minimum of a non empty list according to the given comparison function scanl a gt b gt a gt a gt lb gt a scanl is similar to fol1d1 but returns a list of successive reduced values from the left scanl f z x1 x2 z z f x1 z f x1 f x2 scanli a a gt a gt a gt a scan11 is a variant of scanl that has no starting value argument scanl1 f x1 x2 pel
126. ains those elements that satisfy the predicate argument and the second list contains the remaining arguments Example partition lt 4 8 1 5 2 4 3 1 2 3 8 5 4 group a gt al Splits the list argument into a list of lists of equal adjacent elements Example group 1 2 2 3 3 3 4 1 2 2 3 3 3 4 groupBy a a gt Bool gt a gt fal Splits the list argument into a list of lists of related adjacent elements splitOn a gt a gt a Breaks the second list argument into pieces separated by the first list argument con suming the delimiter An empty delimiter is invalid and will cause an error to be raised split a gt Bool gt a gt a 101 Splits a list into components delimited by separators where the predicate returns True for a separator element The resulting components do not contain the separators Two adjacent separators result in an empty component in the output split a aabbaca p gt q bb ve e split 9999 K inits al gt a Returns all initial segments of a list starting with the shortest Example inits 1 2 3 1 1 2 1 2 3 tails a gt a Returns all final segments of a list starting with the longest Example tails 1 2 3 1 2 3 2 3 3 replace a gt Int gt a gt a Replaces an element in a list isPrefix0f a gt a Bool Checks whether a list is
127. al type isIOType CTypeExpr Bool Returns true if the type expression is IO t isIOReturnType CTypeExpr Bool Returns true if the type expression is IO t with t and t is not functional argTypes CTypeExpr CTypeExpr Returns all argument types from a functional type resultType CTypeExpr CTypeExpr Return the result type from a nested functional type tvarsOfType CTypeExpr gt Int String Returns all type variables occurring in a type expression mods0f Type CTypeExpr String Returns all modules used in the given type 214 funcName CFuncDecl gt String String Returns the name of a given function declaration funcVis CFuncDecl CVisibility Returns the visibility of a given function declaration varsOfPat CPattern gt Int String Returns list of all variables occurring in a pattern Each occurrence corresponds to one element i e the list might contain multiple elements varsOfExp CExpr gt Int String Returns list of all variables occurring in an expression Each occurrence corresponds to one element i e the list might contain multiple elements varsOfRhs CRhs gt Int String Returns list of all variables occurring in a right hand side Each occurrence corresponds to one element i e the list might contain multiple elements varsOfStat CStatement gt Int String Returns list of all variables occurring in a statement Eac
128. all datatypes are explained in detail in these modules we refer to the online documentation of these modules As an example consider a program file test curry containing the following two lines rev rev x xs rev xs x Then the I O action FlatCurry Files readFlatCurry test returns the following term Prog test Prelude Func test rev 1 Public FuncType TCons Prelude TVar 0 TCons Prelude TVar 0 Rule 0 Case Flex Var 1 Branch Pattern Prelude 1 Comb ConsCall Prelude 0O Branch Pattern Prelude 2 3 Comb FuncCall Prelude Comb FuncCall test rev Var 3 http www ps informatik uni kiel de kics2 1ib FlatCurry Types html and http www ps informatik uni kiel de kics2 1ib AbstractCurry Types html AT Comb ConsCall Prelude Var 2 Comb ConsCall Prelude 1 1 333 A 2 General Libraries A 2 1 Library AllSolutions This module contains a collection of functions for obtaining lists of solutions to constraints These operations are useful to encapsulate non deterministic operations between I O actions in order to connect the worlds of logic and functional programming and to avoid non determinism failures on the I O level In contrast the old concept of encapsulated search which could be applied to any subexpression in a computation the operations to encapsulate search in
129. alue list and is preselected wSelectBool String String WuiSpec Bool A widget to select a Boolean value via a selection box The arguments are the strings that are shown for the values True and False in the selection box respectively wCheckBool HtmlExp gt WuiSpec Bool A widget to select a Boolean value via a check box The first argument are HTML expressions that are shown after the check box The result is True if the box is checked wMultiCheckSelect a gt HtmlExp a WuiSpec a A widget to select a list of values from a given list of values via check boxes The current values should be contained in the value list and are preselected The first argument is a mapping from values into HTML expressions that are shown for each item after the check box wRadioSelect a HtmlExp a WuiSpec a A widget to select a value from a given list of values via a radio button The current value should be contained in the value list and is preselected The first argument is a mapping from values into HTML expressions that are shown for each item after the radio button wRadioBool HtmlExp HtmlExp WuiSpec Bool A widget to select a Boolean value via a radio button The arguments are the lists of HTML expressions that are shown after the True and False radio buttons respectively wPair WuiSpec a WuiSpec b WuiSpec a b WUI combinator for pairs wCons2 a b gt c
130. alysis environment for Curry programs In Proc of the 16th Workshop on Logic based Methods in Programming Environments WLPE 06 pages 61 74 2006 M Hanus Type oriented construction of web user interfaces In Proceedings of the 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming PPDP 06 pages 27 38 ACM Press 2006 M Hanus and S Koschnicke An ER based framework for declarative web programming Theory and Practice of Logic Programming 14 3 269 291 2014 M Hanus and F Steiner Controlling search in declarative programs In Principles of Declar ative Programming Proc Joint International Symposium PLILP ALP 98 pages 374 390 Springer LNCS 1490 1998 M Hanus ed Curry An integrated functional logic language vers 0 9 0 Available at http www curry language org 2015 T Johnsson Lambda lifting Transforming programs to recursive functions In Functional Programming Languages and Computer Architecture pages 190 203 Springer LNCS 201 1985 P Wadler Efficient compilation of pattern matching In S L Peyton Jones editor The Implementation of Functional Programming Languages pages 78 103 Prentice Hall 1987 46 A Libraries of the KiCS2 Distribution The KiCS2 distribution comes with an extensive collection of libraries for application program ming The libraries for meta programming by representing Curry programs as datatypes in Curry are described in the f
131. ample we show the implementation of the previous example for sequential rules with a default rule OPTIONS_CYMAKE F pgmF currypp optF defaultrules mlookup key _ key value _ Just value mlookup default _ Nothing Default rules are often a good replacement for negation as failure used in logic programming For instance the following program defines a solution to the n queens puzzle where the default rule is useful since it is easier to characterize the unsafe positions of the queens on the chessboard see the first rule of safe OPTIONS_CYMAKE F pgmF currypp optF defaultrules import Combinatorial permute import Integer abs A placement is safe if two queens are not in a same diagonal safe _ x ys z _ abs x z length ys 1 failed safe default xs xs A solution to the n queens puzzle is a safe permutation queens Int Int queens n safe permute 1 n 39 10 runcurry Running Curry Programs runcurry is a command usually stored in kics2home bin where kics2home is the installation direc tory of KiCS2 see Section 1 2 This command supports the execution of Curry programs without explicitly invoking the interactive environment Hence it can be useful to write short scripts in Curry intended for direct execution The Curry program must always contain the definition of an operation main of type 10 The execution of the program consists of t
132. an Float Float Arc tangent sinh Float Float Hyperbolic sine cosh Float Float tanh Float Float Hyperbolic tangent asinh Float Float Hyperbolic Arc sine acosh Float Float atanh Float gt Float Hyperbolic Arc tangent A 2 17 Library Function This module provides some utility functions for function application 70 Exported functions fix a gt a gt a fix f is the least fixed point of the function f i e the least defined x such that f x x on la gt a gt b gt c gt a gt c gt c gt 6b on f Ax y gt f x f y Typical usage sortBy compare on fst first a gt b gt a c gt b c Apply a function to the first component of a tuple second a gt b gt c a gt c b Apply a function to the second component of a tuple a gt b gt c gt d gt a c gt b d Apply two functions to the two components of a tuple amp amp amp a gt b gt a gt c Daa b c Apply two functions to a value and returns a tuple of the results both a gt b gt a a gt b b Apply a function to both components of a tuple A 2 18 Library GetOpt This Module is a modified version of the Module System Console GetOpt by Sven Panne from the ghc base package it has been adapted for Curry by Bjoern Peemoeller c Sven Panne 2002 2005 The Glasgow Haskell Compiler License Copyright 2
133. andle gt 10 Runs a Widget in a new GUI window and process GUI events after executing an initial action on the GUI window In addition an event handler is provided that process messages received from an external message stream This operation is useful to run a GUI that should react on user events as well as messages written to the given handle runHandlesControlledGUI String gt Widget Handle GuiPort gt 10 Reconfigureltem Handle 10 O Runs a Widget in a new GUI window and process GUI events In addition a list of event handlers is provided that process inputs received from a corresponding list of handles to input streams Thus if the i th handle has some data available the i th event handler is executed with the i th handle as a parameter This operation is useful to run a GUI that should react on inputs provided by other processes e g via sockets runInitHandlesControlledGUI String Widget Handle GuiPort gt IO ReconfigureItem GuiPort 10 ReconfigureItem gt Handle I0 Runs a Widget in a new GUI window and process GUI events after executing an initial action on the GUI window In addition a list of event handlers is provided that process inputs received from a corresponding list of handles to input streams Thus if the i th handle has some data available the i th event handler is executed with the i th handle as a parameter This operation is useful to run a
134. arguments min3 a gt a gt a gt a Returns the minimum of the three arguments maxlist a a Returns the maximum of a list of integer values Fails if the list is empty minlist a a Returns the minimum of a list of integer values Fails if the list is empty bitTrunc Int gt Int gt Int The value of bitTrunc n mis the value of the n least significant bits of m bitAnd Int Int Int Returns the bitwise AND of the two arguments bitOr Int Int gt Int Returns the bitwise inclusive OR of the two arguments bitNot Int gt Int Returns the bitwise NOT of the argument Since integers have unlimited precision only the 32 least significant bits are computed bitXor Int Int Int Returns the bitwise exclusive OR of the two arguments even Int Bool Returns whether an integer is even odd Int Bool Returns whether an integer is odd 87 A 2 22 Library IO Library for IO operations like reading and writing files that are not already contained in the prelude Exported types data Handle The abstract type of a handle for a stream Exported constructors data I0Mode The modes for opening a file Exported constructors e ReadMode IOMode e WriteMode IOMode e AppendMode IOMode data SeekMode The modes for positioning with hSeek in a file Exported constructors e AbsoluteSeek SeekMode e RelativeSeek SeekMode e SeekFromEnd SeekMode Expor
135. arious kinds of transaction errors Exported constructors KeyNotExistsError TErrorKind NoRelationshipError TErrorKind DuplicateKeyError TErrorKind KeyRequiredError TErrorKind UniqueError TErrorKind MinError TErrorKind MaxError TErrorKind UserDefinedError TErrorKind ExecutionError TErrorKind Exported functions runQ Query a gt 10 a Runs a database query in the IO monad transformQ a gt b gt Query a gt Query b runT Applies a function to the result of a database query Transaction a gt IO Either a TError Runs a transaction atomically in the IO monad Transactions are immediate which means that locks are acquired on all databases as soon as the transaction is started After one transaction is started no other database connection will be able to write to the database or start a transaction Other connections can read the database during a transaction of another process The choice to use immediate rather than deferred transactions is conservative It might also be possible to allow multiple simultaneous transactions that lock tables on the first database access which is the default in SQLite However this leads to unpredictable 96 order in which locks are taken when multiple databases are involved The current implementation fixes the locking order by sorting databases by their name and locking them in order immediately when a transaction begins More information
136. arser for HTML documents Exported functions readHtmlFile String 10 HtmlExp Reads a file with HTML text and returns the corresponding HTML expressions parseHtmlString String HtmlExp Transforms an HTML string into a list of HTML expressions If the HTML string is a well structured document the list of HTML expressions should contain exactly one element A 4 5 Library Mail This library contains functions for sending emails The implementation might need to be adapted to the local environment Exported types data MailOption Options for sending emails Exported constructors e CC String Mail0Option CC recipient of a carbon copy e BCC String MailOption BCC recipient of a blind carbon copy e TO String MailOption TO recipient of the email 178 Exported functions sendMail String gt String String String 10 Sends an email via mailx command sendMailWithOptions String String gt MailOption gt String gt I0 Sends an email via mailx command and various options Note that multiple options are allowed e g more than one CC option for multiple recipient of carbon copies Important note The implementation of this operation is based on the command mailx and must be adapted according to your local environment A 4 6 Library Markdown Library to translate markdown documents into HTML or LaTeX The slightly res
137. arting the installation process using make lt optional target gt PROFILING yes In the following kics2home denotes the installation directory of the KiCS2 installation 1 2 General Use All executables required to use the different components of KiCS2 are stored in the direc tory kics2home bin You should add this directory to your path e g by the bash command export PATH kics2home bin PATH The source code of the Curry program must be stored in a file with the suffix curry e g lcurry prog curry Literate programs must be stored in files with the extension Since the translation of Curry programs with KiCS2 creates some auxiliary files see Section C for details you need write permission in the directory where you have stored your Curry programs The auxiliary files for all Curry programs in the current directory can be deleted by the command cleancurry this is a shell script stored in the bin directory of the KiCS2 installation see above The command cleancurry r also deletes the auxiliary files in all subdirectories 1 3 Restrictions There are a few minor restrictions on Curry programs when they are processed with KiCS2 e Singleton pattern variables i e variables that occur only once in a rule should be denoted on as an anonymous variable otherwise the parser will print a warning since this is a typical source of programming errors e KiCS2 translates all local declaration
138. ary the global value exists only during a single execution of a program e Persistent String GlobalSpec Persistent f the global value is stored persisently in file f which is created and initialized if it does not exists Exported functions global a GlobalSpec Global a global is only used for the declaration of a global value and should not be used else where In the future it might become a keyword readGlobal Global a gt IO a Reads the current value of a global writeGlobal Global a gt a gt 10 Updates the value of a global The value is evaluated to a ground constructor term before it is updated 73 A 2 20 Library GUI This library contains definitions and functions to implement graphical user interfaces for Curry programs It is based on Tcl Tk and its basic ideas are described in detail in this paper Exported types data GuiPort The port to a GUI is just the stream connection to a GUI where Tcl Tk communication is done Exported constructors data Widget The type of possible widgets in a GUI Exported constructors PlainButton ConfItem Widget PlainButton a button in a GUI whose event handler is activated if the user presses the button Canvas ConfItem Widget Canvas a canvas to draw pictures containing CanvasItems CheckButton ConfItem Widget CheckButton a Check button it has value 0 if it is unchecked and
139. ase directory name will be relative to the place where the web programs are stored In order to avoid such confusion it might be better to specify an absolute path name for the database directory After the generation of this project see the generated file README txt for information about the generated project structure one can compile the generated programs by make compile In order to generate the executable web application configure the generated Makefile by adapting the variable WEBSERVERDIR to the location where the compiled cgi programs should be stored and run make deploy After the successful compilation and deployment of all files the application is executable in a web browser by selecting the URL lt URL of web dir gt spicey cgi 43 13 Technical Problems One can implement distributed systems with KiCS2 by the use of the library NamedSocket Sec tion A 2 28 that supports a socket communication with symbolic names rather than natural num bers For instance this library is the basis of programming dynamic web pages with the libraries HTML Section A 4 2 or WUI Section A 4 8 However it might be possible that some technical problems arise due to the use of named sockets Therefore this section gives some information about the technical requirements of KiCS2 and how to solve problems due to these requirements There is one fixed port that is used by the implementation of KiCS2 Port 8767 This port is used by the
140. ase of identifiers 4 2 2 Identifiers and Keywords Letter any ASCII letter Dashes Ident Letter Letter Digit _ gt Symbol l Si A 7 lt gt 2 i lit ModuleID Ident Ident TypeConstrID Ident DataConstrID Ident TypeVarID Ident _ InficOpID Symbol Symbol Dashes FunctionID Ident Variable ID Ident LabelID Ident 20 QTypeConstrID ModuleID TypeConstrID QDataConstrID ModuleID DataConstrID QInfizxOpID ModuleID InfixOpID QFunctionID ModulelD FunctionID QVariablelD ModuleID VariableID QLabellD ModuleID LabelID The following identifiers are recognized as keywords and cannot be used as an identifier case data do else external fcase foreign free if import in infix infixl infixr let module newtype of then type where Note that the symbols as hiding and qualified are not keywords They have only a special meaning in module headers and can be used as ordinary identifiers The following symbols also have a special meaning and cannot be used as an infix operator identifier 4 2 3 Comments Comments begin either with and terminate at the end of the line or with and terminate with a matching i e the delimiters and act as parentheses and can be nested 4 2 4 Numeric and Character Literals Contrasting to the Curry Report KiCS2 adopts Haskell s n
141. ategory Meta ie between and scan String gt Token Divides the given string into the six categories For applications it is important to know whether a given part of code is at the beginning of a line or in the middle The state scanner organizes the code in such a way that every string categorized as Code always starts in the middle of a line plainCode Token String Yields the program code without comments but with the line breaks for small com ments unscan Token String Inverse function of scan i e unscan scan x x unscan is used to yield a program after changing the list of tokens readScan String I0 Token return tokens for given filename testScan String gt I0 test whether unscan scan is identity 271 B Markdown Syntax This document describes the syntax of texts containing markdown elements The markdown syntax is intended to simplify the writing of texts whose source is readable and can be easily formatted e g as part of a web document It is a subset of the original markdown syntax basically only internal links and pictures are missing supported by the Curry library Markdown B 1 Paragraphs and Basic Formatting Paragraphs are separated by at least one line which is empty or does contain only blanks Inside a paragraph one can emphasize text or also strongly emphasize text This is done by wrapping it with one or two _ or characters _
142. aybe String Returns the full path parameter of the front end htmldir FrontendParams Maybe String Returns the htmldir parameter of the front end logfile FrontendParams Maybe String Returns the logfile parameter of the front end specials FrontendParams String Returns the special parameters of the front end 60 callFrontend FrontendTarget String gt 10 In order to make sure that compiler generated files like fcy fint acy are up to date one can call the front end of the Curry compiler with this action If the front end returns with an error an exception is raised callFrontendWithParams FrontendTarget gt FrontendParams String 10 In order to make sure that compiler generated files like fcy fint acy are up to date one can call the front end of the Curry compiler with this action where various parameters can be set If the front end returns with an error an exception is raised A 2 11 Library Either Library with some useful operations for the Either data type Exported functions lefts Either a b gt la Extracts from a list of Either all the Left elements in order rights Either a b gt b Extracts from a list of Either all the Right elements in order isLeft Either a b gt Bool Return True if the given value is a Left value False otherwise isRight Either a b Bool Return True if the given value is a Right value False otherwis
143. be accessible via the current load path if no path specification is given into a text editor which is defined as in the command edit Currently bindings are only printed if the initial expression is not an I O action i e not of type I0 and there are not more than ten free variables in the initial expression 10 show Show the source text of the currently loaded Curry program If the variable showcommand is set in the configuration file kics2rc see Section 2 7 its value is used as a command to show the source text otherwise the command cat is used show m Show the source text of module m which must be accessible via the current load path if no path specification is given source f Show the source code of function f which must be visible in the currently loaded module in a separate window source m f Show the source code of function f defined in module m in a separate window browse Start the CurryBrowser to analyze the currently loaded module together with all its imported modules see Section 7 for more details interface Show the interface of the currently loaded module i e show the names of all imported modules the fixity declarations of all exported operators the exported datatypes declarations and the types of all exported functions 6 interface m Similar to interface but sho
144. blocks lines prefixed by four blanks unordered lists lines prefixed by ordered lists lines prefixed by blanks followed by a digit and a dot quotations lines prefixed by gt and web links of the form lt http gt or link text http If the Markdown syntax should not be used one could run CurryDoc with the parameter nomarkdown The comments can also contain markups in HTML format so that special characters like lt must be quoted e g amp lt However header tags like lt h1 gt should not be used since the struc turing is generated by CurryDoc In addition to Markdown or HTML markups one can also mark references to names of operations or data types in Curry programs which are translated into links The documentation tool recognizes this association from the first identifier in a program line If one wants to add a documentation comment to the definition of a function which is an infix operator the first line of the operator definition should be a type definition otherwise the documentation comment is not recognized 28 inside the generated HTML documentation Such references have to be enclosed in single quotes For instance the text conc refers to the Curry operation conc inside the current module whereas the text Prelude reverse refers to the operation reverse of the module Prelude If one wants to write single quotes without this specific meaning
145. bst FM Int TypeExpr Int Maybe TypeExpr Searches the substitution for a mapping from the given variable index to a term 267 substFunc FM Int TypeExpr AFuncDecl TypeExpr AFuncDecl TypeExpr Applies a substitution to a function substRule FM Int TypeExpr ARule TypeExpr ARule TypeExpr Applies a substitution to a type expression substExpr FM Int TypeExpr AExpr TypeExpr AExpr TypeExpr Applies a substitution to a type expression substSnd FM Int TypeExpr a TypeExpr gt a TypeExpr substBranch FM Int TypeExpr ABranchExpr TypeExpr gt ABranchExpr TypeExpr Applies a substitution to a branch expression substPattern FM Int TypeExpr APattern TypeExpr APattern TypeExpr Applies a substitution to a pattern subst FM Int TypeExpr TypeExpr TypeExpr Looks up a type in a substitution and converts the resulting Term to a TypeExpr Returns a given default value if the lookup fails A 5 19 Library FlatCurry Annotated Typelnference Library to annotate the expressions of a FlatCurry program with type information It can be used by any other Curry program which processes or transforms FlatCurry programs The main operation to use is inferProg Prog gt 10 Either String AProg TypeExpr which annotates a FlatCurry program with type information The type inference works in several steps 1 For each known function and constructor either imported or defined i
146. but use a parallel search strategy to compute and print the values of the initial expression The system chooses an appropriate number of threads according the current number of available processors parallel n Similarly to parallel but use n parallel threads prdfs Set the search mode to evaluate non deterministic expressions to primitive depth first search This is usually the fastest method to print all non deterministic values However it does not support the evaluation of values by interactively requesting them choices n Show the internal choice structure according to the implementation described in 10 resulting from the complete evaluation of the main expression in a tree like structure This mode is only useful for debugging or understanding the implementation of non deterministic evaluations used in KiCS2 If the optional argument n is provided the tree is shown up to depth n supply not available in global installations see Section 1 1 Use implementation 7 as the identi fier supply for choice structures see 10 for a detailed explanation Currently the following values for i are supported integer Use unbounded integers as choice identifiers This implementation is described in 10 ghc Use a more sophisticated implementation of choice identifiers based on the ideas de scribed in 6 provided by the Glasgow Haskell Compiler 12 vn
147. c i WuiSpec j WuiSpec k gt WuiSpec 1 WUI combinator for constructors of arity 11 The first argument is the ternary con structor The further arguments are the WUI specifications for the argument types 194 wCons11JS Maybe JSExp gt JSExp gt la gt b gt c gt d gt e gt fl gt 8g gt h gt i gt j gt k gt 1 gt WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f WuiSpec g gt WuiSpec h WuiSpec i gt WuiSpec j WuiSpec k gt WuiSpec 1 wi2Tuple WuiSpec a WuiSpec b WuiSpec c gt WuiSpec d gt WuiSpec e gt WuiSpec f WuiSpec g gt WuiSpec h gt WuiSpec i WuiSpec j WuiSpec k gt WuiSpec 1 gt WuiSpec a b c d e f g h i j k 1 WUI combinator for tuples of arity 12 wCons12 la lt b gt c gt d gt e gt fl gt g gt h gt i gt j gt k gt 1l gt m gt WuiSpec a WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e WuiSpec f gt WuiSpec g WuiSpec h WuiSpec i gt WuiSpec j WuiSpec k WuiSpec 1 gt WuiSpec m WUI combinator for constructors of arity 12 The first argument is the ternary con structor The further arguments are the WUI specifications for the argument types wCons12JS Maybe JSExp gt JSExp gt la gt b gt c gt d gt e gt gt 8g gt h gt i gt j gt k gt 1 gt m gt WuiSpec a gt WuiSpec b gt WuiSpec c gt WuiSpec d gt
148. cPartCall 237 262 isComment 271 isConsCall 240 265 isConsId 245 isConsPartCall 240 265 isConsPattern 241 266 isControl 51 isDefined 127 139 isDigit 51 isDrive 65 isEmpty 107 131 143 150 154 isEmptyFM 146 isEmptySetRBT 156 isEmptyTable 158 isEOF 89 isExternal 235 260 isExtSeparator 64 isFree 239 264 isFuncCall 240 265 isFuncPartCall 240 265 isFunctionalType 214 isFuncType 233 258 isGround 240 265 isHexDigit 51 isInfix0f 102 isInfixOp 245 254 isIO0ReturnType 214 289 isIOType 214 isJust 104 isLatin1 50 isLeft 61 isLet 239 264 isLetter 271 isListld 245 254 isLit 238 263 isLower 51 isMeta 271 isModuleHead 271 isNothing 104 isOctDigit 51 isOr 239 264 isPathSeparator 64 isPolyType 214 isPosix 135 isPrefix0f 102 isPrelude 215 isqrt 86 isRelative 67 isRight 61 isRuleExternal 236 261 isSearchPathSeparator 64 isSmallComment 271 isSpace 51 isSuffixO0f 102 isTCons 233 258 isText 271 isTupleld 245 254 isTVar 233 258 isTypeSyn 231 256 isUpper 51 isValid 67 isVar 138 238 263 isWindows 135 italic 118 170 joinDrive 65 joinModuleldentifiers 58 joinPath 67 JSBranch 94 jsConsTerm 94 JSExp 92 JSFDecl 94 JSStat 93 Key 95 keyOrder 146 KeyPred 95 keysFM 146 kics2 9 kics2rc 16 lab 150 lab 151 labEdges 152 labNode 151 labNodes 152 labUEdges 153 labUNodes 153 langle 116 larrow 117
149. claration opFixity OpDecl Fixity get fixity of operator declaration opPrecedence OpDecl Int get precedence of operator declaration updOp String String String String gt Fixity gt Fixity gt Int gt Int OpDecl OpDecl update operator declaration updOpName String String gt String String OpDecl gt OpDecl update name of operator declaration updOpFixity Fixity gt Fixity OpDecl OpDecl update fixity of operator declaration updOpPrecedence Int Int OpDecl gt OpDecl update precedence of operator declaration 234 trFunc String String Int gt Visibility TypeExpr Rule gt a gt FuncDecl gt a transform function funcName FuncDecl gt String String get name of function funcArity FuncDecl Int get arity of function funcVisibility FuncDecl Visibility get visibility of function funcType FuncDecl TypeExpr get type of function funcRule FuncDecl Rule get rule of function updFunc String String gt String String Int gt Int gt Visibility gt Visibility TypeExpr gt TypeExpr Rule Rule FuncDecl gt FuncDecl update function updFuncName String String gt String String FuncDecl FuncDecl update name of function updFuncArity Int Int FuncDecl gt FuncDecl update arity of function updFuncVisibility
150. constructor pattern patLiteral APattern a Literal get literal from literal pattern isConsPattern APattern a Bool is pattern a constructor pattern updPattern String String a gt String String a gt Int a gt Int a Literal gt Literal gt APattern a gt APattern a update pattern updPatCons String String String String APattern a APattern a update constructors name of pattern updPatArgs Int a gt Int a gt APattern a gt APattern a update arguments of constructor pattern updPatLiteral Literal Literal gt APattern a gt APattern a update literal of pattern patExpr APattern a gt AExpr a build expression from pattern 266 annRule ARule a gt a annExpr AExpr a gt a Extract the annotation of an annotated expression annPattern APattern a gt a Extract the annotation of an annotated pattern unAnnProg AProg a Prog unAnnFuncDecl AFuncDecl a FuncDecl unAnnRule ARule a gt Rule unAnnExpr AExpr a Expr unAnnPattern APattern a gt Pattern A 5 18 Library FlatCurry Annotated TypeSubst Type substitutions on type annotated AnnotatedFlatCurry Exported types type AFCSubst FM Int TypeExpr The abstract data type for substitutions on TypeExpr Exported functions showAFCSubst FM Int TypeExpr String emptyAFCSubst FM Int TypeExpr The empty substitution lookupAFCSu
151. contents getContents 10 String Reads the complete contents from the standard input stream until EOF hPutChar Handle gt Char gt I0 Puts a character to an output handle hPutStr Handle gt String gt 10 Puts a string to an output handle hPutStrLn Handle gt String gt 10 Puts a string with a newline to an output handle hPrint Handle gt a gt 10 O Converts a term into a string and puts it to an output handle hIsReadable Handle gt 10 Bool Is the handle readable hIsWritable Handle gt 10 Bool Is the handle writable hIsTerminalDevice Handle 10 Bool Is the handle connected to a terminal A 2 23 Library IOExts Library with some useful extensions to the IO monad 90 Exported types data IDRef Mutable variables containing values of some type The values are not evaluated when they are assigned to an IORef Exported constructors Exported functions execCmd String IO Handle Handle Handle Executes a command with a new default shell process The standard I O streams of the new process stdin stdout stderr are returned as handles so that they can be explicitly manipulated They should be closed with I0 hClose since they are not closed automatically when the process terminates evalCmd String gt String String gt 10 Int String String Executes a command with the given arguments as a new default shell process and provides the input via the p
152. cription about the use of this mode 16 3 Extensions KiCS2 supports some extensions in Curry programs that are not yet part of the definition of Curry These extensions are described below 3 1 Narrowing on Int Literals In addition to narrowing on algebraic data types KiCS2 also implements narrowing on values of the primitive type Int For example the goal x 3 where x free is evaluated to the solutions Prelude gt x 3 where x free x _x2 False x 0 False x 1 False x 2 _x3 False x 3 True x 4 _x4 1 False x 4 _x4 3 False Note that the free variables occuring in the binding are restricted to positive numbers greater than 0 the output has been indented to increase readability This feature is implemented by an internal binary representation of integer numbers If necessary this representation can be exposed to the user by setting the flag BinaryInt during installation make kernel install RUNTIMEFLAGS BinarylInt In an experimental local installation the flag can also be set in the interpreter set ghc DBinaryInt The example above will then be evaluated without indentation to Prelude gt x 3 where x free x Neg _x2 False x 0 False x 1 False x Pos 0 _x3 False x 3 True x Pos I 0 _x4 False x Pos I I _x4 False In this output values without free variables are presented as before For values containing
153. ction arity type CVarIName Int String Data types for representing object variables Object variables occurring in expressions are represented by Var i where i is a variable index data CVisibility Data type to specify the visibility of various entities Exported constructors e Public CVisibility e Private CVisibility 206 data CurryProg Data type for representing a Curry module in the intermediate form A value of this data type has the form CProg modname imports typedecls functions opdecls where modname name of this module imports list of modules names that are im ported typedecls Type declarations functions Function declarations opdecls Opera tor precedence declarations Exported constructors e CurryProg String gt String gt CTypeDec1 gt CFuncDec1 COpDec1 gt CurryProg data CTypeDecl Data type for representing definitions of algebraic data types and type synonyms A data type definition of the form data t x1 xn c t1 tkc is represented by the Curry term CType t v i1 in CCons c kc v t1 tkc where each ij is the index of the type variable xj Note the type variable indices are unique inside each type declaration and are usually numbered from 0 Thus a data type declaration consists of the name of the data type a list of type parameters and a list of constructor declarations Exported constructors e CType String S
154. ction over the graph 152 nmap a gt b Graph a c gt Graph b c Map a function over the Node labels in a graph emap a b Graph c a gt Graph c b Map a function over the Edge labels in a graph labUEdges a b gt a b 0 add label to list of edges node node labUNodes a gt a 0 add label to list of nodes showGraph Graph a b gt String Represent Graph as String A 3 5 Library Random Library for pseudo random number generation in Curry This library provides operations for generating pseudo random number sequences For any given seed the sequences generated by the operations in this module should be identical to the sequences generated by the java util Random package The algorithm is taken from http en wikipedia org wiki Random_number_generation There is an assumption that all operations are implicitly executed mod 2732 unsigned 32 bit integers GHC computes between 2729 and 2729 1 thus the sequence is NOT as random as one would like w lt choose initializer gt must not be zero lt choose initializer gt must not be zero uint get_random m_z 36969 m_z amp 65535 m_z gt gt 16 m_w 18000 m_w amp 65535 m_w gt gt 16 return m_z lt lt 16 mw 32 bit result Exported functions nextInt Int gt Int Returns a sequence of pseudorandom integer values nextIntRange Int gt Int gt Int Re
155. d argument terms args A 3 13 Library Rewriting Substitution Library for representation of substitutions on first order terms Exported types type Subst a FM Int Term a The abstract data type for substitutions Exported functions showSubst FM Int Term a gt String Pretty string representation of a substitution emptySubst FM Int Term a The empty substitution extendSubst FM Int Term a gt Int Term a gt FM Int Term a Extend the substitution with the given mapping lookupSubst FM Int Term a Int Maybe Term a Searches the substitution for a mapping from the given variable index to a term applySubst FM Int Term a Term a gt Term a Applies a substitution to a single term 161 A 3 14 Library Rewriting Unification Library for unification on first order terms This library implements a unification algorithm using reference tables Exported functions unify Term a Term a gt Either UnificationError a FM Int Term a y Unifies the given equations A 3 15 Library Rewriting UnificationSpec Library for specifying the unification on first order terms This library implements a general unification algorithm Because the algorithm is easy to under stand but rather slow it serves as a specification for more elaborate implementations Exported types data UnificationError The data type for the different kinds of errors that can occur during unification
156. d creates the directory DOC_Example if it does not exist and puts all HTML documentation files for the main program module Example and all its imported modules in this directory together with a main index file index html If one prefers another directory for the documentation files one can also execute the command currydoc docdir Example 29 where docdir is the directory for the documentation files In order to generate the common documentation for large collections of Curry modules e g the libraries contained in the KiCS2 distribution one can call currydoc with the following options currydoc noindexhtml docdir Mod This command generates the documentation for module Mod in the directory docdir without the index pages i e main index page and index pages for all functions and constructors defined in Mod and its imported modules currydoc onlyindexhtml docdir Modi Mod2 Modn This command generates only the index pages i e a main index page and index pages for all functions and constructors defined in the modules Mod1 M2 Modn and their imported modules in the directory docdir 30 7 CurryBrowser A Tool for Analyzing and Browsing Curry Pro grams CurryBrowser is a tool to browse through the modules and functions of a Curry application show them in various formats and analyze their properties Moreover it is constructed in a way so that new analyzers can be easily connected to CurryBrowser A detailed descriptio
157. d r The documents are rendered horizontally if that fits the page Otherwise they are aligned vertically All seperators are put in front of the elements fillEncloseSepSpaced Doc Doc gt Doc gt Doc gt Doc 113 The document fillEncloseSepSpaced 1 r s xs concatenates the documents xs seperated by s and encloses the resulting document by 1 and r In addition after each occurrence of s after 1 and before r a space is inserted The documents are rendered horizontally if that fits the page Otherwise they are aligned vertically All seperators are put in front of the elements list Doc Doc The document list xs comma seperates the documents xs and encloses them in square brackets The documents are rendered horizontally if that fits the page Other wise they are aligned vertically All comma seperators are put in front of the elements listSpaced Doc gt Doc Spaced version of list set Doc Doc The document set xs comma seperates the documents xs and encloses them in braces The documents are rendered horizontally if that fits the page Otherwise they are aligned vertically All comma seperators are put in front of the elements setSpaced Doc Doc Spaced version of set tupled Doc gt Doc The document tupled xs comma seperates the documents xs and encloses them in parenthesis The documents are rendered horizontally if that fits the page Otherwise they are a
158. declaration typeParams TypeDecl gt Int get type parameters of type declaration typeConsDecls TypeDecl ConsDec1 get constructor declarations from type declaration typeSyn TypeDecl TypeExpr get synonym of type declaration isTypeSyn TypeDecl Bool is type declaration a type synonym updType String String gt String String gt Visibility Visibility gt Int gt Int gt ConsDec1 gt ConsDecl TypeExpr gt TypeExpr gt TypeDecl TypeDecl update type declaration updTypeName String String gt String String TypeDecl TypeDecl 256 update name of type declaration updTypeVisibility Visibility Visibility gt TypeDecl TypeDecl update visibility of type declaration updTypeParams Int Int gt TypeDecl gt TypeDecl update type parameters of type declaration updTypeConsDecls ConsDecl gt ConsDecl TypeDecl TypeDecl update constructor declarations of type declaration updTypeSynonym TypeExpr TypeExpr gt TypeDecl gt TypeDecl update synonym of type declaration updQNamesInType String String String String TypeDecl gt TypeDecl update all qualified names in type declaration trCons String String gt Int gt Visibility TypeExpr gt a gt ConsDecl gt a transform constructor declaration consName ConsDecl String String
159. ds let where do or of In the subsequent context free syntax these lists are enclosed with curly brackets and the single entities are separated by semicolons Instead of using the curly brackets and semicolons of the context free syntax a Curry programmer must specify these lists by indentation the indentation of a list of syntactic entities after let where do or of is the indentation of the next symbol following the let where do of Any item of this list start with the same indentation as the list Lines with only whitespaces or an indentation greater than the indentation of the list continue the item in its previous line Lines with an indentation less than the indentation of the list terminate the entire list Moreover a list started by let is terminated by the keyword in Thus the sentence fx hxwhere gy yti hz gz 2 which is valid w r t the context free syntax is written with the layout rules as fx hx where g y y 1 hz g2z 2 or also as f hx where oe Mae z g z 2 mp og gt To avoid an indentation of top level declarations the keyword module and the end of file token are assumed to start in column 0 In order to determine the exact column number we assume a fixed width font with tab stops at each 8th column 22 4 4 Context Free Grammar Module module ModuleID Exports where Block Block ModuleID see lexicon Exports Export Exportn Export QFuncti
160. e Exported types data Socket Abstract type for named sockets Exported constructors Exported functions listenOn String 10 Socket Creates a server side socket with a symbolic name socketAccept Socket gt IO String Handle Returns a connection of a client to a socket The connection is returned as a pair consisting of a string identifying the client the format of this string is implementation dependent and a handle to a stream communication with the client The handle is both readable and writable waitForSocketAccept Socket gt Int gt I0 Maybe String Handle Waits until a connection of a client to a socket is available If no connection is available within the time limit it returns Nothing otherwise the connection is returned as a pair consisting of a string identifying the client the format of this string is implementation dependent and a handle to a stream communication with the client sClose Socket gt IO Closes a server socket socketName Socket String Returns a the symbolic name of a named socket connectToSocketRepeat Int gt IO a gt Int gt String 10 Maybe Handle Waits for connection to a Unix socket with a symbolic name In contrast to connectToSocket this action waits until the socket has been registered with its sym bolic name 105 connectToSocketWait String IO Handle Waits for connection to a Unix socket with a symbolic name and retu
161. e fromLeft Either ab gt a Extract the value from a Left constructor fromRight Either a b gt b Extract the value from a Right constructor partitionEithers Either a b gt a b Partitions a list of Either into two lists All the Left elements are extracted in order to the first component of the output Similarly the Right elements are extracted to the second component of the output A 2 12 Library ErrorState A combination of Error and state monad like ErrorT State in Haskell 61 Exported types type ES a b c b Either a c b Error state monad Exported functions evalES a gt Either b c a gt a gt Either b c Evaluate an ES monad returnES a gt b gt Either c a b Lift a value into the ES monad failES a gt b gt Either a c b Failing computation in the ES monad gt a gt Either b c a gt c a gt Either b d a gt a gt Either b d a Bind of the ES monad gt a gt Either b c a gt a gt Either b d a gt a gt Either b d a Sequence operator of the ES monad lt gt a gt b gt c gt Either d a c gt c gt Either d b c Apply a pure function onto a monadic value lt gt a gt Either b c gt d a gt a gt Either b c a gt a gt Either b d a Apply a function yielded by a monadic action to a monadic value gets a Either b a a Retrieve the current state puts a gt
162. e a Queue a Matches the end of a queue matchLast q is equivalent to if isEmpty q then Nothing else Just deqLast q deqInit q but more efficient listToDeq a Queue a Transforms a list to a double ended queue deqToList Queue a gt la Transforms a double ended queue to a list 143 A 3 3 Library FiniteMap A finite map is an efficient purely functional data structure to store a mapping from keys to values In order to store the mapping efficiently an irreflexive order predicate has to be given i e the order predicate le should not satisfy le x x for some key x Example To store a mapping from Int gt String the finite map needs a Boolean predicate like lt This version was ported from a corresponding Haskell library Exported types data FM Exported constructors Exported functions emptyFM a gt a Bool gt FM ab The empty finite map unitFM a gt a gt Bool gt a gt b gt FMab Construct a finite map with only a single element listToFM a gt a gt Bool gt a b gt FMab Builts a finite map from given list of tuples key element For multiple occurences of key the last corresponding element of the list is taken addToFM FM a b gt a gt b gt FMab Throws away any previous binding and stores the new one given addListToFM FM a b gt a b gt FMa b Throws away any previous bindings and stores the new ones given The items are added starti
163. e with suffix fey lookupFlatCurryFileInLoadPath String IO Maybe String Returns the name of the FlatCurry file of a module in the load path if this file exists getFlatCurryFilelnLoadPath String 10 String Returns the name of the FlatCurry file of a module in the load path if this file exists A 5 8 Library FlatCurry Goodies This library provides selector functions test and update operations as well as some useful auxiliary functions for FlatCurry data terms Most of the provided functions are based on general trans formation functions that replace constructors with user defined functions For recursive datatypes the transformations are defined inductively over the term structure This is quite usual for trans formations on FlatCurry terms so the provided functions can be used to implement specific trans formations without having to explicitly state the recursion Essentially the tedious part of such transformations descend in fairly complex term structures is abstracted away which hopefully makes the code more clear and brief Exported types type Update ab b gt b gt a gt a 229 Exported functions trProg String String TypeDec1 gt FuncDec1 gt OpDec1 gt a gt Prog gt a transform program progName Prog gt String get name from program progImports Prog gt String get imports from program progTypes Prog gt TypeDecl1
164. e and creates an empty XML element that represents the given value The created element may be used in repetitions eOpt String XmlConv a b c XmlConv Repeatable Elem Maybe c Creates an XML converter that represents an element containing optional XML data The created element may be used in repetitions eRep String XmlConv Repeatable a b XmlConv Repeatable Elem b Creates an XML converter that represents an element containing repeated XML data The created element may be used in repetitions seq1 a gt b gt XmlConv c d a gt XmlConv c NoElem b Creates an XML converter representing a sequence of arbitrary XML data The se quence must not be used in repetitions and does not represent an XML element repSeq1 a gt b XmlConv Repeatable c a XmlConv NotRepeatable NoElem Creates an XML converter that represents a repetition of a sequence of repeatable XML data The repetition may be used in other repetitions but does not represent an XML element This combinator is provided because converters for repeatable sequences cannot be constructed by the seq combinators eSeqi String gt a gt b gt XmlConv c d a gt XmlConv Repeatable Elem b Creates an XML converter for compound values represented as an XML element with children that correspond to the values components The element can be used in repe titions 202 b eRepSeql String gt a gt b gt XmlConv Rep
165. e are also some specific options that can be used when invoking KiCS2 noreadline if used this must be the first option Do not use input line editing see Sec tion 2 6 Dname val these options must come before any KiCS2 command Overwrite values defined in the configuration file kics2rc see Section 2 7 where name is a property defined in the configuration file and val its new value 2 2 Commands of KiCS2 The most important commands of KiCS2 are it is sufficient to type a unique prefix of a e command if it is unique e g one can type r instead of reload help Show a list of all available commands load prog Compile and load the program stored in prog curry together with all its imported modules reload Recompile all currently loaded modules add mi1 Mn Add modules mi my to the set of currently loaded modules so that their exported entities are available in the top level environment expr Evaluate the expression expr to normal form and show the computed results In the default mode all results of non deterministic computations are printed One can also print first one result and the next result only if the user requests it This behavior can be set by the option interactive see below Free variables in initial expressions must be declared as in Curry programs In order to see the resul
166. e document bgCyan d displays document d with cyan background color bgWhite Doc Doc The document bgWhite d displays document d with white background color pretty Int Doc String pretty w d pretty prints document d with a page width of w characters A 2 31 Library Profile Preliminary library to support profiling Exported types data ProcessInfo The data type for representing information about the state of a Curry process Exported constructors e RunTime ProcessInfo RunTime the run time in milliseconds e ElapsedTime ProcessInfo ElapsedTime the elapsed time in milliseconds e Memory ProcessInfo Memory the total memory in bytes 120 e Code ProcessInfo Code the size of the code area in bytes e Stack ProcessInfo Stack the size of the local stack for recursive functions in bytes e Heap ProcessInfo Heap the size of the heap to store term structures in bytes e Choices ProcessInfo Choices the size of the choicepoint stack e GarbageCollections ProcessInfo GarbageCollections the number of garbage collections performed Exported functions getProcessInfos I0 ProcessInfo Int Returns various informations about the current state of the Curry process Note that the returned values are implementation dependent so that one should interpret them with care Note for kics2 users Since GHC version 7 x one has to se
167. e non determinism caused by evaluating arguments in a set Thus setn f al an returns the set of all values of f b1 bn where b1 bn are values of the arguments a1 an i e the arguments are evaluated outside this capsule so that the non determinism caused by evaluating these arguments is not captured in this capsule but yields several results for setn Similarly logical variables occuring in a1 an are not bound inside this capsule The set of values returned by a set function is represented by an abstract type Values on which several operations are defined in this module Actually it is a multiset of values i e duplicates are not removed The handling of failures and nested occurrences of set functions is not specified in the previous paper Thus a detailed description of the semantics of set functions as implemented in this library can be found in the paper J Christiansen M Hanus F Reck D Seidel A Semantics for Weakly Encapsulated Search in Functional Logic Programs Proc 15th International Conference on Principles and Practice of Declarative Programming PPDP 13 pp 49 60 ACM Press 2013 129 Exported types data Values Abstract type representing multisets of values Exported constructors Exported functions setO a gt Values a Combinator to transform a 0 ary function into a corresponding set function setOWith SearchTree a gt ValueSequence a gt a gt Valu
168. ePropertyFile 124 updateRBT 158 updateValue 83 updateXmlFile 199 updBranch 240 266 updBranches 239 265 updBranchExpr 241 266 updBranchPattern 240 266 updCases 239 265 updCombs 239 264 updCons 232 257 updConsArgs 233 258 updConsArity 232 257 updConsName 232 257 updConsVisibility 233 258 updFM 145 updFrees 239 264 updFunc 235 260 updFuncArgs 236 261 updFuncArity 235 260 updFuncBody 236 261 updFuncName 235 260 updFuncRule 235 260 updFuncType 235 260 updFuncTypes 234 259 updFuncVisibility 235 260 updLets 239 264 updLiterals 239 264 updOp 234 259 updOpFixity 234 259 updOpName 234 259 updOpPrecedence 234 259 updOrs 239 264 updPatArgs 241 266 updPatCons 241 266 updPatLiteral 241 266 updPattern 241 266 299 updProg 230 255 updProgExps 231 256 updProgFuncs 230 255 updProgImports 230 255 updProgName 230 255 updProgOps 230 255 updProgTypes 230 255 updQNames 240 265 updQNamesInConsDecl 233 258 updQNamesInFunc 236 261 updQNamesInProg 231 256 updQNamesInRule 237 262 updQNamesInType 232 257 updQNamesInTypeExpr 234 259 updRule 236 261 updRuleArgs 236 262 updRuleBody 237 262 updRuleExtDecl 237 262 updTCons 233 258 updTVars 233 258 updType 231 256 updTypeConsDecls 232 257 updTypeds 240 265 updTypeName 231 256 updTypeParams 232 257 updTypeSynonym 232 257 updTypeVisibility 232 257 updVars 239 264 urlencod
169. eatable c a XmlConv Repeatable Elem b Creates an XML converter for repetitions of sequences represented as an XML element that can be used in repetitions seg2 a gt b 4 c gt XmlConv d e a gt XmlConv f g b gt XmlConv NotRepeatable NoElem c Creates an XML converter representing a sequence of arbitrary XML data The se quence must not be used in repetitions and does not represent an XML element repSeg2 a b gt c XmlConv Repeatable d a XmlConv Repeatable e b gt Xm1Conv NotRepeatable NoElem c Creates an XML converter that represents a repetition of a sequence of repeatable XML data The repetition may be used in other repetitions and does not represent an XML element This combinator is provided because converters for repeatable sequences cannot be constructed by the seq combinators eSeq2 String gt a gt b gt c gt XmlConv d e a gt XmlConv f g b gt XmlConv Repeatable Elem c Creates an XML converter for compound values represented as an XML element with children that correspond to the values components The element can be used in repe titions eRepSeq2 String gt a gt b gt c XmlConv Repeatable d a gt XmlConv Repeatable e b gt XmlConv Repeatable Elem c Creates an XML converter for repetitions of sequences represented as an XML element that can be used in repetitions seq3 a gt b gt c gt d gt XmlConv e f a gt XmlConv g
170. ec h WuiSpec i WuiSpec j wi0Tuple WuiSpec a WuiSpec b WuiSpec c WuiSpec d WuiSpec e gt WuiSpec f gt WuiSpec g gt WuiSpec h WuiSpec i WuiSpec j gt WuiSpec a b c d e f g h i j WUI combinator for tuples of arity 10 wConsi0 la lt b gt c gt d gt e gt f gt g gt h gt iw gt j gt k gt WuiSpec a gt WuiSpec b gt WuiSpec c WuiSpec d gt WuiSpec e gt WuiSpec f WuiSpec g gt WuiSpec h gt WuiSpec i WuiSpec j WuiSpec k WUI combinator for constructors of arity 10 The first argument is the ternary con structor The further arguments are the WUI specifications for the argument types wCons10JS Maybe JSExp gt JSExp gt la gt b gt c gt d gt e gt fl gt 8g gt h gt i gt j gt k WuiSpec a WuiSpec b WuiSpec c WuiSpec d WuiSpec e gt WuiSpec f gt WuiSpec g WuiSpec h WuiSpec i WuiSpec j WuiSpec k wiiTuple WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d gt WuiSpec e gt WuiSpec f WuiSpec g gt WuiSpec h gt WuiSpec i WuiSpec j WuiSpec k gt WuiSpec a b c d e f g h i j k WUI combinator for tuples of arity 11 wCons11 la gt b gt c gt d gt e gt f gt g gt h gt i gt j gt k gt 1 gt WuiSpec a gt WuiSpec b gt WuiSpec c WuiSpec d gt WuiSpec e WuiSpec f WuiSpec g gt WuiSpec h gt WuiSpe
171. ection 2 2 277 D External Operations Currently KiCS2 has no general interface to external operations i e operations whose semantics is not defined by program rules in a Curry program but by some code written in another programming language Thus if an external operation should be added to the system this operation must be declared as external in the Curry source code and an implementation for this external operation must be provided for the run time system An external operation is defined as follows in the Curry source code 1 Add a type declaration for the external operation somewhere in a module defining this oper ation usually the prelude or some system module 2 For external operations it is not allowed to define any rule since their semantics is determined by an external implementation Instead of the defining rules you have to write f external below the type declaration for the external operation f Furthermore an implementation of the external operation must be provided in the target language of the KiCS2 compiler i e in Haskell and inserted in the compiled code In order to simplify this task KiCS2 follows some code conventions that are described in the following Assume you want to implement your own concatenation for strings in a module String The name and type of this string concatenation should be sconc String String String Since the primitive Haskell implementation of this operation does
172. ed not reloaded as a main module For instance if a module starts with the lines KiCS2_OPTION ids KiCS2_OPTION ghci KiCS2_OPTION v2 module M where then the load command load M will also set the options for iterative deepening using ghci and verbosity level 2 15 2 5 Using KiCS2 in Batch Mode Although KiCS2 is primarily designed as an interactive system it can also be used to process data in batch mode For example consider a Curry program say myprocessor that reads argument strings from the command line and processes them Suppose the entry point is a function called just_doit that takes no arguments Such a processor can be invoked from the shell as follows gt kics2 set args stringi string2 load myprocessor curry eval just_doit quit The quit directive in necessary to avoid KiCS2 going into interactive mode after the excution of the expression being evaluated The actual run time arguments string1 string2 are defined by setting the option args see above Here is an example to use KiCS2 in this way gt kics2 set args Hello World add System eval getArgs gt gt putStrLn unwords quit Hello World gt 2 6 Command Line Editing In order to have support for line editing or history functionality in the command line of KiCS2 as often supported by the readline library you should have the Unix command rlwrap installed on your local machine If rlwrap is installed
173. ed black tree augmented with the order predicates isEmpty RedBlackTree a Bool Test on emptyness newTreeLike RedBlackTree a gt RedBlackTree a Creates a new empty red black tree from with the same ordering as a give one lookup a RedBlackTree a Maybe a Returns an element if it is contained in a red black tree update a RedBlackTree a gt RedBlackTree a 154 Updates inserts an element into a RedBlackTree delete a RedBlackTree a gt RedBlackTree a Deletes entry from red black tree tree2list RedBlackTree a gt a Transforms a red black tree into an ordered list of its elements sort a a gt Bool gt a gt al Generic sort based on insertion into red black trees The first argument is the order for the elements setInsertEquivalence a gt a Bool gt RedBlackTree a RedBlackTree a For compatibility with old version only A 3 7 Library SCC Computing strongly connected components Copyright c 2000 2003 Wolfgang Lux See LICENSE for the full license The function scc computes the strongly connected components of a list of entities in two steps First the list is topologically sorted downwards using the defines relation Then the resulting list is sorted upwards using the uses relation and partitioned into the connected components Both relations are computed within this module using the bound and free names of each declaration In orde
174. ed constructors e AProg String gt String TypeDecl AFuncDecl a gt OpDecl gt AProg a data AFuncDecl Annotated function declaration Exported constructors e AFunc String String Int gt Visibility TypeExpr ARule a gt AFuncDecl a data ARule Annotated function rule Exported constructors e ARule a gt Int a AExpr a gt ARule a e AExternal a gt String ARule a data AExpr Annotated expression Exported constructors e AVar a gt Int AExpr a e ALit a gt Literal gt AExpr a 250 e AComb a gt CombType gt String String a gt AExpr a AExpr a e ALet a gt Int a AExpr a gt AExpr a gt AExpr a e AFree a gt Int a gt AExpr a gt AExpr a e AOr a gt AExpr a gt AExpr a AExpr a e ACase a gt CaseType gt AExpr a gt ABranchExpr a AExpr a e ATyped a gt AExpr a gt TypeExpr gt AExpr a data ABranchExpr Annotated case branch Exported constructors e ABranch APattern a gt AExpr a ABranchExpr a data APattern Annotated pattern Exported constructors e APattern a gt String String a gt Int a gt APattern a e ALPattern a gt Literal APattern a A 5 16 Library FlatCurry Annotated Pretty This library provides pretty printers for AnnotatedFlatCurry modules and all substructures e g expressions Note that a
175. ed2string 174 usageInfo 72 v 13 validDate 137 value0f 131 Values 130 values2list 133 ValueSequence 141 variables singleton 7 varld 139 Varldx 160 VarIndex 222 varNr 237 262 varsOfExp 215 varsOfFDecl 215 varsOfLDecl 215 varsOfPat 215 varsOfRhs 215 varsOfRule 215 varsD Stat 215 vcat 112 verbatim 171 verbosity 13 version 211 Visibility 222 vsep 111 vsepBlank 111 vsToList 141 w10Tuple 186 194 wiiTuple 186 194 wi2Tuple 186 195 w4Tuple 185 192 w5Tuple 185 192 w6Tuple 185 193 w7Tuple 185 193 w8Tuple 185 193 w9Tuple 186 194 waitForSocketAccept 105 134 wCheckBool 184 191 wCheckMaybe 187 196 wCons10 186 194 wCons10JS 194 wCons11 186 194 wCons11JS 195 wCons12 187 195 wCons12JS 195 wCons2 184 191 wCons2JS 192 wCons3 185 192 wCons3JS 192 wCons4 185 192 wCons4JS 192 wConsd 185 192 wCons5JS 192 wCons6 185 193 wCons6JS 193 wCons7 185 193 300 wCons7JS 193 wCons8 186 193 wCons8JS 193 wCons9 186 194 wCons9JS 194 wConstant 183 190 wEither 187 196 where 17 wHidden 183 190 white 119 wHList 187 195 Widget 74 WidgetRef 80 wint 183 190 withCondition 183 189 withConditionJS 190 withConditionJSName 190 withError 183 189 withRendering 182 189 wJoinTuple 187 191 wList 187 195 wListWithHeadings 187 195 wMatrix 187 195 wMaybe 187 195 wMultiCheckSelect 184 191 wPair 184 191 wRadioBool 1
176. emphasize_ emphasize __strong__ strong Furthermore one can also mark program code text by backtick quotes The function fib computes Fibonacci numbers Web links can be put in angle brackets like in the link http www google com lt http www google com gt Currently only links starting with http are recognized so that one can also use HTML markup If one wants to put a link under a text one can put the text in square brackets directly followed by the link in round brackets as in Google Google http www google com If one wants to put a character that has a specific meaning in the syntax of Markdown like or _ in the output document it should be escaped with a backslash i e a backslash followed by a special character in the source text is translated into the given character this also holds for program code see below For instance the input text _word _ produces the output _word_ The following backslash escapes are recognized backslash i backtick asterisk _ underscore curly braces square brackets 272 O parentheses hash symbol plus symbol minus symbol dash dot blank exclamation mark B 2 Lists and Block Formatting An unordered list i e without numbering is introduced by putting a star in front of the list elements where the star can be preceded by blanks The individual list elements must contain the same indentation as in First
177. er platforms on which a Haskell implementation Glasgow Haskell Compiler and Cabal exists like in many Linux distributions Sun Solaris or Mac OS X systems Installation instructions for KiCS2 can be found in the file INSTALL txt stored in the KiCS2 installation directory Note that there are two possibilities to install KiCS2 Global installation KiCS2 is installed in some global system directory where users have no write permission In this case some options for experimenting with KiCS2 like supply or ghc see below are not available since they require the recompilation of parts of the installed system Local installation KiCS2 is installed in some local user directory where the user has write per mission and the option GLOBALINSTALL in the Makefile of the KiCS2 installation is set as follows GLOBALINSTALL no In this case all options of KiCS2 are available Furthermore KiCS2 can be installed with experimental support for profiling of executables To use profiling two requirements have to be met e The libraries that are shipped with the GHC that is used by KiCS2 have to be installed with profiling enabled This is the default for the system libraries contained in the GHC release but may not be the case for additional libraries e The Makefile of KiCS2 contains an option PROFILING which has to be set to yes to enable profiling support You may either change the Makefile to PROFILING yes or specify this setting while st
178. erm of type ERD w r t the type definition given in module kics2home currytoo1s erd2curry ERD curry and store it in some file e g myerd term This description can be compiled into a Curry program by the command erd2curry t myerd term The directory kics2home currytools erd2curry contains two examples for such ERD term files Blog erdterm This is a simple ERD model for a blog with entries comments and tags Uni erdterm This is an ERD model for university lectures as presented in the paper 8 There is also the possibility to visualize an ERD term as a graph with the graph visualization program dotty for this purpose it might be necessary to adapt the definition of dotviewcommand in your kics2rc file see Section 2 7 according to your local environment The visualization can be performed by the command erd2curry v myerd term 42 12 Spicey An ER based Web Framework Spicey is a framework to support the implementation of web based systems in Curry Spicey generates an initial implementation from an entity relationship ER description of the underlying data The generated implementation contains operations to create and manipulate entities of the data model supports authentication authorization session handling and the composition of individual operations to user processes Furthermore the implementation ensures the consistency of the database w r t the data dependencies specified in the ER model i e updates
179. ertical and horizontal scrollbars The argument contains the configuration options for the text edit widget EntryScroll ConfItem Widget An entry widget with a horizontal scrollbar The argument contains the configuration options for the entry widget getOpenFile 10 String Pops up a GUI for selecting an existing file The file with its full path name will be 9999 returned or if the user cancels the selection getOpenFileWithTypes String String 10 String Pops up a GUI for selecting an existing file The parameter is a list of pairs of file types that could be selected A file type pair consists of a name and an extension for that 9999 file type The file with its full path name will be returned or if the user cancels the selection 85 getSaveFile 10 String Pops up a GUI for choosing a file to save some data If the user chooses an existing file she he will asked to confirm to overwrite it The file with its full path name will 9999 be returned or if the user cancels the selection getSaveFileWithTypes String String 10 String Pops up a GUI for choosing a file to save some data The parameter is a list of pairs of file types that could be selected A file type pair consists of a name and an extension for that file type If the user chooses an existing file she he will asked to confirm to 9999 overwrite it The file with its full path name will be retu
180. es For instance textOf XText xy XElem a XText bc xy bc textOfXml XmlExp String Included for backward compatibility better use textOf xtxt String XmlExp Basic text maybe containing special XML chars xml String XmlExp gt XmlExp XML element without attributes writeXmlFile String gt XmlExp gt 10 Writes a file with a given XML document writeXmlFileWithParams String XmlDocParams XmlExp gt I0 Writes a file with a given XML document and XML parameters showXmlDoc XmlExp String Show an XML document in indented format as a string showXmlDocWithParams XmlDocParams gt XmlExp String readXmlFile String IO XmlExp Reads a file with an XML document and returns the corresponding XML expression readUnsafeXmlFile String IO Maybe XmlExp Tries to read a file with an XML document and returns the corresponding XML expres sion if possible If file or parse errors occur Nothing is returned readFileWithXmlDocs String gt I0 XmlExp 198 Reads a file with an arbitrary sequence of XML documents and returns the list of corresponding XML expressions parseXmlString String gt XmlExp Transforms an XML string into a list of XML expressions If the XML string is a well structured document the list of XML expressions should contain exactly one element updateXmlFile XmlExp gt XmlExp String gt
181. es w6Tuple WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f gt WuiSpec a b c d e f WUI combinator for tuples of arity 6 wCons6 la gt b gt c gt d gt e gt f gt g WuiSpec a WuiSpec b gt WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f WuiSpec g WUI combinator for constructors of arity 6 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types w Tuple WuiSpec a WuiSpec b gt WuiSpec c gt WuiSpec d gt WuiSpec e gt WuiSpec f WuiSpec g gt WuiSpec a b c d e f g WUI combinator for tuples of arity 7 wCons7 a gt b gt c gt d gt e gt f gt g h gt WuiSpec a gt WuiSpec b gt WuiSpec c WuiSpec d WuiSpec e WuiSpec f WuiSpec g WuiSpec h WUI combinator for constructors of arity 7 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types w8Tuple WuiSpec a WuiSpec b WuiSpec c WuiSpec d WuiSpec e gt WuiSpec f gt WuiSpec g gt WuiSpec h WuiSpec a b c d e f g h 185 WUI combinator for tuples of arity 8 wCons8 a gt b gt c gt d gt e gt f gt g gt h gt i gt WuiSpec a gt WuiSpec b gt WuiSpec c WuiSpec d gt WuiSpec e gt WuiSpec f WuiSpec g WuiSpec h gt
182. es by prepending the word import to the module name ppCOpDecl Options gt COpDecl Doc pretty print operator precedence declarations ppCTypeDecl Options CTypeDecl Doc 220 pretty print type declarations like data type or newtype ppCFuncDecl Options CFuncDecl Doc pretty print a function declaration ppCFuncDeclWithoutSig Options CFuncDecl Doc pretty print a function declaration without signature ppCFuncSignature Options gt String String gt CTypeExpr Doc pretty print a function signature according to given options ppCTypeExpr Options CTypeExpr Doc pretty print a type expression ppCPattern Options CPattern Doc pretty print a pattern expression ppCLiteral Options gt CLiteral Doc pretty print given literal Int Float ppCExpr Options CExpr Doc pretty print an expression ppCStatement Options CStatement Doc ppQFunc Options gt String String Doc pretty print a function name or constructor name qualified according to given options Use ppQType or ppType for pretty printing type names ppFunc String String gt Doc pretty print a function name or constructor name non qualified Use ppQType or ppType for pretty printing type names ppQType Options gt String String Doc pretty print a type QName qualified according to given options ppType S
183. es a Combinator to transform a 0 ary function into a corresponding set function that uses a given strategy to compute its values set1 a gt b gt a gt Values b Combinator to transform a unary function into a corresponding set function setiWith SearchTree a gt ValueSequence a gt b gt a gt b Values a Combinator to transform a unary function into a corresponding set function that uses a given strategy to compute its values set2 la b c a b Values c Combinator to transform a binary function into a corresponding set function set2With SearchTree a gt ValueSequence a gt b gt c gt a gt b 4 c gt Values a Combinator to transform a binary function into a corresponding set function that uses a given strategy to compute its values set3 a gt b gt c gt d gt a gt b gt c gt Values d Combinator to transform a function of arity 3 into a corresponding set function set3With SearchTree a gt ValueSequence a gt b gt c gt da gt b gt c gt d gt Values a Combinator to transform a function of arity 3 into a corresponding set function that uses a given strategy to compute its values set4 la b gt c gt d e a b c d Values e Combinator to transform a function of arity 4 into a corresponding set function set4With SearchTree a gt ValueSequence a gt b gt c gt
184. es only a single element from a multi set setRBT2list RedBlackTree a gt la Transforms a red black tree set into an ordered list of its elements unionRBT RedBlackTree a RedBlackTree a gt RedBlackTree a Computes the union of two red black tree sets This is done by inserting all elements of the first set into the second set intersectRBT RedBlackTree a gt RedBlackTree a RedBlackTree a Computes the intersection of two red black tree sets This is done by inserting all elements of the first set contained in the second set into a new set which order is taken from the first set sortRBT a gt a gt Bool gt a gt a Generic sort based on insertion into red black trees The first argument is the order for the elements A 3 9 Library Sort A collection of useful functions for sorting and comparing characters strings and lists 156 Exported functions quickSort a a gt Bool gt a gt al Quicksort mergeSort a gt a Bool gt a gt la Bottom up mergesort leqList a gt a Bool gt a gt la gt Bool Less or equal on lists cmpList a gt a Ordering gt a gt a Ordering Comparison of lists legChar Char Char Bool Less or equal on characters deprecated use Prelude lt lt code gt lt lt code gt cmpChar Char Char Ordering Comparison of characters deprecated use Prel
185. ext suc a Int Int b a Int gt Int All Nodes linked to in a Context pre a Int Int b a Int gt Int All Nodes linked from in a Context 151 lpre a Int Int b a Int gt Int a All Nodes linked from in a Context and the label of the links lsuc C a Int Int b a Int Int a All Nodes linked from in a Context and the label of the links out a Int Int b a Int gt Int Int a All outward directed LEdges in a Context inn a Int Int b a Int gt nt Int a All inward directed LEdges in a Context outdeg a Int Int b a Int 1 gt Int The outward degree of a Context indeg a Int Int b a Int 1 gt Int The inward degree of a Context deg a Int Int b a Int 1 gt Int The degree of a Context labNodes Graph a b gt Int a A list of all LNodes in the Graph labEdges Graph a b gt Int Int b A list of all LEdges in the Graph nodes Graph a b gt Int List all Nodes in the Graph edges Graph a b gt Int Int List all Edges in the Graph newNodes Int gt Graph a b gt Int List N available Nodes ie Nodes that are not used in the Graph ufold a Int 1 Int b a Int 1 gt c gt c gt c gt Graph ba gt c Fold a function over the graph gmap a Int Int b a Int gt c Int Int d c Int gt Graph ba gt Graph dc Map a fun
186. f a cgi script written with this library can be done by the command makecurrycgi m initialForm o home joe public_html prog cgi prog where prog is the name of the Curry program with the cgi script home joe public_html prog cgi is the desired location of the compiled cgi script and initialForm is the Curry expression of type IO HtmlForm computing the HTML form where makecurrycgi is a shell script stored in pakcshome bin Exported types type CgiEnv CgiRef String The type for representing cgi environments i e mappings from cgi references to the corresponding values of the input elements type HtmlHandler CgiRef String gt I0 HtmlForm The type of event handlers in HTML forms data CgiRef The abstract data type for representing references to input elements in HTML forms Exported constructors data HtmlExp 163 The data type for representing HTML expressions Exported constructors e HtmlText String HtmlExp HtmlText s a text string without any further structure e HtmlStruct String gt String String HtmlExp HtmlExp HtmlStruct t as hs a structure with a tag attributes and HTML expressions inside the structure e HtmlCRef HtmlExp CgiRef HtmlExp HtmlCRef h ref an input element described by the first argument with a cgi reference e HtmlEvent HtmlExp gt CgiRef gt String gt IO HtmlForm gt HtmlExp HtmlEvent h hdlr
187. formed and pattern matching is translated into explicit case or expressions compare Appendix A 1 This representation might be useful for other back ends and compilers for Curry and is the basis doing meta programming in Curry This file is implicitly generated when a program is compiled with KiCS2 It can be also explicitly generated by the Curry front end cymake flat ikics2home lib prog The FlatCurry representation of a Curry program is usually generated by the front end after parsing type checking and eliminating local declarations If the Curry module M is stored in the directory dir the corresponding FlatCurry pro gram is stored in the directory dir curry This is also the case for hierarchical module names if the module D1 D2 M is stored in the directory dir i e the module is actu ally stored in dir D1 D2 M curry then the corresponding FlatCurry program is stored in dir curry D1 D2 M fcy prog fint This file contains the interface of the program in the so called FlatCurry represen tation i e it is similar to prog fcy but contains only exported entities and the bodies of all functions omitted i e external This representation is useful for providing a fast access to module interfaces This file is implicitly generated when a program is compiled with KiCS2 and stored in the same directory as prog fcy Curry_prog hs This file contains a Haskell program as the result of translating the Curry pr
188. g the environment variable CURRYPATH which can be also a set in a KiCS2 session by the option set path see below to a list of directory names separated by colons In addition a local standard search path can be defined in the kics2rc file see Section 2 7 Thus modules to be loaded are searched in the following directories in this order i e the first occurrence of a module file in this search path is imported 1 Current working directory or directory prefix of the main module e g directory home joe curryprogs if one loads the Curry program home joe curryprogs main 2 The directories enumerated in the environment variable CURRYPATH ee 3 The directories enumerated in the kics2rc variable libraries 4 The directory kics2home 1ib The same strategy also applies to modules with a hierarchical module name with the only difference that the hierarchy prefix of a module name corresponds to a directory prefix of the module For instance if the main module is stored in directory MAINDIR and imports the module Test Func then the module stored in MAINDIR Test Func curry is imported without setting any additional import path according to the module search strategy described above Note that the standard prelude kics2home 1ib Prelude curry will be always implicitly im ported to all modules if a module does not contain an explicit import declaration for t
189. get name of constructor declaration consArity ConsDecl Int get arity of constructor declaration consVisibility ConsDecl Visibility get visibility of constructor declaration consArgs ConsDecl gt TypeExpr get arguments of constructor declaration updCons String String gt String String gt Int gt Int gt Visibility gt Visibility gt TypeExpr TypeExpr gt ConsDecl gt ConsDecl update constructor declaration updConsName String String gt String String ConsDecl gt ConsDecl update name of constructor declaration updConsArity Int Int ConsDecl ConsDecl update arity of constructor declaration 257 updConsVisibility Visibility gt Visibility gt ConsDecl gt ConsDecl update visibility of constructor declaration updConsArgs TypeExpr gt TypeExpr ConsDecl ConsDecl update arguments of constructor declaration updQNamesInConsDecl String String gt String String ConsDecl gt ConsDecl update all qualified names in constructor declaration tVarIndex TypeExpr Int get index from type variable domain TypeExpr TypeExpr get domain from functional type range TypeExpr TypeExpr get range from functional type tConsName TypeExpr gt String String get name from constructed type tConsArgs TypeExpr TypeExpr get arguments from constructed type trT
190. gt WuiSpec b gt WuiSpec a b WUI combinator to combine two tuples into a joint tuple It is similar to wPair but renders both components as a single tuple provided that the components are already rendered as tuples i e by the rendering function renderTuple This combinator is useful to define combinators for large tuples wList WuiSpec a WuiSpec a WUI combinator for list structures where the list elements are vertically aligned in a table wListWithHeadings String WuiSpec a WuiSpec a Add headings to a standard WUI for list structures wHList WuiSpec a WuiSpec a WUI combinator for list structures where the list elements are horizontally aligned in a table wMatrix WuiSpec a gt WuiSpec a WUI for matrices i e list of list of elements visualized as a matrix wMaybe WuiSpec Bool WuiSpec a a WuiSpec Maybe a WUI for Maybe values It is constructed from a WUI for Booleans and a WUI for the potential values Nothing corresponds to a selection of False in the Boolean WUI The value WUI is shown after the Boolean WUI wCheckMaybe WuiSpec a gt HtmlExp a WuiSpec Maybe a A WUI for Maybe values where a check box is used to select Just The value WUI is shown after the check box wRadioMaybe WuiSpec a HtmlExp HtmlExp a WuiSpec Maybe a A WUI for Maybe values where radio buttons are used to switch between Nothing and Just The value
191. gt e gt f g gt XmlConv h i a gt XmlConv j k b gt XmlConv 1 m c XmlConv n o d gt XmlConv p q e gt XmlConv r s f gt XmlConv NotRepeatable NoElem g Creates an XML converter representing a sequence of arbitrary XML data The se quence must not be used in repetitions and does not represent an XML element repSeq6 a gt b gt c gt d gt e gt f gt g gt XmlConv Repeatable h a gt XmlConv Repeatable i b XmlConv Repeatable j c gt XmlConv Repeatable k d gt XmlConv Repeatable 1 e XmlConv Repeatable m f XmlConv NotRepeatable NoElem g Creates an XML converter that represents a repetition of a sequence of repeatable XML data The repetition may be used in other repetitions and does not represent an XML element This combinator is provided because converters for repeatable sequences cannot be constructed by the seq combinators eSeq6 String gt a gt b gt c gt d gt e gt f gt g gt XmlConv h ia gt XmlConv j k b XmlConv 1 m c gt XmlConv n o d gt XmlConv p q e gt XmlConv r s f gt XmlConv Repeatable Elem g Creates an XML converter for compound values represented as an XML element with children that correspond to the values components The element can be used in repe titions eRepSeg6 String gt a gt b gt c gt d gt e gt f gt g gt XmlConv Repeatable h a XmlConv Repeatable i b XmlCon
192. gt a Applies the given function to each member of the family of a value Proceeds bottom up mapChildFamilies a gt b b gt a gt b gt b b gt b gt b gt b gt a gt a Applies the given function to each member of the families of the children of a value The value and its children can have different types Proceeds bottom up evalFamily a gt a a gt a gt a gt Maybe a gt a gt a Applies the given function to each member of the family of a value as long as possible On each member of the family of the result the given function will yield Nothing Proceeds bottom up evalChildFamilies a gt b b gt a gt b gt b b gt b b gt Maybe b gt a gt a Applies the given function to each member of the families of the children of a value as long as possible Similar to evalFamily fold a gt a a gt a gt a gt b gt b gt ab Implements a traversal similar to a fold with possible default cases 159 foldChildren a gt b b gt ad gt b gt b b gt b gt a gt c gt d gt b gt c c gt a gt d Fold the children and combine the results replaceChildrenl0 a gt b b gt a gt a gt 10 b I0 a IO version of replaceChildren mapChildrenIO a gt b b gt a gt b gt I0 b gt a gt IOa IO version of mapChildren mapFamilyI0
193. h occurrence corresponds to one element i e the list might contain multiple elements varsOfLDecl CLocalDecl gt Int String Returns list of all variables occurring in a local declaration Each occurrence corresponds to one element i e the list might contain multiple elements varsOfFDecl CFuncDecl gt Int String Returns list of all variables occurring in a function declaration Each occurrence corre sponds to one element i e the list might contain multiple elements varsOfRule CRule gt Int String Returns list of all variables occurring in a rule Each occurrence corresponds to one element i e the list might contain multiple elements funcNamesOfLDecl CLocalDecl gt String String funcNamesOfFDecl CFuncDecl String String funcNamesOfStat CStatement String String ldeclsOfRule CRule gt CLocalDecl1 isPrelude String Bool Tests whether a module name is the prelude 215 A 5 4 Library AbstractCurry Build This library provides some useful operations to write programs that generate AbstractCurry pro grams in a more compact and readable way Exported functions gt CTypeExpr CTypeExpr gt CTypeExpr A function type baseType String String CTypeExpr A base type listType CTypeExpr CTypeExpr Constructs a list type from an element type tupleType CTypeExpr CTypeExpr Constructs a tuple type from list of comp
194. he computed values depends on the ordering of the program rules Thus this operation should be used only if the predicate has a single solution A 2 16 Library Float A collection of operations on floating point numbers 68 Exported functions pi Float The number pi Float gt Float gt Float Addition on floats Float gt Float gt Float Subtraction on floats Float gt Float gt Float Multiplication on floats Float gt Float gt Float Division on floats Float gt Int gt Float The value of a 7 b is a raised to the power of b Executes in O log b steps i2f Int gt Float Conversion function from integers to floats truncate Float Int Conversion function from floats to integers The result is the closest integer between the argument and 0 round Float gt Int Conversion function from floats to integers The result is the nearest integer to the argument If the argument is equidistant between two integers it is rounded to the closest even integer value recip Float Float Reciprocal sqrt Float Float Square root log Float Float Natural logarithm logBase Float Float Float 69 Logarithm to arbitrary Base exp Float Float Natural exponent sin Float Float Sine cos Float Float Cosine tan Float Float Tangent asin Float Float Arc sine acos Float Float at
195. he evaluation of this operation Basically the command runcurry supports three modes of operation e One can execute a Curry program whose file name is provided as an argument when runcurry e is called In this case the suffix curry or 1curry must be present and cannot be dropped One can write additional commands for the interactive environment typically settings of some options before the Curry program name All arguments after the Curry program name are passed as run time arguments For instance consider the following program stored in the file ShowArgs curry import System getArgs main getArgs gt gt print This program can be executed by the shell command gt runcurry ShowArgs curry Hello World which produces the output Hello World e One can also execute a Curry program whose whose program text comes from the standard input Thus one can either pipe the program text into this command or type the program text on the keyboard For instance if we type gt runcurry main putStr unlines map show take 8 1 followed by the end of file marker Ctrl D the output AON OOF WN RHE is produced e One can also write the program text in a script file to be executed like a shell script In this case the script must start with the line 40 usr bin env runcurry followed by the source text of the Curry program For instance we can write a simple Curry script
196. he module Prelude 2 Using the Interactive Environment of KiCS2 This section describes the interactive environment KiCS2 that supports the development of appli cations written in Curry The implementation of KiCS2 contains also a separate compiler which is automatically invoked by the interactive environment 2 1 Invoking KiCS2 To start KiCS2 execute the command kics2 this is a shell script stored in kics2home bin where kics2home is the installation directory of KiCS2 When the system is ready i e when the prompt Prelude gt occurs the prelude kics2home 1ib Prelude curry is already loaded i e all definitions in the prelude are accessible Now you can type various commands see next section or an expression to be evaluated One can also invoke KiCS2 with parameters These parameters are usual a sequence of com mands see next section that are executed before the user interaction starts For instance the invocation kics2 load Mod add List starts KiCS2 loads the main module Mod and adds the additional module List The invocation kics2 load Mod eval config starts KiCS2 loads the main module Mod and evaluates the operation config before the user interaction starts As a final example the invocation kics2 load Mod save quit starts KiCS2 loads the main module Mod creates an executable and terminates KiCS2 This invocation could be useful in make files for systems implemented in Curry Ther
197. he same type and returns the corresponding list of data terms writeQTermFile String gt a gt I0 Writes a ground term into a file in standard prefix notation writeQTermListFile String la gt I0 Writes a list of ground terms into a file Each term is written into a separate line which might be useful to modify the file with a standard text editor A 2 37 Library SearchTree This library defines a representation of a search space as a tree and various search strategies on this tree This module implements strong encapsulation as discussed in this paper 126 Exported types type Strategy a SearchTree a ValueSequence a A search strategy maps a search tree into some sequence of values Using the abtract type of sequence of values rather than list of values enables the use of search strategies for encapsulated search with search trees strong encapsulation as well as with set functions weak encapsulation data SearchTree A search tree is a value a failure or a choice between two search trees Exported constructors e Value a SearchTree a e Fail Int gt SearchTree a e Or SearchTree a gt SearchTree a gt SearchTree a Exported functions getSearchTree a gt IO SearchTree a Returns the search tree for some expression someSearchTree a SearchTree a Internal operation to return the search tree for some expression Note that this operation is not purely declarative
198. hell escape execute cmd in a Unix shell 2 3 Options of KiCS2 The following options which can be set by the command set are currently supported 11 path path Set the additional search path for loading modules to path Note that this search path b s d s ids is only used for loading modules inside this invocation of KiCS2 uy The path is a list of directories separated by The prefix is replaced by the home directory as in the following example set path aux tests Relative directory names are replaced by absolute ones so that the path is independent of later changes of the current working directory Set the search mode to evaluate non deterministic expressions to breadth first search This is the default search strategy Usually all non deterministic values are enumerated and printed with a breadth first strategy but one can also print only the first value or all values by interactively requesting them see below for these options Similarly to bfs but use a depth first search strategy to compute and print the values of the initial expression Similarly to bfs but use an iterative deepening strategy to compute and print the values of the initial expression The initial depth bound is 100 and the depth bound is doubled after each iteration ids n Similarly to ids but use an initial depth bound of n parallel Similarly to bfs
199. ideas and options to influence this optimization Consider the following definition of the operation last to extract the last element in list last xs xs _ x x where x free In order to evaluate the condition xs _ x the Boolean equality is evaluated to True or False by instantiating the free variables _ and x However since we know that a condition must be evaluated to True only and all evaluations to False can be ignored we can use the constrained equality to obtain a more efficient program last xs xs _ x x where x free Since the selection of the appropriate equality operator is not obvious and might be tedious KiCS2 149 encourages programmers to use only the Boolean equality operator in programs The con 4 straint equality operator can be considered as an optimization of if it is ensured that only positive results are required e g in conditions of program rules To support this programming style KiCS2 has a built in optimization phase on FlatCurry files For this purpose the optimizer analyzes the FlatCurry programs for occurrences of and replaces them by whenever the result False is not required The usage of the optimizer can be influenced by setting the property flag bindingoptimization in the configuration file kics2rc The following values are recognized for this flag no Do not apply this transformation fast
200. ile Prog curry CURRYPP if the name of the original program is Prog curry For instance in order to use integrated code and default rules in a module and store the transformed program one has to put the line OPTIONS_CYMAKE F pgmF currypp optF foreigncode optF defaultrules optF o at the beginning of the program 9 1 Integrated Code Integrated code is enclosed in at least two back ticks and ticks in a Curry program The number of starting back ticks and ending ticks must be always identical After the initial back ticks there must be an identifier specifying the kind of integrated code e g regexp or html see below For instance if one uses regular expressions see below for more details the following expressions are valid in source programs 35 s regex al bcx ccece s regex abaxc The Curry preprocessor transforms these code pieces into regular Curry expressions The next sections describe the currently supported foreign languages 9 1 1 Regular Expressions In order to match strings against regular expressions i e to check whether a string is contained in the language generated by a regular expression one can specify regular expression similar to POSIX The foreign regular expression code must be marked by regexp Since this code is transformed into operations of the KiCS2 library RegExp this library must be imported For instance the following module defines a predicate t
201. ile o ociosos a h aoe ee ah ea RS 228 A 5 8 Library FlatCurry Goodies lt o c e b sct aos aca e 229 A 5 9 Library FlatCurry Pretty gt o ccc tose pad e nasai sd pppu 241 A 5 10 Library FlatCurry Read e sc ccce thir 66 Reba eses 246 A 5 11 Library FlatOurry Show gt lt o c oe raos a ee a Ras a 246 A 5 12 Library PlatCurty AMD s e os a g kor OE a a a 247 A 5 13 Library FlatCurry FlexRigid sansende Eana ei 247 A 5 14 Library FlatCurry Compact gt e ce e 248 A 5 15 Library FlatCurry Annotated Types e 250 A 5 16 Library FlatCurry Annotated Pretty 251 A 5 17 Library FlatCurry Annotated Goodies ee eee 254 A 5 18 Library FlatCurry Annotated TypeSubst o 267 A 5 19 Library FlatCurry Annotated TypeI nference a aoo 268 A 5 20 Library CurryStringClassifier e o 270 B Markdown Syntax 272 B 1 Paragraphs and Basic Formatting 0 0 0 0 20002 eee eee 272 B 2 Lists and Block Formatting lt lt o e eaaa e 4 0 85055 2 bee eR De aaa 273 Bo Bode go ee le wo ee ee a ee ee ee eee a ee ee 275 C Auxiliary Files 276 D External Operations 278 Index 281 Preface This document describes KiCS2 Kiel Curry System Version 2 an implementation of the multi paradigm language Curry 11 20 that is based on compiling Curry programs into Haskell pro grams Curry is a universal programming language a
202. ill be quoted so that they appear as in the parameter string htxts String HtmlExp A list of strings represented as a list of HTML expressions The strings may contain special HTML chars that will be quoted hempty HtmlExp An empty HTML expression nbsp HtmlExp Non breaking Space hi HtmlExp HtmlExp Header 1 h2 HtmlExp HtmlExp Header 2 h3 HtmlExp gt HtmlExp Header 3 169 h4 HtmlExp HtmlExp Header 4 h5 HtmlExp gt HtmlExp Header 5 par HtmlExp gt HtmlExp Paragraph section HtmlExp gt HtmlExp Section header HtmlExp gt HtmlExp Header footer HtmlExp HtmlExp Footer emphasize HtmlExp HtmlExp Emphasize strong HtmlExp HtmlExp Strong more emphasized text bold HtmlExp HtmlExp Boldface italic HtmlExp HtmlExp Italic nav HtmlExp HtmlExp Navigation code HtmlExp gt HtmlExp Program code center HtmlExp HtmlExp Centered text blink HtmlExp HtmlExp Blinking text 170 teletype HtmlExp gt HtmlExp Teletype font pre HtmlExp HtmlExp Unformatted input i e keep spaces and line breaks and don t quote special characters verbatim String HtmlExp Verbatim unformatted special characters lt gt amp are quoted address HtmlExp HtmlExp Address href String HtmlExp HtmlExp Hypertext reference
203. iming at the amalgamation of the most im portant declarative programming paradigms namely functional programming and logic program ming Curry combines in a seamless way features from functional programming nested expressions lazy evaluation higher order functions logic programming logical variables partial data struc tures built in search and concurrent programming concurrent evaluation of constraints with synchronization on logical variables The current KiCS2 implementation does not support con current constraints Alternatively one can write distributed applications by the use of sockets that can be registered and accessed with symbolic names Moreover KiCS2 also supports the high level implementation of graphical user interfaces and web services as described in more detail in 12 13 14 17 We assume familiarity with the ideas and features of Curry as described in the Curry language definition 20 Therefore this document only explains the use of the different components of KiCS2 and the differences and restrictions of KiCS2 see Section 1 3 compared with the language Curry Version 0 9 0 The basic ideas of the implementation of KiCS2 can be found in 10 9 Acknowledgements This work has been supported in part by the DFG grants Ha 2457 5 1 and Ha 2457 5 2 1 Overview of KiCS2 1 1 Installation This version of KiCS2 has been developed and tested on Linux systems In principle it should be also executable on oth
204. in leadings blanks and the integer is read up to the first non digit If the string does not start with an integer token Nothing is returned otherwise the result is Just v s where v is the value of the integer and s is the remaing string without the integer token readNat String Maybe Int String 124 Read a natural number as a first token in a string The string might contain leadings blanks and the number is read up to the first non digit If the string does not start with a natural number token Nothing is returned otherwise the result is Just v s where v is the value of the number and s is the remaing string without the number token readHex String gt Maybe Int String Read a hexadecimal number as a first token in a string The string might contain leadings blanks and the number is read up to the first non hexadecimal digit If the string does not start with a hexadecimal number token Nothing is returned otherwise the result is Just v s where v is the value of the number and s is the remaing string without the number token readOct String Maybe Int String Read an octal number as a first token in a string The string might contain leadings blanks and the number is read up to the first non octal digit If the string does not start with an octal number token Nothing is returned otherwise the result is Just v s where v is the value of the number and s is the remaing string without the number toke
205. ions TypeDec1 FuncDec1 gt Doc pretty print the export list ppTypeExport Options gt TypeDecl Doc pretty print a type export ppConsExports Options ConsDec1 gt Doc pretty print the export list of constructors ppFuncExports Options FuncDec1 gt Doc pretty print the export list of functions ppImports Options String gt Doc pretty print a list of import statements ppImport Options gt String Doc pretty print a single import statement ppOpDecls Options gt OpDec1 Doc pretty print a list of operator fixity declarations ppOpDecl Options gt OpDecl gt Doc pretty print a single operator fixity declaration ppFixity Fixity gt Doc pretty print the associativity keyword ppTypeDecls Options gt TypeDec1 gt Doc pretty print a list of type declarations ppTypeDecl Options gt TypeDecl Doc 243 pretty print a type declaration ppConsDecls Options gt ConsDec1 Doc pretty print the constructor declarations ppConsDecl Options gt ConsDecl Doc pretty print a single constructor ppTypeExp Options TypeExpr Doc pretty a top level type expression ppTypeExpr Options gt Int TypeExpr Doc pretty print a type expression ppTVarIndex Int Doc pretty print a type variable ppFuncDecls Options FuncDecl Doc pretty print a list of function declarations p
206. ions and returns the corresponding FlatCurry program This I O action is used by the standard action readFlatCurry flatCurryFileName String String 228 Transforms a name of a Curry program with or without suffix curry or lcurry into the name of the file containing the corresponding FlatCurry program flatCurryIntName String String Transforms a name of a Curry program with or without suffix curry or lcurry into the name of the file containing the corresponding FlatCurry program readFlatCurryFile String gt 10 Prog I O action which reads a FlatCurry program from a file in fey format In contrast to readFlatCurry this action does not parse a source program Thus the argument must be the name of an existing file with suffix fcy containing a FlatCurry program in fey format and the result is a FlatCurry term representing this program readFlatCurrylnt String IO Prog I O action which returns the interface of a Curry module i e a FlatCurry program containing only Public entities and function definitions without rules i e external functions The argument is the file name without suffix curry or lcurry and the result is a FlatCurry term representing the interface of this module writeFCY String Prog gt I0 Writes a FlatCurry program into a file in fcy format The first argument must be the name of the target fil
207. is classified into the following categories e moduleHead module interface imports operators e code the part where the actual program is defined e big comment parts enclosed in e small comment from to the end of a line e text a string i e text enclosed in e letter the given string is the representation of a character e meta containing information for meta programming For an example to use the state scanner cf addtypes the tool to add function types to a given program Exported types type Tokens Token data Token The different categories to classify the source code Exported constructors e SmallComment String Token e BigComment String Token e Text String Token e Letter String Token e Code String Token e ModuleHead String Token e Meta String Token 270 Exported functions isSmallComment Token Bool test for category SmallComment isBigComment Token gt Bool test for category BigComment isComment Token Bool test if given token is a comment big or small isText Token Bool test for category Text String isLetter Token Bool test for category Letter Char isCode Token Bool test for category Code isModuleHead Token Bool test for category ModuleHead ie imports and operator declarations isMeta Token Bool test for c
208. isConsCall AExpr a gt Bool is expression a call of a constructor isConsPartCall AExpr a Bool is expression a partial constructor call isGround AExpr a Bool is expression fully evaluated allVars AExpr a gt Int get all variables also pattern variables in expression rnmAllVars Int gt Int gt AExpr a gt AExpr a rename all variables also in patterns in expression updQNames String String gt String String AExpr a gt AExpr a update all qualified names in expression trBranch APattern a gt AExpr a gt b ABranchExpr a gt b transform branch expression branchPattern ABranchExpr a APattern a get pattern from branch expression branchExpr ABranchExpr a gt AExpr a get expression from branch expression 265 updBranch APattern a gt APattern a gt AExpr a gt AExpr a gt ABranchExpr a gt ABranchExpr a update branch expression updBranchPattern APattern a APattern a ABranchExpr a gt ABranchExpr a update pattern of branch expression updBranchExpr AExpr a AExpr a ABranchExpr a gt ABranchExpr a update expression of branch expression trPattern a gt String String a gt Int a gt b gt a gt Literal gt b APattern a gt b transform pattern patCons APattern a gt String String get name from constructor pattern patArgs APattern a gt Int a get arguments from
209. ked The order of pattern matching should not influence the computed result However it might have some influence on the termination behavior of programs i e a program might not terminate instead of finitely failing In such cases it could be necessary to consider the influence of the order of pattern matching Note that other orders of pattern matching can be obtained using auxiliary operations 19 4 Recognized Syntax of Curry The KiCS2 Curry compiler accepts a slightly extended version of the grammar specified in the Curry Report 20 Furthermore the syntax recognized by KiCS2 differs from that specified in the Curry Report regarding numeric or character literals We therefore present the complete description of the syntax below whereas syntactic extensions are highlighted 4 1 Notational Conventions The syntax is given in extended Backus Naur Form eBNF using the following notation NonTerm a production Non Term nonterminal symbol Term terminal symbol la optional a zero or more repetitions a grouping a 8 alternative ag difference elements generated by a without those generated by 8 The Curry files are expected to be encoded in UTF8 However source programs are biased towards ASCII for compatibility reasons 4 2 Lexicon 4 2 1 Case Mode Although the Curry Report specifies four different case modes Prolog G del Haskell free the KiCS2 only supports the free mode which puts no constraints on the c
210. l qualified names in type declaration trCons String String gt Int gt Visibility TypeExpr gt a gt ConsDecl gt a transform constructor declaration consName ConsDecl String String get name of constructor declaration consArity ConsDecl Int get arity of constructor declaration consVisibility ConsDecl Visibility get visibility of constructor declaration consArgs ConsDecl gt TypeExpr get arguments of constructor declaration updCons String String gt String String gt Int gt Int gt Visibility gt Visibility gt TypeExpr TypeExpr gt ConsDecl gt ConsDecl update constructor declaration updConsName String String gt String String ConsDecl gt ConsDecl update name of constructor declaration updConsArity Int Int ConsDecl ConsDecl update arity of constructor declaration 232 updConsVisibility Visibility gt Visibility gt ConsDecl gt ConsDecl update visibility of constructor declaration updConsArgs TypeExpr gt TypeExpr ConsDecl ConsDecl update arguments of constructor declaration updQNamesInConsDecl String String gt String String ConsDecl gt ConsDecl update all qualified names in constructor declaration tVarIndex TypeExpr Int get index from type variable domain TypeExpr TypeExpr get domain from functional type
211. lSep 112 filterFM 145 find 100 findall 7 findIndex 100 findIndices 100 first 13 71 fix 71 Fixity 224 FlatCurry 47 flatCurry2Xml 247 flatCurry2XmlFile 247 flatCurryFileName 228 flatCurryIntName 229 FlexRigidResult 248 float 115 200 floatType 216 FM 144 fmSortBy 146 fmToList 146 fmToListPreOrder 146 286 focusInput 84 fold 159 foldChildren 160 foldFM 145 foldValues 132 footer 170 form 167 formatMarkdownFileAsPDF 181 formatMarkdownInputAsPDF 181 formBodyAttr 167 formCSS 167 formEnc 167 formMetaInfo 167 FormParam 164 freeExpr 238 263 freeVars 238 263 fromJust 104 fromLeft 61 fromMarkdownText 180 fromMaybe 104 fromRight 61 FrontendParams 57 FrontendTarget 56 fullPath 60 funcArgs 236 261 funcArity 235 260 funcBody 236 261 FuncDecl 224 funcName 215 235 260 funcNamesOfFDecl 215 funcNamesOfLDecl 215 funcNamesOfStat 215 funcRHS 236 261 funcRule 235 260 functional pattern 18 functions 213 funcType 235 260 funcVis 215 funcVisibility 235 260 garbageCollect 121 garbageCollectorOff 121 garbageCollectorOn 121 GDecomp 148 gelem 151 generateCompactFlatCurryFile 249 germanLatexDoc 176 getAbsolutePath 56 getAllFailures 48 getAllSolutions 48 getAllValues 48 67 getAllValuesWith 128 140 getArgs 134 getAssoc 92 getClockTime 136 getContents 90 getContentsO0fUrl 181 getCookies 175 getCPUTime 134 getCurrentDirector
212. lackTree a b gt a b Transforms the nodes of red black tree into a list deleteRBT a gt RedBlackTree a b gt RedBlackTree a b A 3 11 Library Traversal Library to support lightweight generic traversals through tree structured data See here fora description of the library Exported types type Traversable ab a gt b b gt a A datatype is Traversable if it defines a function that can decompose a value into a list of children of the same type and recombine new children to a new value of the original type http www ps informatik uni kiel de sebf projects traversal html 158 Exported functions noChildren a gt b b gt a Traversal function for constructors without children children a gt b b a gt a gt b Yields the children of a value replaceChildren a gt b b gt a gt a gt bl gt a Replaces the children of a value mapChildren a gt b b gt a gt b gt b Sana Applies the given function to each child of a value family a gt lal lal gt a gt a gt a Computes a list of the given value its children those children etc childFamilies a gt b b gt a gt b gt b b gt DD gt a gt b Computes a list of family members of the children of a value The value and its children can have different types mapFamily a gt a a gt a gt aa gt az
213. ligned vertically All comma seperators are put in front of the elements tupledSpaced Doc gt Doc Spaced version of tupled semiBraces Doc gt Doc The document semiBraces xs seperates the documents xs with semi colons and encloses them in braces The documents are rendered horizontally if that fits the page Otherwise they are aligned vertically All semi colons are put in front of the elements semiBracesSpaced Doc Doc Spaced version of semiBraces enclose Doc gt Doc Doc gt Doc The document enclose 1 r x encloses document x between documents 1 and r using lt gt enclose lrx 1 lt gt x lt gt r squotes Doc gt Doc 114 Document squotes x encloses document x with single quotes dquotes Doc Doc Document dquotes x encloses document x with double quotes bquotes Doc Doc Document bquotes x encloses document x with back quotes parens Doc Doc Document parens x encloses document x in parenthesis and gt parensIf Bool Doc Doc Document parensIf x encloses document x in parenthesis and iff the con dition is true angles Doc Doc Document angles x encloses document x in angles lt and gt braces Doc Doc Document braces x encloses document x in braces and brackets Doc Doc Document brackets x encloses document x in square brackets and char Char Doc
214. llect all values e g dfsStrategy or bfsStrategy Conceptually all printed values are computed on a copy of the expression i e the evaluation of the expression does not share any results someValue a gt a Returns some value for an expression Note that this operation is not purely declarative since the computed value depends on the ordering of the program rules T hus this operation should be used only if the expression has a single value It fails if the expression has no value someValueWith SearchTree a gt ValueSequence a gt a gt a Returns some value for an expression w r t a search strategy A search strategy is an operation to traverse a search tree and collect all values e g dfsStrategy or bfsStrategy Note that this operation is not purely declarative since the computed value depends on the ordering of the program rules Thus this operation should be used only if the expression has a single value It fails if the expression has no value A 2 38 Library SetFunctions This module contains an implementation of set functions The general idea of set functions is described in S Antoy M Hanus Set Functions for Functional Logic Programming Proc 11th Inter national Conference on Principles and Practice of Declarative Programming PPDP 09 pp 73 82 ACM Press 2009 Intuition If f is an n ary function then setn f is a set valued function that collects all non determinism caused by f but not th
215. luates the conjunction of a list of constraints orC Bool Bool Evaluates the disjunction of a list of constraints allC a gt Bool gt a Bool Is a given constraint abstraction satisfied by all elements in a list anyC a gt Bool gt a Bool Is there an element in a list satisfying a given constraint A 2 6 Library CPNS Implementation of a Curry Port Name Server based on raw sockets It is used to implement the library Ports for distributed programming with ports Exported functions cpnsStart I0 Starts the Curry Port Name Server CPNS running on the local machine The CPNS is responsible to resolve symbolic names for ports into physical socket numbers so that a port can be reached under its symbolic name from any machine in the world cpnsShow I0 Shows all registered ports at the local CPNS demon in its logfile cpnsStop I0 Terminates the local CPNS demon registerPort String gt Int gt Int gt I0 Registers a symbolic port at the local host getPortInfo String gt String gt 10 Int Int Gets the information about a symbolic port at some host unregisterPort String gt I0 Unregisters a symbolic port at the local host cpnsAlive Int String 10 Bool Tests whether the CPNS demon at a host is alive main 10 O Main function for CPNS demon Check arguments and execute command 93 A 2 7 Library CSV Library for reading writi
216. m FormTarget s a name of a target frame where the output of the script should be represented should only be used for scripts running in a frame FormEnc String FormParam FormEnc the encoding scheme of this form FormMeta String String FormParam FormMeta as meta information in form of attributes for this form HeadInclude HtmlExp FormParam HeadInclude he HTML expression to be included in form header MultipleHandlers FormParam MultipleHandlers 165 indicates that the event handlers of the form can be multiply used i e are not deleted if the form is submitted so that they are still available when going back in the browser but then there is a higher risk that the web server process might overflow with unused events the default is a single use of event handlers i e one cannot use the back button in the browser and submit the same form again which is usually a reasonable behavior to avoid double submissions of data e BodyAttr String String gt FormParam BodyAttr ps optional attribute for the body element more than one occurrence is allowed data CookieParam The possible parameters of a cookie Exported constructors e CookieExpire ClockTime CookieParam e CookieDomain String CookieParam e CookiePath String CookieParam e CookieSecure CookieParam data HtmlPage The data type for representing HTML pages The cons
217. m TclOption further options in Tcl syntax unsafe data Reconfigureltem Data type for describing configurations that are applied to a widget or GUI by some event handler Exported constructors e WidgetConf WidgetRef ConfItem Reconfigureltem WidgetConf wref conf 77 reconfigure the widget referred by wref with configuration item conf e StreamHandler Handle gt Handle gt GuiPort gt I0 Reconfigureltem gt Reconfigureltem StreamHandler hdl handler add a new handler to the GUI that processes inputs on an input stream referred by hdl e RemoveStreamHandler Handle Reconfigureltem RemoveStreamHandler hdl remove a handler for an input stream referred by hdl from the GUI usually used to remove handlers for closed streams data Event The data type of possible events on which handlers can react This list is still incomplete and might be extended or restructured in future releases of this library Exported constructors e DefaultEvent Event DefaultEvent the default event of the widget e MouseButtoni Event MouseButton1 left mouse button pressed e MouseButton2 Event MouseButton2 middle mouse button pressed e MouseButton3 Event MouseButton3 right mouse button pressed e KeyPress Event KeyPress any key is pressed e Return Event Return 78 return key is pressed data ConfCollection The data
218. mWSpec wHidden WuiSpec a A hidden widget for a value that is not shown in the WUI Usually this is used in components of larger structures e g internal identifiers data base keys wConstant a HtmlExp WuiSpec a A widget for values that are shown but cannot be modified The first argument is a mapping of the value into a HTML expression to show this value wInt WuiSpec Int A widget for editing integer values wString WuiSpec String A widget for editing string values wStringSize Int WuiSpec String A widget for editing string values with a size attribute wRequiredString WuiSpec String A widget for editing string values that are required to be non empty wRequiredStringSize Int WuiSpec String A widget with a size attribute for editing string values that are required to be non empty wTextArea Int Int gt WuiSpec String A widget for editing string values in a text area The argument specifies the height and width of the text area 183 wSelect a gt String la gt WuiSpec a A widget to select a value from a given list of values The current value should be contained in the value list and is preselected The first argument is a mapping from values into strings to be shown in the selection widget wSelectInt Int gt WuiSpec Int A widget to select a value from a given list of integers provided as the argument The current value should be contained in the v
219. mp amp amp 71 KiCS2 9 lt gt 62 106 lt gt 110 lt gt 65 lt gt 110 lt gt 66 110 Li 02 lt 52 lt RAR lt gt 111 lt gt 110 lt gt 110 lt gt 62 lt gt 110 gt 62 gt 62 gt 2 gt 53 gt gt 104 gt gt gt 106 gt 216 100 86 7 69 aBool 201 ABranchExpr 251 abs 87 AbstractCurry 47 abstractCurryFileName 212 aChar 201 acos 70 acosh 70 adapt 201 adaptWSpec 183 190 addAttr 174 addAttrs 174 addCanvas 84 addClass 174 addCookies 168 addCurrySubdir 59 addDays 137 addExtension 65 281 addFormParam 168 addHeadings 171 addHours 137 addListToFM 144 addListToFM_C 144 addMinutes 137 addMonths 137 addPageParam 169 addRegionStyle 84 address 171 addSeconds 137 addSound 168 addToFM 144 addToFM_C 144 addTrailingPathSeparator 66 addVS 141 addYears 137 AExpr 250 AFCSubst 267 aFloat 201 AFuncDecl 250 aInt 201 align 109 al1C 53 allDBInfos 98 allDBKeyInfos 98 allDBKeys 98 Al11Solutions 7 allSolutions 68 allValues 68 allValuesBFS 128 139 allValuesDFS 128 139 allValuesDiag 128 allValuesIDS 128 139 allValuesIDSwith 128 140 allValuesWith 128 allVars 240 265 allVarsInFunc 235 261 allVarsInProg 230 255 allVarsInRule 237 262 alwaysRequired 249 anchor 171 andC 53 angles 115 annExpr 267 annPattern 267 annRule 267 answerEncText 168
220. n A 2 36 Library ReadShowTerm Library for converting ground terms to strings and vice versa Exported functions showTerm a gt String Transforms a ground term into a string representation in standard prefix notation Thus showTerm suspends until its argument is ground This function is similar to the prelude function show but can read the string back with readUnqualifiedTerm provided that the constructor names are unique without the module qualifier showQTerm a gt String Transforms a ground term into a string representation in standard prefix notation Thus showTerm suspends until its argument is ground Note that this function differs from the prelude function show since it prefixes constructors with their module name in order to read them back with readQTerm readsUnqualifiedTerm String gt String gt a String Transform a string containing a term in standard prefix notation without module qual ifiers into the corresponding data term The first argument is a non empty list of module qualifiers that are tried to prefix the constructor in the string in order to get the qualified constructors that must be defined in the current program In case of a successful parse the result is a one element list containing a pair of the data term and the remaining unparsed string 125 readUnqualifiedTerm String String gt a Transforms a string containing a term in standard prefix notation
221. n Principles and Practice of Declarative Programming PPDP 09 pages 73 82 ACM Press 2009 S Antoy and M Hanus Curry without Success In Proc of the 23rd International Workshop on Functional and Constraint Logic Programming WFLP 2014 volume 1335 of CEUR Workshop Proceedings pages 140 154 CEUR WS org 2014 S Antoy and M Hanus From boolean equalities to constraints In Proceedings of the 25th International Symposium on Logic based Program Synthesis and Transformation LOPSTR 2015 Springer LNCS to appear 2015 S Antoy and M Hanus Default rules for Curry In Proc of the 18th International Symposium on Practical Aspects of Declarative Languages PADL 2016 Springer LNCS to appear 2016 L Augustsson M Rittri and D Synek On generating unique names Journal of Functional Programming 4 1 117 123 1994 B Brabel M Hanus and F Huch Encapsulating non determinism in functional logic com putations Journal of Functional and Logic Programming 2004 6 2004 B Brafel M Hanus and M M ller High level database programming in Curry In Proc of the Tenth International Symposium on Practical Aspects of Declarative Languages PADL 08 pages 316 332 Springer LNCS 4902 2008 B Bra el M Hanus B Peem ller and F Reck Implementing equational constraints in a functional language In Proc of the 19th International Conference on Applications of Declara tive Programming and Knowledge Management INAP 20
222. n involve complex constraints As a simple example the following module defines a lookup operation in association lists by a functional pattern Due to the sequential rule strategy the second rule is applied only if there is no appropriate key in the association list 38 OPTIONS_CYMAKE F pgmF currypp optF seqrules mlookup key _ key value _ Just value mlookup _ Nothing 9 3 Default Rules An alternative to sequential rules are default rules i e these two options cannot be simultaneously used Default rules are activated by the preprocessor option defaultrules In this case one can add to each operation a default rule A default rule for a function f is defined as a rule defining the operation f default this mechanism avoids any language extension for default rules A default rule is applied only if no standard rule is applicable either because the left hand sides pattern do not match or the conditions are not satisfiable Default rules are preferable over the sequential rule selection strategy since they have a better operational behavior This is due to the fact that the test for the application of default rules is done with the same sometimes optimal strategy than the selection of standard rules Moreover default rules provide a similar power than sequential rules i e they can be applied if the standard rules have complex functional patterns or complex conditions As a simple ex
223. n of the ideas behind this tool can be found in 15 16 CurryBrowser is part of the KiCS2 distribution and can be started in two ways e In the command shell via the command kics2home bin currybrowser mod e In the KiCS2 environment after loading the module mod and typing the command browse Here mod is the name of the main module of a Curry application After the start CurryBrowser loads the interfaces of the main module and all imported modules before a GUI is created for interactive browsing To get an impression of the use of CurryBrowser Figure 1 shows a snapshot of its use on a particular application here the implementation of CurryBrowser The upper list box in the left column shows the modules and their imports in order to browse through the modules of an application Similarly to directory browsers the list of imported modules of a module can be opened or closed by clicking After selecting a module in the list of modules its source code interface or various other formats of the module can be shown in the main right text area For instance one can show pretty printed versions of the intermediate flat programs see below in order to see how local function definitions are translated by lambda lifting 21 or pattern matching is translated into case expressions 11 22 Since Curry is a language with parametric polymorphism and type inference programmers often omit the type signatures when defining functions Theref
224. n the module itself the respective type is inserted into a type environment type assumption 2 Every subexpression is annotated with a fresh type variable whereas constructor and function names are annotated with a fresh variant of the type in the type assumption 3 Based on FlatCurry s type inference rules type equations are generated for a function s rule 4 The resulting equations are solved using unification and the resulting substitution is applied to the function rule 5 The inferred types are then normalized such that for every function rule the type variables start with 0 268 In addition the function inferNewFunctions allows to infer the types of a list of functions whose type is not known before Consequently this disallows polymorphic recursive functions Those functions are separated into strongly connected components before their types are inferred to allow mutually recursive function definitions In case of any error the type inference quits with an error message Exported types type TypeEnv FM String String TypeExpr A type environment Exported functions inferProg Prog gt IO Either String AProg TypeExpr Infers the type of a whole program inferProgFromProgEnv String Prog Prog gt Either String AProg TypeExpr Infers the type of a whole program w r t a list of imported modules inferFunction String String gt Prog gt 10 Either String AFuncDecl TypeE
225. n value via a radio button The arguments are the lists of HTML expressions that are shown after the True and False radio buttons respectively wJoinTuple WuiSpec a gt WuiSpec b WuiSpec a b WUI combinator to combine two tuples into a joint tuple It is similar to wPair but renders both components as a single tuple provided that the components are already rendered as tuples i e by the rendering function renderTuple This combinator is useful to define combinators for large tuples wPair WuiSpec a WuiSpec b WuiSpec a b WUI combinator for pairs wCons2 a gt b gt c gt WuiSpec a WuiSpec b WuiSpec c 191 WUI combinator for constructors of arity 2 The first argument is the binary con structor The second and third arguments are the WUI specifications for the argument types wCons2JS Maybe JSExp gt JSExp gt a gt b gt c WuiSpec a gt WuiSpec b gt WuiSpec c wTriple WuiSpec a WuiSpec b gt WuiSpec c gt WuiSpec a b c WUI combinator for triples wCons3 a b gt c gt d WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d WUI combinator for constructors of arity 3 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types wCons3JS Maybe JSExp gt JSExp gt a gt b gt c gt d gt WuiSpec a WuiSpec b gt WuiSpec c WuiSpec d
226. name conflicts Tf the file External_String hs contains also some import declarations at the beginning these import declara tions are put after the generated import declarations 279 actions by using Haskell I O actions For instance if we want to implement an external operation to print some string as an output line we start by declaring the external operations in the Curry module String printString String gt 10 O printString s prim_printString s prim_printString String 10 prim_printString external Next we add the corresponding implementation in the file External_String hs where C_IO and OP_Unit are the names of the Haskell representation of the Curry type constructor 10 and the Curry data type respectively external_d_C_prim_printString CP OP_List CP C_Char ConstStore CP C_IO CP OP_Unit external_d_C_prim_printString s _ toCurry putStrLn s Here Haskell s I O action putStrLn of type String gt I0 is transformed into a Curry I O action toCurry putStrLn which has the type CP OP_List CP C_Char CP C_10 CP OP_Unit When we compile the Curry module String KiCS2 combines these definitions in the target program so that we can immediately use the externally defined operation printString in Curry programs As we have seen KiCS2 transforms a name like prim0P of an external operation into the name external_d_C_primOP for the Haskell operation to be implemented i e o
227. nction of arity 7 into a corresponding set function that uses a given strategy to compute its values isEmpty Values a Bool Is a multiset of values empty notEmpty Values a Bool Is a multiset of values not empty valueOf a Values a Bool Is some value an element of a multiset of values choose Values a gt a Values a Chooses non deterministically some value in a multiset of values and returns the chosen value and the remaining multiset of values Thus if we consider the operation chooseValue by 131 chooseValue x fst choose x then set1 chooseValue is the identity on value sets i e set1 chooseValue s contains the same elements as the value set s chooseValue Values a gt a Chooses non deterministically some value in a multiset of values and returns the chosen value Thus seti chooseValue is the identity on value sets i e set1 chooseValue s contains the same elements as the value set s select Values a gt a Values a Selects indeterministically some value in a multiset of values and returns the selected value and the remaining multiset of values Thus select has always at most one value It fails if the value set is empty NOTE The usage of this operation is only safe i e does not destroy completeness if all values in the argument set are identical selectValue Values a gt a Selects indeterministically some value in a multiset of values and returns the
228. nd the base name The directory 99 prefix is if there is no real prefix in the name stripSuffix String String Strips a suffix the last suffix starting with a dot from a file name fileSuffix String String Yields the suffix the last suffix starting with a dot from given file name splitBaseName String gt String String Splits a file name into prefix and suffix the last suffix starting with a dot and the rest splitPath String String Splits a path string into list of directory names lookupFileInPath String String String gt I0 Maybe String Looks up the first file with a possible suffix in a list of directories Returns Nothing if such a file does not exist getFileInPath String gt String String gt I0 String Gets the first file with a possible suffix in a list of directories An error message is delivered if there is no such file 63 A 2 14 Library FilePath This library is a direct port of the Haskell library System FilePath of Neil Mitchell Exported types type FilePath String Exported functions pathSeparator Char pathSeparators String isPathSeparator Char Bool searchPathSeparator Char isSearchPathSeparator Char Bool extSeparator Char isExtSeparator Char Bool splitSearchPath String gt String getSearchPath 10 String splitExtension String gt String String
229. nd visible to subsequent calls to getEnviron but it is not visible in the environment of the process that started the program execution unsetEnviron String gt 10 Removes an environment variable that has been set by setEnviron getHostname 10 String 134 Returns the hostname of the machine running this process getPID 10 Int Returns the process identifier of the current Curry process getProgName 10 String Returns the name of the current program i e the name of the main module currently executed system String IO Int Executes a shell command and return with the exit code of the command An exit status of zero means successful execution exitWith Int gt IO a Terminates the execution of the current Curry program and returns the exit code given by the argument An exit code of zero means successful execution sleep Int gt I0 The evaluation of the action sleep n puts the Curry process asleep for n seconds isPosix Bool Is the underlying operating system a POSIX system unix MacOS isWindows Bool Is the underlying operating system a Windows system A 2 41 Library Time Library for handling date and time information Exported types data ClockTime ClockTime represents a clock time in some internal representation Exported constructors data CalendarTime A calendar time is presented in the following form CalendarTime year month day hour minute second timezone whe
230. ned if there does not exist an associated value newlORef a gt IO IORef a Creates a new IORef with an initial values readIORef I0Ref a gt 10 a Reads the current value of an IORef writelORef I0Ref a gt a gt 10 Updates the value of an IORef modifylORef I0Ref a gt a gt a gt I0 Modify the value of an IORef A 2 24 Library JavaScript A library to represent JavaScript programs Exported types data JSExp Type of JavaScript expressions Exported constructors e JSString String JSExp JSString string constant e JSInt Int JSExp JSInt integer constant e JSBool Bool JSExp JSBool Boolean constant e JSIVar Int JSExp JSIVar indexed variable 92 data JSIArrayldx Int Int JSExp JSIArrayldx array access to index array variable JSOp String JSExp JSExp JSExp JSOp infix operator expression JSFCall String gt JSExp gt JSExp JSFCall function call JSApply JSExp JSExp gt JSExp JSApply function call where the function is an expression JSLambda Int JSStat gt JSExp JSLambda anonymous function with indexed variables as arguments JSStat Type of JavaScript statements Exported constructors JSAssign JSExp JSExp JSStat JSAssign assignment JSIf JSExp gt JSStat gt JSStat gt JSStat JS
231. next line and indents to the current nesting level Document linesep s behaves like text s if the line break is undone by group hardline Doc The document hardline advances to the next line and indents to the current nesting level hardline cannot be undone by group line Doc The document line advances to the next line and indents to the current nesting level Document line behaves like text if the line break is undone by group linebreak Doc The document linebreak advances to the next line and indents to the current nesting level Document linebreak behaves like text if the line break is undone by group softline Doc The document softline behaves like space if the resulting output fits the page oth erwise it behaves like line softline group line softbreak Doc The document softbreak behaves like text if the resulting output fits the page otherwise it behaves like line softbreak group linebreak group Doc gt Doc The combinator group is used to specify alternative layouts The document group x undoes all line breaks in document x The resulting line is added to the current line if that fits the page Otherwise the document x is rendered without any changes nest Int Doc Doc The document nest i d renders document d with the current indentation level in creased by i See also hang align and indent nest 2 text hello text world text I outputs
232. ng files in CSV format Files in CSV comma separated values format can be imported and exported by most spreadsheed and database applications Exported functions writeCSVFile String gt Stringl gt 10 O Writes a list of records where each record is a list of strings into a file in CSV format showCSV String String Shows a list of records where each record is a list of strings as a string in CSV format readCSVFile String gt I0 String Reads a file in CSV format and returns the list of records where each record is a list of strings readCSVFileWithDelims String gt String I0 String Reads a file in CSV format and returns the list of records where each record is a list of strings readCSV String gt String Reads a string in CSV format and returns the list of records where each record is a list of strings readCSVWithDelims String String gt String Reads a string in CSV format and returns the list of records where each record is a list of strings A 2 8 Library Debug This library contains some useful operation for debugging programs Exported functions trace String gt a gt a Prints the first argument as a side effect and behaves as identity on the second argument traceld String String Prints the first argument as a side effect and returns it afterwards traceShow a gt b gt b Prints the first argument using show and retur
233. ng with the first one in the list addToFM_C a a a FM b a b gt a gt Mba Instead of throwing away the old binding addToFM_C combines the new element with the old one addListToFM_C a gt a gt a gt FMba gt b a gt FMba Combine with a list of tuples key element cf addToFM_C delFromFM FM a b gt a gt FMa b Deletes key from finite map Deletion doesn t complain if you try to delete something which isn t there 144 delListFromFM FM a b gt la gt FM ab Deletes a list of keys from finite map Deletion doesn t complain if you try to delete something which isn t there updFM FMab gt a gt b gt b gt Mab Applies a function to element bound to given key splitFM FM a b gt a gt Maybe FM a b a b Combines delFrom and lookup plusFM FM a b gt TFMab gt FMab Efficiently add key element mappings of two maps into a single one Bindings in right argument shadow those in the left plusFMC a gt a gt a gt FMba gt FMba gt FMba Efficiently combine key element mappings of two maps into a single one cf addToFM_C minusFM FM a b gt FMa b gt FMa b minusFM a1 a2 deletes from al any bindings which are bound in a2 intersectFM FM a b gt FMa b gt Mab Filters only those keys that are bound in both of the given maps The elements will be taken from the second map intersectFM_C a gt b c FM d a FM d b gt FMd c Filters
234. ning holes for the WUI and the handler wuiWithErrorForm WuiSpec a gt a a IO HtmlForm HtmlExp WuiHandler IO HtmlForm HtmlExp WuiHandler Generates HTML editors and a handler from a WUI data specification an initial value and an update form In addition to wui2html we can provide a skeleton form used to show illegal inputs A 4 9 Library WUljs A library to support the type oriented construction of Web User Interfaces WUls The ideas behind the application and implementation of WUls are described in a paper that is available via this web page In addition to the original library this version provides also support for JavaScript 188 Exported types type Rendering HtmlExp gt HtmlExp A rendering is a function that combines the visualization of components of a data structure into some HTML expression data WuiHandler A handler for a WUI is an event handler for HTML forms possibly with some specific JavaScript code attached Exported constructors data WuiSpec The type of WUI specifications The first component are parameters specifying the behavior of this WUI type rendering error message and constraints on inputs The second component is a show function returning an HTML expression for the edit fields and a WUI state containing the CgiRefs to extract the values from the edit fields The third component is read function to extract the values from the edit fields
235. nly a specific prefix is added However this is only valid if no special characters occur in the Curry names Otherwise in order to generate a correct Haskell program special characters are translated into specific names prefixed by OP_ For instance if we declare the external operation lt gt Int gt Int gt Int lt gt external the generated Haskell module contains the code d_0P_1t_ampersand_gt Curry_Prelude C_Int Curry_Prelude C_Int gt ConstStore Curry_Prelude C_Int d_0P_1t_ampersand_gt x1 x2 x3500 external_d_0P_1t_ampersand_gt x1 x2 x3500 so that one has to implement the operation external_d_OP_1t_ampersand_gt in Haskell If in doubt one should look into the generated Haskell code about the names and types of the operations to be implemented Finally note that this method to connect functions implemented in Haskell to Curry programs provides the opportunity to connect also operations written in other programming languages to Curry via Haskell s foreign function interface 280 Index lt 106 xxx 71 69 69 28 69 kics2rc 16 69 142 LA amp 149 add 10 browse 11 cd 10 edit 10 eval 10 fork 11 help 9 interface 11 load 9 programs 10 quit 10 reload 9 save 11 set 11 set path 8 show 11 source 11 type 10 usedimports 11 e 18 author 28 cons 28 param 28 return 28 version 28 110 a
236. nnotations are ignored for pretty printing Exported functions ppProg AProg a Doc pretty print a FlatCurry module ppHeader String gt TypeDec1 AFuncDecl a gt Doc pretty print the module header ppExports TypeDecl gt AFuncDecl a gt Doc pretty print the export list ppTypeExport TypeDecl Doc pretty print a type export ppConsExports ConsDecl gt Doc 251 pretty print the export list of constructors ppFuncExports AFuncDecl a gt Doc pretty print the export list of functions ppImports String gt Doc pretty print a list of import statements ppImport String Doc pretty print a single import statement ppOpDecls OpDec1 Doc pretty print a list of operator fixity declarations ppOpDecl OpDecl Doc pretty print a single operator fixity declaration ppFixity Fixity Doc pretty print the associativity keyword ppTypeDecls TypeDecl gt Doc pretty print a list of type declarations ppTypeDecl TypeDecl Doc pretty print a type declaration ppConsDecls ConsDecl Doc pretty print the constructor declarations ppConsDecl ConsDecl Doc pretty print a single constructor ppTypeExp TypeExpr Doc pretty a top level type expression ppTypeExpr Int TypeExpr Doc pretty print a type expression ppTVarIndex Int Doc pretty print a type variable ppFuncDecls AFuncDecl a gt Doc 252 pre
237. not enforced Exported functions permute a gt a Compute any permutation of a list For example 1 2 3 4 may give 1 3 4 2 subset a a Compute any sublist of a list The sublist contains some of the elements of the list in the same order For example 1 2 3 4 may give 1 3 and 1 2 3 gives 1 2 3 1 2 1 3 1 2 3 2 3 or splitSet a gt fal al Split a list into any two sublists For example 1 2 3 4 may give 1 3 4 2 sizedSubset Int gt a gt a Compute any sublist of fixed length of a list Similar to subset but the length of the result is fixed partition a gt a Compute any partition of a list The output is a list of non empty lists such that their concatenation is a permutation of the input list No guarantee is made on the order of the arguments in the output For example 1 2 3 4 may give 4 2 3 1 and 1 2 3 gives 1 2 31 2 3 U1 111 31 20 18111 2 or 13 2 11J A 2 5 Library Constraint Some useful operations for constraint programming Exported functions lt a gt a Bool Less than on ground data terms as a constraint gt a a gt Bool Greater than on ground data terms as a constraint lt a a Bool Less or equal on ground data terms as a constraint 52 gt a a gt Bool Greater or equal on ground data terms as a constraint andC Bool gt Bool Eva
238. not now anything about the operational mechanism of Curry e g needed narrowing non deterministic rewriting the argu ments need to be completely evaluated before the primitive implementation is called This can be easily obtained by the prelude operation that applies an operation to the normal form of the given argument i e this operation evaluates the argument to its normal form before applying the operation to it Thus we define sconc by sconc String String String sconc si s2 prim_sconc s1 s2 prim_sconc String String String prim_sconc external so that it is ensured that the external operation prim_sconc is always called with complete evaluated arguments In order to define the Haskell code implementing prim_sconc one has to satisfy the naming conventions of KiCS2 The KiCS2 compiler generates the following code for the external opera tion prim_sconc note that the generated Haskell code for the module String is stored in the file curry kics2 Curry_String hs There is also a similar prelude operation which evaluates the argument only to head normal form This is a bit more efficient and can be used for unstructured types like Bool 278 d_C_prim_sconc Curry_Prelude OP_List Curry_Prelude C_Char gt Curry_Prelude OP_List Curry_Prelude C_Char gt ConstStore gt Curry_Prelude OP_List Curry_Prelude C_Char d_C_prim_sconc x1 x2 x3500 external_d_C_prim_sconc x1 x2 x3
239. ns 65 dropFileName 66 dropTrailingPathSeparator 66 Dynamic 95 eBool 202 eChar 202 Edge 147 edges 152 eEmpty 202 eFloat 202 eInt 201 element 200 elemFM 146 elemIndex 100 elemIndices 100 elemRBT 156 elemsOf 198 eltsFM 146 Emacs 16 emap 153 emphasize 170 empty 106 107 143 149 154 200 emptyAFCSubst 267 emptyDefaultArray 142 emptyErrorArray 142 emptyFM 144 emptySetRBT 156 emptySubst 161 285 emptyTableRBT 158 emptyVS 141 encapsulated search 7 enclose 114 encloseSep 113 encloseSepSpaced 113 Encoding 197 entity relationship diagrams 42 EntryScroll 85 eOpt 202 eqFM 145 equal 151 equalFilePath 67 equals 117 ERD2Curry 42 erd2curry 42 eRep 202 eRepSeqi 203 eRepSeq2 203 eRepSeq3 204 eRepSeg4 204 eRepSeq5 205 eRepSeg6 205 errorT 97 ES 62 eSeqi 202 eSeq2 203 eSeq3 203 eSeg4 204 eSeq5 205 eSeq6 205 eString 202 evalChildFamilies 159 evalChildFamiliesl0 160 evalCmd 91 evalES 62 evalFamily 159 evalFamilyl0 160 even 87 Event 78 exclusivel0 91 execCmd 91 existsDBKey 98 exitGUI 83 exitWith 135 exp 70 expires 168 Expr 225 extended 60 extendSubst 161 external operation 278 extSeparator 64 factorial 86 failES 62 failT 97 failVS 141 faint 118 family 159 FilePath 64 fileSize 55 fileSuffix 63 fill 117 fillBreak 118 f llCat 112 fillEncloseSep 113 fillEncloseSepSpaced 113 fil
240. ns the second argument afterwards 54 traceShowld a gt a Prints the first argument using show and returns it afterwards tracel0 String gt I0 Output a trace message from the IO monad assert Bool gt String gt a gt a Assert a condition w r t an error message If the condition is not met it fails with the given error message otherwise the third argument is returned assertI0 Bool gt String gt 10 Assert a condition w r t an error message from the 10 monad If the condition is not met it fails with the given error message A 2 9 Library Directory Library for accessing the directory structure of the underlying operating system Exported functions doesFileExist String IO Bool Returns true if the argument is the name of an existing file doesDirectoryExist String 10 Bool Returns true if the argument is the name of an existing directory fileSize String gt 10 Int Returns the size of the file getModificationTime String 10 ClockTime Returns the modification time of the file getCurrentDirectory 10 String Returns the current working directory setCurrentDirectory String gt 10 Sets the current working directory getDirectoryContents String 10 String Returns the list of all entries in a directory createDirectory String gt I0 Creates a new directory with the given name 59 createDirectorylfMissing Bool gt String gt 10
241. nt gt TypeExpr a gt TypeDecl gt a transform type declaration typeName TypeDecl gt String String get name of type declaration typeVisibility TypeDecl Visibility get visibility of type declaration typeParams TypeDecl gt Int get type parameters of type declaration typeConsDecls TypeDecl ConsDec1 get constructor declarations from type declaration typeSyn TypeDecl TypeExpr get synonym of type declaration isTypeSyn TypeDecl Bool is type declaration a type synonym updType String String gt String String gt Visibility Visibility gt Int gt Int gt ConsDec1 gt ConsDecl TypeExpr gt TypeExpr gt TypeDecl TypeDecl update type declaration updTypeName String String gt String String TypeDecl gt TypeDecl 231 update name of type declaration updTypeVisibility Visibility Visibility gt TypeDecl TypeDecl update visibility of type declaration updTypeParams Int Int gt TypeDecl gt TypeDecl update type parameters of type declaration updTypeConsDecls ConsDecl gt ConsDecl TypeDecl TypeDecl update constructor declarations of type declaration updTypeSynonym TypeExpr TypeExpr gt TypeDecl gt TypeDecl update synonym of type declaration updQNamesInType String String String String TypeDecl gt TypeDecl update al
242. nv NotRepeatable NoElem a 200 Takes a value and returns an XML converter for this value which is not represented as XML data Empty XML data must not be used in repetitions and does not represent an XML element attr String gt String gt a a gt String gt XmlConv NotRepeatable NoElem a Takes a name and string conversion functions and returns an XML converter that represents an attribute Attributes must not be used in repetitions and do not represent an XML element adapt a gt b b gt a gt XmlConv c d a gt XmlConv c d b Converts between arbitrary XML converters for different types opt XmlConv a b c gt XmlConv NotRepeatable NoElem Maybe c Creates a converter for arbitrary optional XML data Optional XML data must not be used in repetitions and does not represent an XML element rep XmlConv Repeatable a b XmlConv NotRepeatable NoElem b Takes an XML converter representing repeatable data and returns an XML converter that represents repetitions of this data Repetitions must not be used in other repeti tions and do not represent XML elements alnt String XmlConv NotRepeatable NoElem Int Creates an XML converter for integer attributes Integer attributes must not be used in repetitions and do not represent XML elements aFloat String XmlConv NotRepeatable NoElem Float Creates an XML converter for float attributes Float attributes must not be used in repetitions and do no
243. o check whether a string is a valid identifier OPTIONS_CYMAKE F pgmF currypp optF foreigncode import RegExp isID String Bool isID s s regex a zA Z la zA Z0 9_ x 9 1 2 Format Specifications In order to format numerical and other data as strings one can specify the desired format with foreign code marked by format In this case one can write a format specification similarly to the printf statement of C followed by a comma separated list of arguments This format specification is transformed into operations of the KiCS2 library Format so that it must be imported For instance the following program defines an operation that formats a string an integer with leading sign and zeros and a float with leading sign and precision 3 OPTIONS_CYMAKE F pgmF currypp optF foreigncode import Format showSIF String Int gt Float String showSIF s i f format Name s 5i 6 3f s i f main putStrLn showSIF Curry 42 3 14159 Thus the execution of main will print the line Name Curry 00042 3 142 Instead of format one can also write a format specification with printf In this case the formatted string is printed with putStr Hence we can rewrite our previous definitions as follows showSIF String gt Int gt Float gt 10 showSIF s i f printf Name s 5i 6 3f n s i f 36 main showSIF Curry 4
244. ocument inverse d displays document d with inversed coloring i e use text color of d as background color and background color of d as text color black Doc Doc The document black d displays document d with black text color red Doc Doc The document red d displays document d with red text color green Doc Doc The document green d displays document d with green text color yellow Doc Doc The document yellow d displays document d with yellow text color blue Doc Doc The document blue d displays document d with blue text color magenta Doc Doc The document magenta d displays document d with magenta text color cyan Doc Doc The document cyan d displays document d with cyan text color white Doc Doc The document white d displays document d with white text color bgBlack Doc Doc The document bgBlack d displays document d with black background color bgRed Doc Doc The document bgRed d displays document d with red background color bgGreen Doc Doc 119 The document bgGreen d displays document d with green background color bgYellow Doc Doc The document bgYellow d displays document d with yellow background color bgBlue Doc Doc The document bgBlue d displays document d with blue background color bgMagenta Doc gt Doc The document bgMagenta d displays document d with magenta background color bgCyan Doc gt Doc Th
245. of the web script e g QUERYSTRING REMOTEHOST REMOTE_ADDR cgienv are the values in the current form submitted by the client and nextpage is the answer text to be shown in the next web page Exported constructors e CgiSubmit String String String String CgiServerMsg e GetLoad CgiServerMsg GetLoad 176 get info about the current load of the server process e SketchStatus CgiServerMsg SketchStatus get a sketch of the status of the server e SketchHandlers CgiServerMsg SketchHandlers get a sketch of all event handlers of the server e ShowStatus CgiServerMsg ShowStatus show the status of the server with all event handlers e CleanServer CgiServerMsg CleanServer clean up the server with possible termination e StopCgiServer CgiServerMsg StopCgiServer stop the server Exported functions readCgiServerMsg Handle gt IO Maybe CgiServerMsg Reads a line from a handle and check whether it is a syntactically correct cgi server message submitForm I0 runCgiServerCmd String CgiServerMsg I0 Executes a specific command for a cgi server noHandlerPage String String String cgiServerRegistry String The name of the file to register all cgi servers registerCgiServer String gt String gt 10 unregisterCgiServer String gt I0 177 A 4 4 Library HtmlParser This module contains a very simple p
246. ogram with the KiCS2 compiler If the Curry module M is stored in the directory dir the corresponding Haskell program is stored in the directory dir curry kics2 This is also the case for hierarchical module names if the module D1 D2 M is stored in the directory dir i e the module is actu ally stored in dir D1 D2 M curry then the corresponding Haskell program is stored in dir curry kics2 D1 D2 Curry_prog hs Curry_prog hi This file contains the interface of the Haskell program Curry_prog hs when the latter program is compiled in order to execute it This file is stored in the same directory as Curry_prog hs Curry_prog o This file contains the object code of the Haskell program Curry_prog hs when the latter program is compiled in order to execute it This file is stored in the same directory as Curry_prog hs 276 Curry_prog nda This file contains some information about the determinism behavior of operations that is used by the KiCS2 compiler see 10 for more details about the use of this information This file is stored in the same directory as Curry_prog hs Curry_prog info This file contains some information about the top level functions of module prog that are used by the interactive environment like determinism behavior or IO status This file is stored in the same directory as Curry_prog hs prog This file contains the executable after compiling and saving a program with KiCS2 see command save in S
247. ollowing subsection in more detail The complete set of libraries with all exported types and functions are described in the further subsections For a more detailed online documentation of all libraries of KiCS2 see http www ps informatik uni kiel de kics2 lib index html A 1 AbstractCurry and FlatCurry Meta Programming in Curry To support meta programming i e the manipulation of Curry programs in Curry there are system modules FlatCurry Types Section A 5 6 and AbstractCurry Types Section A 5 1 which define datatypes for the representation of Curry programs AbstractCurry Types is a more direct repre sentation of a Curry program whereas FlatCurry Types is a simplified representation where local function definitions are replaced by global definitions i e lambda lifting has been performed and pattern matching is translated into explicit case or expressions Thus FlatCurry Types can be used for more back end oriented program manipulations or for writing new back ends for Curry whereas AbstractCurry Types is intended for manipulations of programs that are more oriented towards the source program There are predefined I O actions to read AbstractCurry and FlatCurry programs AbstractCurry Files readCurry and FlatCurry Files readFlatCurry These actions parse the corresponding source program and return a data term representing this program according to the definitions in the modules AbstractCurry Types and FlatCurry Types Since
248. on _transaction html gt transactions in SQLite is available online runJustT Transaction a gt IO a Executes a possibly composed transaction on the current state of dynamic predicates as a single transaction Similar to runT but a run time error is raised if the execution of the transaction fails getDB Query a gt Transaction a Lifts a database query to the transaction type such that it can be composed with other transactions Run time errors that occur during the execution of the given query are transformed into transaction errors returnT a Transaction a Returns the given value in a transaction that does not access the database doneT Transaction Returns the unit value in a transaction that does not access the database Useful to ignore results when composing transactions errorT TError gt Transaction a Aborts a transaction with an error failT String Transaction a Aborts a transaction with a user defined error message gt gt Transaction a gt a Transaction b Transaction b Combines two transactions into a single transaction that executes both in sequence The first transaction is executed its result passed to the function which computes the second transaction which is then executed to compute the final result If the first transaction is aborted with an error the second transaction is not executed l gt gt Transaction a gt Transaction b gt Transaction b
249. onName QTypeConstrID ConsLabelName QTypeConstrID module ModuleID ConsLabelName gt n gt 0 ConsLabelName LabellD DataConstr Block ImportDech ImportDecl no fixity declarations here BlockDeclaration BlockDeclaration y k n gt 0 ImportDecl import qualified ModuleID as ModuleID ImportRestr ImportRestr Import Importn n gt 0 hiding Import Import n gt 0 Import FunctionName TypeConstrID ConsLabelName ConsLabelName n gt 0 TypeConstrID BlockDeclaration TypeSynonymDecl DataDeclaration FixityDeclaration FunctionDeclaration TypeSynonymDecl type SimpleType TypeExpr SimpleType TypeConstrID TypeVarID TypeVarlD n gt 0 TypeConstrID see lexicon DataDeclaration data SimpleType external data type data SimpleType ConstrDecl ConstrDecl n gt 0 ConstrDecl DataConstr Simple TypeExpr Simple TypeExpr n gt 0 SimpleTypeExpr ConsOp TypeConsExpr infix data constructor DataConstr4 FieldDeclaration FieldDeclaration y n gt 0 FieldDeclaration LabelID LabelID TypeExpr n gt 0 LabelID see lexicon TypeExpr TypeConsExpr gt TypeExpr TypeConsExpr QTypeConstrID SimpleTypeExpry Simple TypeExpr n gt 0 Simple TypeExpr Simple TypeExpr TypeVarID QTypeConstrID O unit type TypeExpri TypeExpr t
250. one can escape them with a backslash This is a comment without a reference To simplify the writing of documentation comments such escaping is only necessary for single words i e if the text inside quotes has not the syntax of an identifier the escaping can be omitted as in This isn t a reference The following example text shows a Curry program with some documentation comments This is an example module author Michael Hanus version 0 1 module Example where The function conc concatenates two lists param xs the first list param ys the second list return a list containing all elements of xs and ys conc ys ys conc x xs ys X conc xs ys this comment will not be included in the documentation The function last computes the last element of a given list It is based on the operation conc to concatenate two lists param xs the given input list return last element of the input list last xs conc ys x xs x where x ys free This data type defines _polymorphic_ trees cons Leaf a leaf of the tree cons Node an inner node of the tree data Tree a Leaf a Node Tree a To generate the documentation execute the command currydoc Example currydoc is a command usually stored in kics2home bin where kics2home is the installation directory of KiCS2 see Section 1 2 This comman
251. onent types ioType CTypeExpr CTypeExpr Constructs an IO type from a type maybeType CTypeExpr CTypeExpr Constructs a Maybe type from element type stringType CTypeExpr The type expression of the String type intType CTypeExpr The type expression of the Int type floatType CTypeExpr The type expression of the Float type boolType CTypeExpr The type expression of the Bool type unitType CTypeExpr The type expression of the unit type dateType CTypeExpr The type expression of the Time CalendarTime type 216 cfunc String String Int gt CVisibility CTypeExpr gt CRule gt CFuncDecl Constructs a function declaration from a given qualified function name arity visibility type expression and list of defining rules cmtfunc String gt String String Int CVisibility CTypeExpr gt CRule gt CFuncDecl Constructs a function declaration from a given comment qualified function name arity visibility type expression and list of defining rules simpleRule CPattern gt CExpr gt CRule Constructs a simple rule with a pattern list and an unconditional right hand side guardedRule CPattern gt CExpr CExpr CLocalDecl CRule Constructs a rule with a possibly guarded right hand side and local declarations A simple right hand side is constructed if there is only one True condition noGuard CExpr gt CExpr CExpr C
252. onstructs a guarded expression with the trivial guard applyF String String gt CExpr gt CExpr An application of a qualified function name to a list of arguments applyE CExpr gt CExpr gt CExpr An application of an expression to a list of arguments constF String String gt CExpr A constant i e an application without arguments applyV Int String CExpr CExpr An application of a variable to a list of arguments applyJust CExpr CExpr applyMaybe CExpr CExpr CExpr CExpr tupleExpr CExpr gt CExpr Constructs a tuple expression from list of component expressions cBranch CPattern CExpr CPattern CRhs 217 Constructs from a pattern and an expression a branch for a case expression tuplePattern CPattern gt CPattern Constructs a tuple pattern from list of component patterns pVars Int gt CPattern Constructs for given n a list of n PVars starting from 0 pChar Char CPattern Converts a character into a pattern pNil CPattern Constructs an empty list pattern listPattern CPattern gt CPattern Constructs a list pattern from list of component patterns stringPattern String CPattern Converts a string into a pattern representing this string list2ac CExpr CExpr Converts a list of AbstractCurry expressions into an AbstractCurry representation of this list cChar Char CExpr Conver
253. ore one can also view and store the selected module as source code where missing type signatures are added Below the list box for selecting modules there is a menu Analyze selected module to analyze all functions of the currently selected module at once This is useful to spot some functions of a module that could be problematic in some application contexts like functions that are impure i e the result depends on the evaluation time or partially defined i e not evaluable on all ground terms If such an analysis is selected the names of all functions are shown in the lower list box of the left column the function list with prefixes indicating the properties of the individual functions The function list box can be also filled with functions via the menu Select functions For instance all functions or only the exported functions defined in the currently selected module can be shown there or all functions from different modules that are directly or indirectly called from a currently selected function This list box is central to focus on a function in the source code of some module or to analyze some function i e showing their properties In order to focus on a function it is sufficient to check the focus on code button To analyze an individually selected function one can select an analysis from the list of available program analyses through the menu Select analysis In this case the analysis results a
254. orizontally with lt gt if it fits the page or vertically with sep xs group vsep xs hcat Doc Doc The document hcat xs concatenates all documents xs horizontally with lt gt vcat Doc Doc The document vcat xs concatenates all documents xs vertically with lt gt If a group undoes the line breaks inserted by vcat all documents are directly concatenated fillCat Doc Doc The document fillCat xs concatenates documents xs horizontally with lt gt as long as its fits the page than inserts a linebreak and continues doing that for all documents in xs fillCat xs foldr lt gt empty xs cat Doc Doc The document cat xs concatenates all documents xs either horizontally with lt gt if it fits the page or vertically with lt gt cat xs group vcat xs punctuate Doc gt Doc gt Doc punctuate p xs concatenates all documents xs with document p except for the last document someText map text words in a tuple test parens align cat punctuate comma someText This is layed out on a page width of 20 as words in a tuple But when the page width is 15 it is layed out as words in a tuple 112 If you want put the commas in front of their elements instead of at the end you should use tupled or in general encloseSep encloseSep Doc Doc Doc gt Doc Doc The document encloseSe
255. orted so that values can only be created inside this module Exported constructors data Style The data type of possible text styles Exported constructors e Bold Style Bold text in bold font e Italic Style Italic text in italic font e Underline Style Underline underline text 80 Fg Color gt Style Fg foreground color i e color of the text font Bg Color gt Style Bg background color of the text data Color The data type of possible colors Exported constructors Black Color Blue Color Brown Color Cyan Color Gold Color Gray Color Green Color Magenta Color Navy Color Orange Color Pink Color Purple Color Red Color Tomato Color Turquoise Color Violet Color White Color Yellow Color 81 Exported functions row Widget gt Widget Horizontal alignment of widgets col Widget Widget Vertical alignment of widgets matrix Widget Widget Matrix alignment of widgets debugTcl Widget gt I0 Prints the generated Tcl commands of a main widget useful for debugging runPassiveGUI String Widget 10 GuiPort IO action to show a Widget in a new GUI window in passive mode i e ignore all GUI events runGUI String gt Widget gt 10 IO action to run a Widget in a new window runGUIwithParams String gt String Widget 10
256. otation of literals for both numeric literals as well as Char and String literals The precise syntax for both kinds is given below Int Decimal Ob Binary 0B Binary 00 Octal 00 Octal Ox Hexadecimal OX Hexadecimal Float Decimal Decimal Exponent Decimal Exponent Exponent e E Decimal Decimal Digit Decimal Binary Binit Binary Octal Octit Octal Hexadecimal Hexit Hexadecimal Digit 0o 1i 2 3 4 5 6 7 8 9 Bint z O 1 Octit 0 1 2 3 4 5 6 7 Hezit 0 1 2 3 4 5 6 7 8 Jo A B C D E F a b c dl e f Char Graphic Space Escape yy String Graphic y Space Escape Gap 21 Escape CharEsc Ascii Decimal o Octal x Hexadecimal CharEsc a b f n r tiv x gt Ascii Cntrl NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US SP DEL Cntrl AsciiLarge L N 1 7 _ AsctiLarge A Z Gap NX WhiteChar 4 WhiteChar 4 3 Layout Similarly to Haskell a Curry programmer can use layout information to define the structure of blocks For this purpose we define the indentation of a symbol as the column number indicating the start of this symbol The indentation of a line is the indentation of its first symbol The layout or off side rule applies to lists of syntactic entities after the keywor
257. p 1 r s xs concatenates the documents xs seperated by s and encloses the resulting document by 1 and r The documents are rendered hori zontally if that fits the page Otherwise they are aligned vertically All seperators are put in front of the elements For example the combinator list can be defined with encloseSep list xs encloseSep lbracket rbracket comma xs test text list lt gt list map int 10 200 3000 Which is layed out with a page width of 20 as list 10 200 3000 But when the page width is 15 it is layed out as list 10 200 3000 encloseSepSpaced Doc gt Doc gt Doc gt Doc gt Doc The document encloseSepSpaced 1 r s xs concatenates the documents xs seper ated by s and encloses the resulting document by 1 and r In addition after each occurrence of s after 1 and before r a space is inserted The documents are rendered horizontally if that fits the page Otherwise they are aligned vertically All seperators are put in front of the elements hEncloseSep Doc Doc gt Doc gt Doc Doc The document hEncloseSep 1 r s xs concatenates the documents xs seperated by s and encloses the resulting document by 1 and r The documents are rendered horizontally fillEncloseSep Doc gt Doc gt Doc gt Doc gt Doc The document fillEncloseSep 1 r s xs concatenates the documents xs seperated by s and encloses the resulting document by 1 an
258. pFuncDecl Options gt FuncDecl Doc pretty print a function declaration ppRule Options Rule Doc pretty print a function rule ppExp Options Expr Doc Pretty print a top level expression ppExpr Options Int Expr Doc pretty print an expression ppVarIndex Int Doc pretty print a variable ppLiteral Literal Doc pretty print a literal ppComb Options gt Int String String Expr gt Doc Pretty print a constructor or function call ppDecls Options gt Int Expr Doc 244 pretty print a list of declarations ppDecl Options gt Int Expr Doc pretty print a single declaration ppCaseType CaseType gt Doc Pretty print the type of a case expression ppBranch Options gt BranchExpr Doc Pretty print a case branch ppPattern Options gt Pattern Doc Pretty print a pattern ppPrefixQ0p Options String String Doc pretty print a qualified prefix operator ppPrefixOp String String Doc pretty print a prefix operator unqualified ppInfixQOp Options gt String String Doc pretty print an infix operator ppQName Options gt String String Doc Pretty print a qualified name ppName String String gt Doc Pretty print a qualified name unqualified e g for type definitions isInfixOp String String gt Bool Check whether an operator is an infix operator isConsId String S
259. pe to specify the visibility of various entities Exported constructors Public Visibility Private Visibility data TypeDecl 222 Data type for representing definitions of algebraic data types and type synonyms A data type definition of the form data t x1 xn c t1 tkc is represented by the FlatCurry term Type t i1 in Cons c ke t1 tkc where each ij is the index of the type variable xj Note the type variable indices are unique inside each type declaration and are usually numbered from 0 Thus a data type declaration consists of the name of the data type a list of type parameters and a list of constructor declarations Exported constructors e Type String String Visibility gt Int ConsDec1 TypeDecl e TypeSyn String String Visibility Int gt TypeExpr TypeDecl data ConsDecl A constructor declaration consists of the name and arity of the constructor and a list of the argument types of the constructor Exported constructors e Cons String String gt Int Visibility TypeExpr ConsDecl data TypeExpr Data type for type expressions A type expression is either a type variable a function type or a type constructor application Note the names of the predefined type constructors are Int Float Bool Char 10 unit type tuple types lis
260. pes since other types with more alternatives can be easily reduced to this case wTree WuiSpec a gt WuiSpec WTree a WUI for tree types The rendering specifies the rendering of inner nodes Leaves are shown with their default rendering renderTuple HtmlExp gt HtmlExp Standard rendering of tuples as a table with a single row Thus the elements are horizontally aligned renderTaggedTuple String HtmlExp HtmlExp Standard rendering of tuples with a tag for each element Thus each is preceded by a tag that is set in bold and all elements are vertically aligned renderList HtmlExp HtmlExp Standard rendering of lists as a table with a row for each item Thus the elements are vertically aligned mainWUI WuiSpec a gt a gt a gt I0 HtmlForm 10 HtmlForm Generates an HTML form from a WUI data specification an initial value and an update form wui2html WuiSpec a gt a gt a I0 HtmlForm gt HtmlExp WuiHandler Generates HTML editors and a handler from a WUI data specification an initial value and an update form wuilnForm WuiSpec a gt a gt a gt IO HtmlForm gt HtmlExp WuiHandler gt 10 HtmlForm I0 HtmlForm Puts a WUI into a HTML form containing holes for the WUI and the handler wuiWithErrorForm WuiSpec a gt a gt a I0 HtmlForm gt HtmlExp gt WuiHandler gt I0 HtmlForm HtmlExp Wui
261. plicitly required in a FlatCurry program since they might be generated by external functions like or on the fly generateCompactFlatCurryFile Option gt String String gt I0 Computes a single FlatCurry program containing all functions potentially called from a set of main functions and writes it into a FlatCurry file This is done by merging all imported FlatCurry modules and removing the imported functions that are definitely not used computeCompactFlatCurry Option String I0 Prog Computes a single FlatCurry program containing all functions potentially called from a set of main functions This is done by merging all imported FlatCurry modules these are loaded demand driven so that modules that contains no potentially called functions are not loaded and removing the imported functions that are definitely not used 249 A 5 15 Library FlatCurry Annotated Types This library contains a version of FlatCurry s abstract syntax tree which can be annotated with arbitrary information due to a polymorphic type parameter For instance this could be used to annotate function declarations and expressions with their corresponding type For more information about the abstract syntax tree of FlatCurry see the documentation of the respective module Exported types type Arity Int Arity of a function declaration data AProg Annotated FlatCurry program corresponds to a module Export
262. ponent is read function to extract the values from the edit fields for a given cgi environment returned as Just v If the value is not legal Nothing is returned The second component of the result contains an HTML edit expression together with a WUI state to edit the value again Exported constructors data WTree A simple tree structure to demonstrate the construction of WUls for tree types Exported constructors e WLeaf a WTree a e WNode WIree a WTree a Exported functions wuiHandler2button String WuiHandler HtmlExp Transform a WUI handler into a submit button with a given label string withRendering WuiSpec a gt HtmlExp HtmlExp gt WuiSpec a 182 Puts a new rendering function into a WUI specification withError WuiSpec a String WuiSpec a Puts a new error message into a WUI specification withCondition WuiSpec a gt a Bool WuiSpec a Puts a new condition into a WUI specification transformWSpec a gt b b gt a gt WuiSpec a gt WuiSpec b Transforms a WUI specification from one type to another adaptWSpec a gt b WuiSpec a gt WuiSpec b Adapt a WUI specification to a new type For this purpose the first argument must be a transformation mapping values from the old type to the new type This function must be bijective and operationally invertible i e the inverse must be computable by narrowing Otherwise use transfor
263. pureio Use IO references i e memory cells for choice identifiers This is the most efficient implementation for top level depth first search but cannot be used for more sophisticated search methods like encapsulated search ioref default Use a mixture of ghc and pureio IO references are used for top level depth first search and ghc identifiers are used for encapsulated search methods Set the verbosity level to n The following values are allowed for n n 0 Do not show any messages except for errors n 1 Show only messages of the front end like loading of modules n 2 Show also messages of the back end like compilation messages from the Haskell com piler n 3 Show also intermediate messages and commands of the compilation process n 4 Show also all intermediate results of the compilation process prompt p Sets the user prompt which is shown when KiCS2 is waiting for input If the parameter p starts with a letter or a percent sign the prompt is printed as the given parameter where the sequence s is expanded to the list of currently loaded modules and is expanded to a percent sign If the prompt starts with a double quote it is read as a string and therefore also supports the normal escape sequences that can occur in Curry programs The default setting is set prompt s gt interactive Turn on off the interactive mode In the interactive mode the next non
264. r to avoid useless recomputations the code in the module first decorates the declarations with their bound and free names and a unique number The latter is only used to provide a trivial ordering so that the declarations can be used as set elements Exported functions scc a gt b gt a gt b gt a gt fal Computes the strongly connected components of a list of entities To be flexible we distinguish the nodes and the entities defined in this node A 3 8 Library SetRBT Library with an implementation of sets as red black trees All the operations on sets are generic i e one has to provide an explicit order predicate lt less than on elements Exported types type SetRBT a RedBlackTree a 155 Exported functions emptySetRBT a a Bool RedBlackTree a Returns an empty set i e an empty red black tree augmented with an order predicate isEmptySetRBT RedBlackTree a gt Bool Test for an empty set elemRBT a gt RedBlackTree a gt Bool Returns true if an element is contained in a red black tree set insertRBT a gt RedBlackTree a gt RedBlackTree a Inserts an element into a set if it is not already there insertMultiRBT a gt RedBlackTree a gt RedBlackTree a Inserts an element into a multiset Thus the same element can have several occurrences in the multiset deleteRBT a RedBlackTree a RedBlackTree a delete an element from a set Delet
265. rTime gt ClockTime 136 Transforms a calendar time interpreted as UTC time into a clock time calendarTimeToString CalendarTime gt String Transforms a calendar time into a readable form toDayString CalendarTime String Transforms a calendar time into a string containing the day e g September 23 2006 toTimeString CalendarTime String Transforms a calendar time into a string containing the time addSeconds Int ClockTime gt ClockTime Adds seconds to a given time addMinutes Int ClockTime gt ClockTime Adds minutes to a given time addHours Int gt ClockTime ClockTime Adds hours to a given time addDays Int ClockTime ClockTime Adds days to a given time addMonths Int ClockTime ClockTime Adds months to a given time addYears Int ClockTime ClockTime Adds years to a given time daysOfMonth Int Int Int Gets the days of a month in a year validDate Int gt Int Int Bool Is a date consisting of year month day valid compareDate CalendarTime gt CalendarTime gt Ordering Compares two dates don t use it just for backward compatibility compareCalendarTime CalendarTime CalendarTime Ordering Compares two calendar times compareClockTime ClockTime ClockTime Ordering Compares two clock times 137 A 2 42 Library Unsafe Library containing unsafe operations These operations
266. range TypeExpr TypeExpr get range from functional type tConsName TypeExpr gt String String get name from constructed type tConsArgs TypeExpr TypeExpr get arguments from constructed type trTypeExpr Int gt a gt String String gt a gt a gt a gt a gt a gt TypeExpr gt a transform type expression isTVar TypeExpr gt Bool is type expression a type variable isTCons TypeExpr Bool is type declaration a constructed type isFuncType TypeExpr Bool is type declaration a functional type updTVars Int TypeExpr TypeExpr TypeExpr update all type variables updTCons String String TypeExpr TypeExpr TypeExpr TypeExpr 233 update all type constructors updFuncTypes TypeExpr TypeExpr gt TypeExpr TypeExpr TypeExpr update all functional types argTypes TypeExpr gt TypeExpr get argument types from functional type resultType TypeExpr TypeExpr get result type from nested functional type rnmAllVarsInTypeExpr Int Int gt TypeExpr TypeExpr rename variables in type expression updQNamesInTypeExpr String String gt String String TypeExpr gt TypeExpr update all qualified names in type expression trOp String String gt Fixity Int gt a gt OpDecl gt a transform operator declaration opName OpDecl gt String String get name from operator de
267. rary Assertion oos ce aoe ee a eR aS 49 Ads Libia BT ie o ee woes ee Ae Re aa Ad ds e i 50 A 2 4 Library Combinatorial e 52 A 2 0 Library Constraint lt s ss poca smera sa a Eee 52 A20 Libras OPNS z eo Ge hae ag ai a A a ee 53 Aar e he we ee ee eS A EO ee a lee PE we BE 54 AJE Librssy Debe cis disse Me A Gk SG a e a aes 54 2 29 Library Directoy o once Aa he ae eee a ede eee ee Bas 55 210 Library Distrbiblon aose s eraon ed PO ee ee e es 56 Ac Ll Library Either so neat eA A Ae ae da ee ee a aa 61 ALT Libron Emor iG o a eae sima HO ee Ae ee Se ee a eS 61 213 Libtary Filsioodiss lt e ca kk ea ee EEA ee ee a a a 63 A214 Library FilePath 4 arig te aomp a eR Re a a we aa 64 A216 Library Findal oe eo ee ee a os a a ee A G ETS 67 A216 Library Float gt s co oime x orcas rana npo G o i AE A aa a 68 22 17 Library Function p ecc ocea igede a Ge ee we DR Re we DS 70 Als Library ep das rd be a A a 71 A219 Library Global 204404604 a ica eee pa a oS 73 Po ME A wot eee oe Re he ee BO Oe E 74 24 221 Library Integer oc A ERAS REM GS De SA RRA RAO 86 Als labia TO o co He ee ee bE ee EE Oa a a 88 za Library WORSE sg hh ee ek es oe a Pee ea as 90 A3 AA A224 Library JavaSeriph sic a Keg acia we ee Be eS 92 A225 Library Key Databases Lile gt oa scera da pi hee Mae A eS 95 220 Libtary List esos we te RAG a OR eS eR RASS ES 100 A227 Library Maybe s lt ea bos be ee a be we Ee Re e 104 462 2
268. rder String a gt ArgOrder a data OptDescr Exported constructors e Option String String ArgDescr a String gt OptDescr a data ArgDescr Exported constructors e NoArg a ArgDescr a e RegArg String gt a gt String ArgDescr a e OptArg Maybe String gt a gt String ArgDescr a Exported functions usageInfo String OptDescr a gt String getOpt ArgOrder a gt OptDescr a String a String String getOpt ArgOrder a gt OptDescr a String gt lal String String String 72 A 2 19 Library Global Library for handling global entities A global entity has a name declared in the program Its value can be accessed and modified by IO actions Furthermore global entities can be declared as persistent so that their values are stored across different program executions Currently it is still experimental so that its interface might be slightly changed in the future A global entity g with an initial value v of type t must be declared by g Global t g global v spec Here the type t must not contain type variables and spec specifies the storage mechanism for the global entity see type GlobalSpec Exported types data Global The abstract type of a global entity Exported constructors data GlobalSpec The storage mechanism for the global entity Exported constructors e Temporary GlobalSpec Tempor
269. rding to an equivalence relation delete a gt a gt a Deletes the first occurrence of an element in a list deleteBy a gt a Bool gt a gt a gt al Deletes the first occurrence of an element in a list according to an equivalence relation AV a gt a gt La Computes the difference of two lists union a gt a gt a Computes the union of two lists unionBy a gt a gt Bool gt a gt a gt a 100 Computes the union of two lists according to the given equivalence relation intersect a gt al gt al Computes the intersection of two lists intersectBy a gt a gt Bool gt a gt a gt a Computes the intersection of two lists according to the given equivalence relation intersperse a gt a gt a Puts a separator element between all elements in a list Example intersperse 9 1 2 3 4 1 9 2 9 3 9 4 intercalate a gt a gt a intercalate xs xss is equivalent to concat intersperse xs xss It inserts the list xs in between the lists in xss and concatenates the result transpose a gt a Transposes the rows and columns of the argument Example transpose 1 2 3 4 5 6 1 4 2 5 3 6 permutations a gt a Returns the list of all permutations of the argument partition a gt Bool gt a gt a a Partitions a list into a pair of lists where the first list cont
270. re either shown in the text box below the main text area or visualized by separate tools e g by a graph drawing tool for visualizing call graphs Some 1 Although CurryBrowser is implemented in Curry some functionalities of it require an installed graph visualization tool dot http www graphviz org otherwise they have no effect 31 Browser Version of 22 05 2006 one ssa Select module and imports Show source Show selected module as Tools File Settings Read an existing FlatCurry file w r t current load path readFlatCurryFileInLoadPath prt mod do mbfilename lt findFileInLoadPath mod fcy maybe error FlatCurry file mod fcy not found readFlatCurryFile ndReport prt mod mbfilename Imports readFlatCurryFileAndReport prt mod filename do size lt fileSize filename prt Reading FlatCurry file of module mod show size bytes prog lt readFlatCurryFile filename seq prog prog return prog Finds the first file with a possible suffix in the load path findFileInLoadPath String gt String gt IO Maybe String findFileInLoadPath file suffixes do loadpath lt getLocalLoadPath N findFileInPath file suffixes loadpath Analyze selected module computes real load path in case of non local first program argument getLocalLoadPath do Select functions Y focus in code loadpath lt getLoadPath args lt get rgs if null args
271. re timezone is an integer representing the timezone as a difference to UTC time in seconds Exported constructors e CalendarTime Int gt Int gt Int gt Int gt Int gt Int Int CalendarTime 135 Exported functions ctYear CalendarTime Int The year of a calendar time ctMonth CalendarTime gt Int The month of a calendar time ctDay CalendarTime Int The day of a calendar time ctHour CalendarTime Int The hour of a calendar time ctMin CalendarTime Int The minute of a calendar time ctSec CalendarTime Int The second of a calendar time ctTZ CalendarTime Int The time zone of a calendar time The value of the time zone is the difference to UTC time in seconds getClockTime I0 ClockTime Returns the current clock time getLocalTime I0 CalendarTime Returns the local calendar time clockTimeToInt ClockTime Int Transforms a clock time into a unique integer It is ensured that clock times that differs in at least one second are mapped into different integers toCalendarTime ClockTime 10 CalendarTime Transforms a clock time into a calendar time according to the local time if possible Since the result depends on the local environment it is an I O operation toUTCTime ClockTime gt CalendarTime Transforms a clock time into a standard UTC calendar time Thus this operationa is independent on the local time toClockTime Calenda
272. ream communication with the client The handle is both readable and writable 133 waitForSocketAccept Socket Int I0 Maybe String Handle Waits until a connection of a client to a socket is available If no connection is available within the time limit it returns Nothing otherwise the connection is returned as a pair consisting of a string identifying the client the format of this string is implementation dependent and a handle to a stream communication with the client sClose Socket gt I0 Closes a server socket connectToSocket String Int I0 Handle Creates a new connection to a Unix socket A 2 40 Library System Library to access parts of the system environment Exported functions getCPUTime 10 Int Returns the current cpu time of the process in milliseconds getElapsedTime IO Int Returns the current elapsed time of the process in milliseconds This operation is not supported in KiCS2 there it always returns 0 but only included for compatibility reasons getArgs IO String Returns the list of the program s command line arguments The program name is not included getEnviron String IO String Returns the value of an environment variable The empty string is returned for unde fined environment variables setEnviron String gt String gt 10 Set an environment variable to a value The new value will be passed to subsequent shell commands see system a
273. receives a message containing the environment of the client s web browser translates the HTML form w r t this environment into a string representation of the complete HTML doc ument and sends the string representation back to the client s browser by binding the corresponding message argument runFormServerWithKeyAndFormParams String gt String gt FormParam gt 10 HtmlForm gt I0 The server implementing an HTML form possibly containing input fields It receives a message containing the environment of the client s web browser translates the HTML form w r t this environment into a string representation of the complete HTML doc ument and sends the string representation back to the client s browser by binding the corresponding message argument showLatexExps HtmlExp gt String Transforms HTML expressions into LaTeX string representation showLatexExp HtmlExp String Transforms an HTML expression into LaTeX string representation htmlSpecialChars2tex String String Convert special HTML characters into their LaTeX representation if necessary showLatexDoc HtmlExp gt String Transforms HTML expressions into a string representation of a complete LaTeX docu ment showLatexDocWithPackages HtmlExp String gt String 175 Transforms HTML expressions into a string representation of a complete LaTeX doc ument The variable packages holds the packages to add to the
274. resenting a sequence of arbitrary XML data The se quence must not be used in repetitions and does not represent an XML element repSeq4 a b c d gt e gt XmlConv Repeatable f a gt XmlConv Repeatable g b XmlConv Repeatable h c gt XmlConv Repeatable i d gt XmlConv NotRepeatable NoElem e Creates an XML converter that represents a repetition of a sequence of repeatable XML data The repetition may be used in other repetitions and does not represent an XML element This combinator is provided because converters for repeatable sequences cannot be constructed by the seq combinators eSeq4 String gt la gt b c gt d gt e gt XmlConv f g a gt XmlConv h i b gt XmlConv j k c XmlConv 1md XmlConv Repeatable Elem e Creates an XML converter for compound values represented as an XML element with children that correspond to the values components The element can be used in repe titions eRepSeq4 String gt a gt b gt c gt d e XmlConv Repeatable f a XmlConv Repeatable g b XmlConv Repeatable h c XmlConv Repeatable i d gt XmlConv Repeatable Elem e Creates an XML converter for repetitions of sequences represented as an XML element that can be used in repetitions seg5 a gt b gt c d e f gt XmlConv g ha gt XmlConv i j b gt XmlConv k 1 c XmlConv m n d gt XmlConv o p e XmlConv NotRepeatable NoElem f Creates an X
275. riables This function is only mean ingful when applied to parts of a result of an encapsulated expression if the argument stems from a Value node of a SearchTree varld a gt Int Returns the unique identifier of a free variable if the argument was not a free variable otherwise an error is raised This function is only meaningful when applied to a part of a result of an encapsulated expression if the argument stems from a Value node of a Search Tree getSearchTree a gt I0 SearchTree a Returns the search tree for some expression someSearchTree a SearchTree a Internal operation to return the search tree for some expression Note that this operation is not purely declarative since the ordering in the resulting search tree depends on the ordering of the program rules isDefined a Bool Returns True iff the argument is is defined i e has a value showSearchTree SearchTree a String Shows the search tree as an intended line structure searchTreeSize SearchTree a gt Int Int Int Return the size number of Value Fail Or nodes of the search tree allValuesDFS SearchTree a gt la Return all values in a search tree via depth first search dfsStrategy SearchTree a ValueSequence a allValuesBFS SearchTree a gt la Return all values in a search tree via breadth first search bfsStrategy SearchTree a ValueSequence a allValuesIDS SearchTree a gt la Return all values in a search
276. ring String Transforms a path to a module name into a file name by adding the currySubDir to the path and transforming a hierarchical module name into a path For instance inCurrySubdir mylib Data Char evaluates to mylib curry Data Char inCurrySubdirModule String String String Transforms a file name by adding the currySubDir to the file name This version respects hierarchical module names addCurrySubdir String String Transforms a directory name into the name of the corresponding sub directory contain ing auxiliary files getLoadPathForModule String I0 String Returns the current path list of directory names that is used for loading modules w r t 2 a given module path The directory prefix of the module path or if there is no such prefix is the first element of the load path and the remaining elements are determined by the environment variable CURRYRPATH and the entry libraries of the system s rc file lookupModuleSourceInLoadPath String I0 Maybe String String Returns a directory name and the actual source file name for a module by looking up the module source in the current load path If the module is hierarchical the directory is the top directory of the hierarchy Returns Nothing if there is no corresponding source file defaultParams FrontendParams The default parameters of the front end rcParams 10 FrontendParams The default parameters of the f
277. rity 8 wCons8 la lt b gt c gt d gt e gt gt g gt h gt i gt WuiSpec a gt WuiSpec b gt WuiSpec c WuiSpec d WuiSpec e WuiSpec f WuiSpec g WuiSpec h gt WuiSpec i WUI combinator for constructors of arity 8 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types wCons8JS Maybe JSExp gt JSExp gt a gt b gt c gt d gt e gt f f gt 8g gt h gt i gt WuiSpec a WuiSpec b WuiSpec c WuiSpec d WuiSpec e WuiSpec f gt WuiSpec g WuiSpec h gt WuiSpec i 193 w9Tuple WuiSpec a WuiSpec b WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f gt WuiSpec g gt WuiSpec h gt WuiSpec i gt WuiSpec a b c d e f g h i WUI combinator for tuples of arity 9 wCons9 la gt b gt c gt d gt e gt f gt g gt h gt i gt j WuiSpec a gt WuiSpec b gt WuiSpec c gt WuiSpec d WuiSpec e gt WuiSpec f WuiSpec g WuiSpec h gt WuiSpec i WuiSpec j WUI combinator for constructors of arity 9 The first argument is the ternary construc tor The further arguments are the WUI specifications for the argument types wCons9JS Maybe JSExp JSExp gt a gt b gt c gt d gt e gt f gt g gt h gt i gt j gt WuiSpec a gt WuiSpec b WuiSpec c gt WuiSpec d gt WuiSpec e WuiSpec f WuiSpec g WuiSp
278. rkdownInputAsPDF I0 Format the standard input containing markdown text as PDF formatMarkdownFileAsPDF String gt 10 Format a file containing markdown text as PDF A 4 7 Library URL Library for dealing with URLs Uniform Resource Locators Exported functions getContentsOfUrl String 10 String Reads the contents of a document located by a URL This action requires that the program weet is in your path otherwise the implementation must be adapted to the local installation 181 A 4 8 Library WUI A library to support the type oriented construction of Web User Interfaces WUIs The ideas behind the application and implementation of WUls are described in a paper that is available via this web page Exported types type Rendering HtmlExp gt HtmlExp A rendering is a function that combines the visualization of components of a data structure into some HTML expression data WuiHandler A handler for a WUI is an event handler for HTML forms possibly with some specific code attached for future extensions Exported constructors data WuiSpec The type of WUI specifications The first component are parameters specifying the behavior of this WUI type rendering error message and constraints on inputs The second component is a show function returning an HTML expression for the edit fields and a WUI state containing the CgiRefs to extract the values from the edit fields The third com
279. rn the handle of the connection This action waits possibly forever until the socket with the symbolic name is registered connectToSocket String IO Handle Creates a new connection to an existing Unix socket with a symbolic name If the symbolic name is not registered an error is reported A 2 29 Library Parser Library with functional logic parser combinators Adapted from Rafael Caballero and Francisco J Lopez Fraguas A Functional Logic Perspective of Parsing In Proc FLOPS 99 Springer LNCS 1722 pp 85 99 1999 Exported types type Parser a a gt a type ParserRep a b a gt b gt b Exported functions lt I gt Glal gt a gt a gt a gt a gt a Combines two parsers without representation in an alternative manner lt Il gt a 5 b gt b gt a gt b b 5 a gt b gt b Combines two parsers with representation in an alternative manner lt gt a gt a gt a gt a gt a gt a Combines two parsers with or without representation in a sequential manner gt gt gt a gt a gt b gt b gt a gt a Attaches a representation to a parser without representation empty a gt a The empty parser which recognizes the empty word terminal a gt a gt a A parser recognizing a particular terminal symbol 106 satisfy a gt Bool gt a gt a gt la A
280. rned or if the user cancels the selection chooseColor IO String Pops up a GUI dialog box to select a color The name of the color will be returned or 9999 if the user cancels the selection A 2 21 Library Integer A collection of common operations on integer numbers Most operations make no assumption on the precision of integers Operation bitNot is necessarily an exception Exported functions Int gt Int gt Int The value of a b is a raised to the power of b Fails if b amp 1t 0 Executes in O log b steps pow Int gt Int gt Int The value of pow a b is a raised to the power of b Fails if b amp 1t 0 Executes in O log b steps ilog Int gt Int The value of ilog n is the floor of the logarithm in the base 10 of n Fails if n amp 1t 0 For positive integers the returned value is 1 less the number of digits in the decimal representation of n isqrt Int Int The value of isqrt n is the floor of the square root of n Fails if n amp 1t 0 Executes in O log n steps but there must be a better way factorial Int gt Int The value of factorial n is the factorial of n Fails ifn amp 1t 0 86 binomial Int gt Int gt Int The value of binomial n mis n n 1 n m 1 m m 1 1 Fails if m lt 0 or n lt m abs Int gt Int The value of abs n is the absolute value of n max3 a gt a gt a gt a Returns the maximum of the three
281. rocess stdin input stream The exit code of the process and the contents written to the standard I O streams stdout and stderr are returned connectToCommand String IO Handle Executes a command with a new default shell process The input and output streams of the new process is returned as one handle which is both readable and writable Thus writing to the handle produces input to the process and output from the process can be retrieved by reading from this handle The handle should be closed with 10 hClose since they are not closed automatically when the process terminates readCompleteFile String 10 String An action that reads the complete contents of a file and returns it This action can be used instead of the lazy readFile action if the contents of the file might be changed updateFile String gt String gt String gt 10 An action that updates the contents of a file exclusivel0 String gt IO a gt IO a Forces the exclusive execution of an action via a lock file For instance exclusivelO myaction lock act ensures that the action act is not executed by two processes on the same system at the same time setAssoc String String gt I0 Defines a global association between two strings Both arguments must be evaluable to ground terms before applying this operation 91 getAssoc String gt I0 Maybe String Gets the value associated to a string Nothing is retur
282. rom values into strings to be shown in the selection widget wSelectInt Int gt WuiSpec Int A widget to select a value from a given list of integers provided as the argument The current value should be contained in the value list and is preselected wSelectBool String String WuiSpec Bool A widget to select a Boolean value via a selection box The arguments are the strings that are shown for the values True and False in the selection box respectively wCheckBool HtmlExp gt WuiSpec Bool A widget to select a Boolean value via a check box The first argument are HTML expressions that are shown after the check box The result is True if the box is checked wMultiCheckSelect a gt HtmlExp a gt WuiSpec a A widget to select a list of values from a given list of values via check boxes The current values should be contained in the value list and are preselected The first argument is a mapping from values into HTML expressions that are shown for each item after the check box wRadioSelect a HtmlExp gt a gt WuiSpec a A widget to select a value from a given list of values via a radio button The current value should be contained in the value list and is preselected The first argument is a mapping from values into HTML expressions that are shown for each item after the radio button wRadioBool HtmlExp gt HtmlExp WuiSpec Bool A widget to select a Boolea
283. ront end as configured by the compiler specific resource configuration file setQuiet Bool gt FrontendParams gt FrontendParams Set quiet mode of the front end 59 setExtended Bool gt FrontendParams FrontendParams Set extended mode of the front end setOverlapWarn Bool FrontendParams FrontendParams Set overlap warn mode of the front end setFullPath String FrontendParams FrontendParams Set the full path of the front end If this parameter is set the front end searches all modules in this path instead of using the default path setHtmlDir String FrontendParams FrontendParams Set the htmldir parameter of the front end Relevant for HTML generation setLogfile String FrontendParams FrontendParams Set the logfile parameter of the front end If this parameter is set all messages produced by the front end are stored in this file setSpecials String FrontendParams FrontendParams Set additional specials parameters of the front end These parameters are specific for the current front end and should be used with care since their form might change in the future quiet FrontendParams Bool Returns the value of the quiet parameter extended FrontendParams Bool Returns the value of the extended parameter overlapWarn FrontendParams Bool Returns the value of the overlapWarn parameter fullPath FrontendParams M
284. rst argument is the condition a constraint For instance the rule equal2 x x 2 True is represented as Rule 0 Comb FuncCall Prelude cond Comb FuncCall Prelude Var 0 Lit Intc 2 Comb FuncCall Prelude True Exported constructors e Var Int Expr Var variable represented by unique index e Lit Literal Expr Lit literal Int Float Char constant 226 data Comb CombType gt String String Expr Expr Comb application f el en of function constructor f with n lt arity f Let Int Expr Expr Expr Let introduction of local variables via recursive let declarations Free Int Expr Expr Free introduction of free local variables Or Expr Expr Expr Or disjunction of two expressions used to translate rules with overlapping left hand sides Case CaseType gt Expr gt BranchExpr Expr Case case distinction rigid or flex Typed Expr TypeExpr Expr Typed typed expression to represent an expression with a type declaration BranchExpr Data type for representing branches in a case expression Branches m c x1 xn gt e in case expressions are represented as Branch Pattern m c il in e where each ij is the index of the pattern variable xj or as Branch LPattern Intc i e for integers as branch patterns similarly for
285. s 219 setIndentWith Int Options Options Sets the indentation width of the pretty printer options setQualification Qualification Options Options Sets the qualification method to be used by the pretty printer setModName String Options Options Sets the name of the current module in the pretty printer options setLayoutChoice LayoutChoice Options Options Sets the preferred layout in the pretty printer options showCProg CurryProg String Shows a pretty formatted version of an abstract Curry Program The options for pretty printing are the defaultOptions prettyCurryProg Options CurryProg String pretty print the document generated by ppCurryProg using the page width specified by given options ppCurryProg Options CurryProg Doc pretty print a CurryProg the representation of a program written in curry using AbstractCurry according to given options This function will overwrite the module name given by options with the name encapsulated in CurryProg ppMName String Doc pretty print a module name just a string ppExports Options CTypeDecl gt CFuncDecl gt Doc pretty print exports i e all type and function declarations which are public extract the type and function declarations which are public and gather their qualified names in a list ppImports Options String gt Doc pretty print imports list of module nam
286. s are fully evaluated in order to satisfy the constraint Functional patterns can help to improve this computational behavior A functional pattern is a function call at a pattern position With functional patterns we can define the operation last as follows last _ y y This definition is not only more compact but also avoids the complete evaluation of the list elements since a functional pattern is considered as an abbreviation for the set of constructor terms obtained by all evaluations of the functional pattern to normal form see 1 for an exact definition the previous definition is conceptually equivalent to the set of rules last y y last _ y y last _ _ y y which shows that the evaluation of the list elements is not demanded by the functional pattern In general a pattern of the form f t tn n gt 0 is interpreted as a functional pattern if f is not a visible constructor but a defined function that is visible in the scope of the pattern It is also possible to combine functional patterns with as patterns Similarly to the meaning of as patterns in standard constructor patterns as patterns in functional patterns are interpreted as a sequence of pattern matching where the variable of the as pattern is matched before the given pattern is matched This process can be described by introducing an auxiliary operation for this two level pattern matching process For instance the definition 18 f _ x 42 _
287. s executed provided that it is still newer than the script file itself otherwise it will be recompiled This feature combines easy scripting with Curry together with fast execution Al 11 ERD2Curry A Tool to Generate Programs from ER Specifi cations ERD2Curry is a tool to generate Curry code to access and manipulate data persistently stored from entity relationship diagrams The idea of this tool is described in detail in 8 Thus we describe only the basic steps to use this tool in the following If one creates an entity relationship diagram ERD with the Umbrello UML Modeller one has to store its XML description in XMI format as offered by Umbrello in a file e g myerd xmi This description can be compiled into a Curry program by the command erd2curry x myerd xmi erd2curry is a program stored in kics2home bin where kics2home is the installation directory of KiCS2 see Section 1 2 If MyData is the name of the ERD the Curry program file MyData curry is generated containing all the necessary database access code as described in 8 In addition to the generated Curry program file two auxiliary program files ERDGeneric curry and KeyDatabase curry are created in the same directory If one does not want to use the Umbrello UML Modeller which might be the preferred method since the interface to the Umbrello UML Modeller is no longer actively supported one can also create a textual description of the ERD as a Curry t
288. s into global functions with additional arguments lambda lifting see Appendix D of the Curry language report Thus in the various run time systems the definition of functions with local declarations look different from their original definition in order to see the result of this transformation you can use the Curry Browser see Section 7 e Tabulator stops instead of blank spaces in source files are interpreted as stops at columns 9 17 25 33 and so on In general tabulator stops should be avoided in source programs e Encapsulated search The general definition of encapsulated search of the Curry report 19 is not supported Thus the corresponding prelude operations like try solveA11 once findall or best are not defined in the KiCS2 prelude However KiCS2 supports appropriate alterna tives to encapsulate non deterministic computations Strong encapsulation This means that all potential non determinism is encapsulated Since this might result in dependencies on the evaluation strategy see 7 for a de tailed discussion this kind of encapsulation is only available as I O operations For instance the library Al1Solutions Section A 2 1 defines the operation getAllValues a I0 a to compute all values of a given argument expression There is also the library SearchTree Section A 2 37 which supports user programmable search strategies and contains some predefined strategies like depth first breadth first i
289. sControl Char Bool Returns true if the argument is a control character isUpper Char Bool Returns true if the argument is an uppercase letter isLower Char Bool Returns true if the argument is an lowercase letter isAlpha Char Bool Returns true if the argument is a letter isDigit Char Bool Returns true if the argument is a decimal digit isAlphaNum Char Bool Returns true if the argument is a letter or digit isBinDigit Char Bool Returns true if the argument is a binary digit isOctDigit Char Bool Returns true if the argument is an octal digit isHexDigit Char Bool Returns true if the argument is a hexadecimal digit isSpace Char Bool Returns true if the argument is a white space toUpper Char Char Converts lowercase into uppercase letters toLower Char Char Converts uppercase into lowercase letters digitToInt Char gt Int Converts a hexadecimal digit character into an integer intToDigit Int Char Converts an integer into a hexadecimal digit character 5l A 2 4 Library Combinatorial A collection of common non deterministic and or combinatorial operations Many operations are intended to operate on sets The representation of these sets is not hidden rather sets are repre sented as lists Ideally these lists contains no duplicate elements and the order of their elements cannot be observed In practice these conditions are
290. save quit MyProgram RTS p RTS additional arguments ghci Turn on off the ghci mode In the ghci mode the initial goal is send to the interactive version of the Glasgow Haskell Compiler This might result in a slower execution but in a faster startup time since the linker to create the main executable is not used safe Turn on the safe execution mode In the safe execution mode the initial goal is not allowed to be of type IO and the program should not import the module Unsafe Furthermore the allowed commands are eval load quit and reload This mode is useful to use KiCS2 in uncontrolled environments like a computation service in a web page where KiCS2 could be invoked by kics2 set safe parser opts Define additional options passed to the KiCS2 front end i e the parser program kics2home bin cymake For instance setting the option set parser F pgmF transcurry has the effect that each Curry module to be compiled is transformed by the preprocessor command transcurry into a new Curry program which is actually compiled cmp opts Define additional options passed to the KiCS2 compiler For instance setting the option set cmp 0 0 has the effect that all optimizations performed by the KiCS2 compiler are turned off ghc opts Define additional options passed to the Glasgow Haskell Compiler GHC when the generated Haskell programs are compiled
291. should be carefully used e g for testing or debugging These operations should not be used in application programs Exported functions unsafePerformi0 IO a gt a Performs and hides an I O action in a computation use with care trace String gt a gt a Prints the first argument as a side effect and behaves as identity on the second argument A 2 43 Library UnsafeSearchTree This library defines a representation of a search space as a tree and various search strategies on this tree This module implements strong encapsulation as discussed in this paper Warning In contrast to the SearchTree Module free variables that are not bound in the encap sulated expression remain free This may lead to non determinism if such an escaped variable is bound later via pattern matching Exported types type Strategy a SearchTree a ValueSequence a data SearchTree A search tree is a value a failure or a choice between two search trees Exported constructors e Value a gt SearchTree a e Fail Int SearchTree a e Or SearchTree a gt SearchTree a gt SearchTree a Exported functions isVar a gt Bool Tests whether the argument is a free variable This function is only meaningful when applied to a part of a result of an encapsulated expression if the argument stems from a Value node of a Search Tree identicalVars a gt a gt Bool 138 Tests whether both arguments are identical free va
292. since the ordering in the resulting search tree depends on the ordering of the program rules isDefined a Bool Returns True iff the argument is defined i e has a value showSearchTree SearchTree a String Shows the search tree as an intended line structure searchTreeSize SearchTree a gt Int Int Int Return the size number of Value Fail Or nodes of the search tree dfsStrategy SearchTree a ValueSequence a Depth first search strategy bfsStrategy SearchTree a ValueSequence a Breadth first search strategy idsStrategy SearchTree a ValueSequence a 127 Iterative deepening search strategy idsStrategyWith Int gt Int gt Int SearchTree a ValueSequence a Parameterized iterative deepening search strategy The first argument is the initial depth bound and the second argument is a function to increase the depth in each iteration diagStrategy SearchTree a ValueSequence a Diagonalization search strategy allValuesWith SearchTree a gt ValueSequence a SearchTree a gt a Return all values in a search tree via some given search strategy allValuesDFS SearchTree a gt la Return all values in a search tree via depth first search allValuesBFS SearchTree a gt la Return all values in a search tree via breadth first search allValuesIDS SearchTree a gt la Return all values in a search tree via iterative deepening search allValuesIDSwith
293. space x lt gt y x lt gt space lt gt y dot Doc The document dot contains a single dot 116 backslash Doc The document backslash contains a back slash equals Doc The document equals contains an equal sign larrow Doc The document larrow contains a left arrow sign lt rarrow Doc The document rarrow contains a right arrow sign gt doubleArrow Doc The document doubleArrow contains an double arrow sign gt doubleColon Doc The document doubleColon contains a double colon sign bar Doc The document bar contains a vertical bar sign at Doc The document at contains an at sign tilde Doc The document tilde contains a tilde sign fill Int Doc Doc The document fi11 i d renders document d It than appends spaces until the width is equal to i If the width of d is already larger nothing is appended This combinator is quite useful in practice to output a list of bindings The following example demonstrates this types empty Doc nest Int gt Doc gt Doc linebreak Doc ptype name tp fill 6 text name lt gt text lt gt text tp test text let lt gt align vcat map ptype types 117 Which is layed out as let empty Doc nest Int gt Doc gt Doc linebreak Doc Note that fill is not guaranteed to be linear time bounded since it has to compute the width of
294. ssion missingCombArgs AExpr a Int get number of missing arguments if expression is combined letBinds AExpr a gt Int a AExpr a get indices of variables in let declaration letBody AExpr a AExpr a get body of let declaration freeVars AExpr a gt Int get variable indices from declaration of free variables freeExpr AExpr a AExpr a get expression from declaration of free variables orExps AExpr a AExpr a get expressions from or expression caseType AExpr a CaseType get case type of case expression caseExpr AExpr a AExpr a get scrutinee of case expression caseBranches AExpr a ABranchExpr a isVar AExpr a Bool is expression a variable isLit AExpr a Bool 263 is expression a literal expression isComb AExpr a gt Bool is expression combined isLet AExpr a gt Bool is expression a let expression isFree AExpr a gt Bool is expression a declaration of free variables isOr AExpr a gt Bool is expression an or expression isCase AExpr a Bool is expression a case expression trExpr a gt Int gt b gt a gt Literal gt b gt a gt CombType gt String String a gt b gt b gt a gt Int a b gt b gt b gt a gt Int a gt b gt b gt a gt b gt b gt b gt a gt CaseType gt b gt c gt b gt APattern a gt b gt c gt a gt b gt TypeExpr gt
295. ssout 119 CRule 209 CStatement 211 ctDay 136 ctHour 136 ctMin 136 ctMonth 136 ctSec 136 ctTZ 136 ctvar 218 CTVarIName 206 ctYear 136 CTypeDecl 207 CTypeExpr 208 currentModule 242 Curry mode 16 Curry preprocessor 35 curryCompiler 57 curryCompilerMajorVersion 57 curryCompilerMinorVersion 57 CurryDoc 28 currydoc 29 CURRYPATH 8 CurryProg 207 curryRuntime 57 curryRuntimeMajorVersion 58 curryRuntimeMinorVersion 58 currySubdir 59 284 Curry Test 33 currytest 33 cvar 218 CVarIName 206 CVisibility 206 cyan 119 cycle 103 cyclic structure 18 cymake 276 database programming 42 dateType 216 daysOfMonth 137 debugTcl 82 Decomp 148 defaultEncoding 167 defaultOptions 219 243 defaultParams 59 defaultRequired 249 deg 151 deg 152 delEdge 149 delEdges 150 delete 100 155 deleteBy 100 deleteDBEntries 99 deleteDBEntry 99 deleteRBT 156 158 delFromFM 144 delListFromFM 145 delNode 149 delNodes 150 deqHead 143 deqInit 143 deqLast 143 deqLength 143 deqReverse 143 deqTail 143 deqToList 143 dfs 12 dfsStrategy 127 139 diagStrategy 128 digitTolnt 51 dirName 63 dlist 171 Doc 107 documentation comment 28 documentation generator 28 doesDirectoryExist 55 doesFileExist 55 domain 233 258 doneT 97 dot 116 doubleArrow 117 doubleColon 117 dquote 116 dquotes 115 dropDrive 65 dropExtension 65 dropExtensio
296. st Exported types data Assertion Datatype for defining test cases Exported constructors data ProtocolMsg The messages sent to the test GUI Used by the currytest tool Exported constructors e TestModule String ProtocolMsg e TestCase String Bool ProtocolMsg e TestFinished ProtocolMsg e TestCompileError ProtocolMsg Exported functions assertTrue String gt Bool Assertion assertTrue s b asserts with name s that b must be true assertEqual String gt a a Assertion a assertEqual s el e2 asserts with name s that el and e2 must be equal w r t assertValues String gt a a Assertion a assertValues s e vs asserts with name s that vs is the multiset of all values of e All values of e are compared with the elements in vs w r t assertSolutions String a Bool gt a Assertion a assertSolutions s c vs asserts with name s that constraint abstraction c has the multiset of solutions vs The solutions of c are compared with the elements in vs Writ assertIO String IO a gt a Assertion a assertlI0 s a r asserts with name s that I O action a yields the result value r assertEquall0 String IO a gt IO a gt Assertion a 49 assertEqualIO s al a2 asserts with name s that I O actions al and a2 yield equal w r t results seqStrActions IO String Bool IO String Bool
297. t String Returns the imports module names of a given curry program functions CurryProg gt CFuncDecl Returns the function declarations of a given curry program constructors CurryProg CConsDec1 Returns all constructors of given curry program types CurryProg CTypeDecl Returns the type declarations of a given curry program publicFuncNames CurryProg String String Returns the names of all visible functions in given curry program publicConsNames CurryProg String String Returns the names of all visible constructors in given curry program publicTypeNames CurryProg String String Returns the names of all visible types in given curry program 213 typeName CTypeDecl gt String String Returns the name of a given type declaration typeVis CTypeDecl gt CVisibility Returns the visibility of a given type declaration typeCons CTypeDecl gt CConsDec1 Returns the constructors of a given type declaration consName CConsDecl gt String String Returns the name of a given constructor declaration consVis CConsDecl CVisibility Returns the visibility of a given constructor declaration isBaseType CTypeExpr Bool Returns true if the type expression is a base type isPolyType CTypeExpr Bool Returns true if the type expression contains type variables isFunctionalType CTypeExpr Bool Returns true if the type expression is a function
298. t popupMessage String gt I0 A simple popup message 84 Cmd GuiPort IO gt ConfItem A simple event handler that can be associated to a widget The event handler takes a GUI port as parameter in order to read or write values from into the GUI Command GuiPort IO Reconfigureltem gt ConfItem An event handler that can be associated to a widget The event handler takes a GUI port as parameter in order to read or write values from into the GUI and returns a list of widget reference configuration pairs which is applied after the handler in order to configure some GUI widgets Button GuiPort I0 gt ConfItem Widget A button with an associated event handler which is activated if the button is pressed ConfigButton GuiPort I0 Reconfigureltem gt ConfItem Widget A button with an associated event handler which is activated if the button is pressed The event handler is a configuration handler see Command that allows the configura tion of some widgets TextEditScroll ConfItem Widget A text edit widget with vertical and horizontal scrollbars The argument contains the configuration options for the text edit widget ListBoxScroll Confltem Widget A list box widget with vertical and horizontal scrollbars The argument contains the configuration options for the list box widget CanvasScroll Confltem Widget A canvas widget with v
299. t node Decomp a b Maybe b Int Int a b Int Graph a b a decomposition with a maybe context UDecomp a Maybe Int Int Int a Unlabeled decomposition Path Int Unlabeled path LPath a Int a Labeled path UPath Int Quasi unlabeled path UGr Graph O a graph without any labels Graph The type variables of Graph are nodeLabel and edgeLabel The internal representation of Graph is hidden Exported constructors 148 Exported functions amp C Ga Int 1 Int b a Int gt Graph b a gt Graph ba amp takes a node context and a Graph and yields a new graph The according key idea is detailed at the beginning nl is the type of the node labels and el the edge labels Note that it is an error to induce a context for a node already contained in the graph matchAny Graph a b gt b Int Int a b Int Graph a b decompose a graph into the Context for an arbitrarily chosen Node and the remaining Graph In order to use graphs as abstract data structures we also need means to decompose a graph This decompostion should work as much like pattern matching as possible The normal matching is done by the function matchAny which takes a graph and yields a graph decompostion According to the main idea matchAny amp should be an identity empty Graph a b An empty Graph mkGraph Int a gt Int Int b Graph a b Create a Graph from the list of
300. t also be exported As an example consider the following program that can be used to test some list processing functions import List import Assertion testi assertEqual 1 2 3 4 1 2 3 4 test2 assertTrue all all lt 5 1 2 3 4 test3 assertSolutions prefix lx gt xt _ 1 2 LEJ 1 1 213 For instance test1 asserts that the result of evaluating the expression 1 2 3 4 is equal to 1 2 3 4 We can execute a test suite by the command currytest TestList currytest is a program stored in kics2home bin where kics2home is the installation directory of KiCS2 see Section 1 2 In our example TestList curry is the program containing the definition of all assertions This has the effect that all exported top level functions of type Assertion are 33 o A BE Test cases 38 Failures fod Status jtesting Run test Add test module Clear test modules Exit Failed test cases Modules to be tested testCombinatorial testDynamic testInteger testList gt testSort y Compilation messages Test protocol ae malit Loading module testDynamic OK PIETA Exported top level test functions ES testl test2 test3 test4 test5 test6 test test8 test9 test10 OK bitand ae Fite Loading module testInteger OK bitx Exported top level test functions OK an testPow testIlog testIsqrt testAbs testFactorial testBinomia OK Loading module testList
301. t represent XML elements aChar String XmlConv NotRepeatable NoElem Char Creates an XML converter for character attributes Character attributes must not be used in repetitions and do not represent XML elements aString String XmlConv NotRepeatable NoElem String Creates an XML converter for string attributes String attributes must not be used in repetitions and do not represent XML elements aBool String gt String String XmlConv NotRepeatable NoElem Bool Creates an XML converter for boolean attributes Boolean attributes must not be used in repetitions and do not represent XML elements eInt String XmlConv Repeatable Elem Int 201 Creates an XML converter for integer elements Integer elements may be used in repe titions eFloat String XmlConv Repeatable Elem Float Creates an XML converter for float elements Float elements may be used in repetitions eChar String XmlConv Repeatable Elem Char Creates an XML converter for character elements Character elements may be used in repetitions eString String XmlConv Repeatable Elem String Creates an XML converter for string elements String elements may be used in repeti tions eBool String String XmlConv Repeatable Elem Bool Creates an XML converter for boolean elements Boolean elements may be used in repetitions eEmpty String gt a XmlConv Repeatable Elem a pty 8 P Takes a name and a valu
302. t the run time option T when this operation is used This can be done by the kics2 command set rts T garbageCollector0ff 10 O Turns off the garbage collector of the run time system if possible This could be useful to get more precise data of memory usage garbageCollectorOn 10 Turns on the garbage collector of the run time system if possible garbageCollect I0 121 Invoke the garbage collector if possible This could be useful before run time critical operations showMemInfo ProcessInfo Int String Get a human readable version of the memory situation from the process infos printMemInfo I0 Print a human readable version of the current memory situation of the Curry process profileTime IO a gt IO a Print the time needed to execute a given IO action profileTimeNF a gt I0 Evaluates the argument to normal form and print the time needed for this evaluation profileSpace IO a gt IO a Print the time and space needed to execute a given IO action During the executation the garbage collector is turned off to get the total space usage profileSpaceNF a gt 10 Evaluates the argument to normal form and print the time and space needed for this evaluation During the evaluation the garbage collector is turned off to get the total space usage A 2 32 Library Prolog A library defining a representation for Prolog programs together with a simple pretty printer It does
303. t type Exported constructors e TVar Int TypeExpr e FuncType TypeExpr TypeExpr TypeExpr e TCons String String TypeExpr TypeExpr data OpDecl 223 Data type for operator declarations An operator declaration fix p n in Curry corre sponds to the FlatCurry term Op n fix p Exported constructors e Op String String gt Fixity gt Int gt OpDecl data Fixity Data types for the different choices for the fixity of an operator Exported constructors e InfixOp Fixity e InfixlOp Fixity e InfixrOp Fixity data FuncDecl Data type for representing function declarations A function declaration in FlatCurry is a term of the form Func name k type Rule i1 ik e and represents the function name with definition name type name xi xk e where each ij is the index of the variable xj Note the variable indices are unique inside each function declaration and are usually numbered from 0 External functions are represented as Func name arity type External s where s is the external name associated to this function Thus a function declaration consists of the name arity type and rule Exported constructors e Func String String gt Int Visibility TypeExpr Rule FuncDecl data Rule 224 A rule is either a list of formal parameters together with an expression or an External tag Exported constructors e Rule Int
304. tabase based on the SQLite database engine In order to use it you need to have sqlite3 in your PATH environment variable or adjust the value of the constant path lt code gt to lt code gt sqlite3 Programs that use the KeyDatabase module can be adjusted to use this module instead by re placing the imports of Dynamic Database and KeyDatabase with this module and changing the declarations of database predicates to use the function persistentSQLite instead of dynamic or persistent This module redefines the types Dynamic Query and Transaction and although both implementations can be used in the same program by importing modules qualified they cannot be mixed Compared with the interface of KeyDatabase this module lacks definitions for index sortByIndex groupByIndex and runTNA and adds the functions deleteDBEntries and closeDBHandles Exported types type Key Int type KeyPred a Int gt a gt Dynamic data Query Queries can read but not write to the database Exported constructors data Transaction Transactions can modify the database and are executed atomically Exported constructors data Dynamic Result type of database predicates Exported constructors data ColVal Abstract type for value restrictions Exported constructors 95 data TError The type of errors that might occur during a transaction Exported constructors data TError TErrorKind String TError TErrorKind The v
305. ted functions stdin Handle Standard input stream stdout Handle Standard output stream stderr Handle Standard error stream openFile String IOMode gt IO Handle Opens a file in specified mode and returns a handle to it 88 hClose Handle gt 10 Closes a file handle and flushes the buffer in case of output file hFlush Handle gt 10 Flushes the buffer associated to handle in case of output file hIsEOF Handle 10 Bool Is handle at end of file isEOF 10 Bool Is standard input at end of file hSeek Handle gt SeekMode gt Int gt 10 Set the position of a handle to a seekable stream e g a file Tf the second argument is AbsoluteSeek SeekFromEnd or RelativeSeek the position is set relative to the beginning of the file to the end of the file or to the current position respectively hWaitForInput Handle Int 10 Bool Waits until input is available on the given handle If no input is available within t milliseconds it returns False otherwise it returns True hWaitForInputs Handle gt Int gt IO Int Waits until input is available on some of the given handles If no input is available within t milliseconds it returns 1 otherwise it returns the index of the corresponding handle with the available data hWaitForInputOrMsg Handle la IO Either Handle a Waits until input is available on a given handles or a message in the message stream
306. terative deepening search Weak encapsulation This means that only the non determinism defined inside an encap sulation operator is encapsulated Conceptually these operators are offered as set func tions 2 which compute the set of all results but do not encapsulate non determinism in the actual arguments See the library SetFunctions Section A 2 38 for more details e Concurrent computations based on the suspension of expressions containing free variables are not yet supported KiCS2 supports value generators for free variables so that a free variable is instantiated when its value is demanded For instance the initial expression x True where x free is non deterministically evaluated to False and True by instantiating x to False and True respectively Thus a computation is never suspended due to free variables This behavior also applies to free variables of primitive types like integers For instance the initial expression x y 1 where x y free is non deterministically evaluated to the two solutions tx 1 y 1 True x 1 y 1 True e Unification is performed without an occur check e There is currently no general connection to external constraint solvers 1 4 Modules in KiCS2 KiCS2 searches for imported modules in various directories By default imported modules are searched in the directory of the main program and the system module directory kics2home 1ib This search path can be extended by settin
307. th and the name of the main module If there is no interface file but a FlatCurry file suffix fey the FlatCurry file is read instead of the interface A 5 11 Library FlatCurry Show This library contains operations to transform FlatCurry programs into string representations either in a FlatCurry format or in a Curry like syntax This library contains e show functions for a string representation of FlatCurry programs showFlatProg showFlatType showFlatFunc e functions for showing FlatCurry type expressions in almost Curry syntax showCurryType showCurryExpr Exported functions showFlatProg Prog String Shows a FlatCurry program term as a string with some pretty printing showFlatType TypeDecl gt String 246 showFlatFunc FuncDecl String showCurryType String String String Bool TypeExpr String Shows a FlatCurry type in Curry syntax showCurryExpr String String String Bool gt Int gt Expr String Shows a FlatCurry expressions in almost Curry syntax showCurryVar a String showCurryld String String Shows an identifier in Curry form Thus operators are enclosed in brackets A 5 12 Library FlatCurry XML This library contains functions to convert FlatCurry programs into corresponding XML expressions and vice versa This can be used to store Curry programs in a way independent of a Curry system or to use a Curry system like
308. tmlForm 164 HtmlHandler 163 htmlIsoUmlauts 174 HtmlPage 166 htmlQuote 174 htmlSpecialChars2tex 175 htxt 169 htxts 169 hWaitForInput 89 hWaitForInputOrMsg 89 hWaitForInputs 89 hWaitForInputsOrMsg 89 i2f 69 identicalVars 138 idOfCgiRef 167 ids 12 idsStrategy 127 139 idsStrategyWith 128 140 ilog 86 image 172 imageButton 172 imports 213 inCurrySubdir 59 inCurrySubdirModule 59 indeg 151 288 indeg 152 indent 109 245 254 indentWidth 242 inferExpr 269 inferFunction 269 inferFunctionEnv 269 inferNewFunctions 269 inferProg 269 inferProgEnv 269 inferProgFromProgEnv 269 init 102 inits 102 inline 172 inn 151 inn 152 insEdge 149 insEdges 150 insertBy 102 insertMultiRBT 156 insertRBT 156 insNode 149 insNodes 149 installation global 6 local 6 installDir 58 int 115 200 integer 12 interactive 10 interactive 13 intercalate 101 intersect 101 intersectBy 101 intersectFM 145 intersectFM_C 145 intersectRBT 156 intersperse 101 intForm 176 intFormMain 176 intToDigit 51 intType 216 inverse 119 IOMode 88 IORef 91 ioref 13 ioType 216 isAbsolute 63 67 isAlpha 51 isAlphaNum 51 isAscii 50 isAsciiLower 50 isAsciiUpper 51 isBaseType 214 isBigComment 271 isBinDigit 51 isCase 239 264 isCode 271 isComb 238 264 isCombTypeConsCall 237 262 isCombTypeConsPartCall 237 262 isCombTypeFuncCall 237 262 isCombTypeFun
309. to count the number of code lines in a Curry program by removing all blank and comment lines and counting the remaining lines usr bin env runcurry import Char isSpace import System getArgs count number of program lines in a file countCLines String 10 Int countCLines f readFile f gt gt return length filter not isEmptyLine map stripSpaces lines where stripSpaces reverse dropWhile isSpace reverse dropWhile isSpace isEmptyLine True isEmptyLine _ False isEmptyLine c1 c2 _ cl amp amp c2 The main program reads Curry file names from arguments main do args lt getArgs mapI0_ f do ls lt countCLines f putStrLn Stripped lines of file f show 1s args If this script is stored in the executable file codelines sh we can count the code lines of the file Prog curry by the shell command gt codelines sh Prog curry When this command is executed the command runcurry compiles the program and evaluates the expression main Since the compilation might take some time in more complex scripts one can also save the result of the compilation in a binary file To obtain this behavior one has to insert the line jit in the script file e g in the second line With this option a binary of the compiled program is saved in the same directory as the script Now when the same script is executed the next time the stored binary file i
310. tricted subset of the markdown syntax recognized by this implementation is documented in this page Exported types type MarkdownDoc MarkdownElem A markdown document is a list of markdown elements data MarkdownElem The data type for representing the different elements occurring in a markdown docu ment Exported constructors e Text String MarkdownElem Text s a simple text in a markdown document e Emph String MarkdownElem Emph s an emphasized text in a markdown document e Strong String MarkdownElem Strong s a strongly emphaszed text in a markdown document e Code String MarkdownElem Code s a code string in a markdown document 179 e HRef String String MarkdownElem HRef s u a reference to URL u with text s in a markdown document e Par MarkdownElem MarkdownElem Par md a paragraph in a markdown document e CodeBlock String MarkdownElem CodeBlock s a code block in a markdown document e UList MarkdownElem MarkdownElem UList mds an unordered list in a markdown document e OList MarkdownElem MarkdownElem OList mds an ordered list in a markdown document e Quote MarkdownElem gt MarkdownElem Quote md a quoted paragraph in a markdown document e HRule MarkdownElem HRule a hoirzontal rule in a markdown document e Header Int String MarkdownElem
311. tring CVisibility gt Int String CConsDec1 gt CTypeDecl e CTypeSyn String String gt CVisibility gt Int String CTypeExpr gt CTypeDecl e CNewType String String CVisibility gt Int String CConsDecl gt CTypeDecl data CConsDecl 207 A constructor declaration consists of the name of the constructor and a list of the argument types of the constructor The arity equals the number of types Exported constructors e CCons String String CVisibility CTypeExpr CConsDecl e CRecord String String CVisibility gt CFieldDec1 gt CConsDecl data CFieldDecl A record field declaration consists of the name of the the label the visibility and its corresponding type Exported constructors e CField String String gt CVisibility CTypeExpr gt CFieldDecl data CTypeExpr Type expression A type expression is either a type variable a function type or a type constructor application Note the names of the predefined type constructors are Int Float Bool Char 10 unit type tuple types list type Exported constructors e CTVar Int String CTypeExpr e CFuncType CTypeExpr CTypeExpr CTypeExpr e CTCons String String gt CTypeExpr CTypeExpr data COpDecl Data type for operator declarations An operator declaration fix p n
312. tring gt Bool Check whether an identifier represents the list constructor isListId String String Bool Check whether an identifier represents a list isTupleld String String Bool Check whether an identifier represents a tuple indent Options Doc gt Doc Indentation 245 A 5 10 Library FlatCurry Read This library defines operations to read a FlatCurry programs or interfaces together with all its imported modules in the current load path Exported functions readFlatCurryWithImports String gt I0 Prog Reads a FlatCurry program together with all its imported modules The argument is the name of the main module possibly with a directory prefix readFlatCurryWithImportsInPath String String gt 10 Prog Reads a FlatCurry program together with all its imported modules in a given load path The arguments are a load path and the name of the main module readFlatCurryIntWithImports String I0 Prog Reads a FlatCurry interface together with all its imported module interfaces The argument is the name of the main module possibly with a directory prefix If there is no interface file but a FlatCurry file suffix fcy the FlatCurry file is read instead of the interface readFlatCurryIntWithImportsInPath String String gt 10 Prog Reads a FlatCurry interface together with all its imported module interfaces in a given load path The arguments are a load pa
313. tring String gt Doc pretty print a type QName non qualified 221 A 5 6 Library FlatCurry Types This library supports meta programming i e the manipulation of Curry programs in Curry For this purpose the library contains definitions of data types for the representation of so called FlatCurry programs Exported types type type type data QName String String The data type for representing qualified names In FlatCurry all names are qualified to avoid name clashes The first component is the module name and the second component the unqualified name as it occurs in the source program TVarIndex Int The data type for representing type variables They are represented by TVar i where i is a type variable index VarIndex Int Data type for representing object variables Object variables occurring in expressions are represented by Var i where i is a variable index Prog Data type for representing a Curry module in the intermediate form A value of this data type has the form Prog modname imports typedecls functions opdecls where modname is the name of this module imports is the list of modules names that are imported and typedecls functions and opdecls are the list of data type function and operator declarations contained in this module respectively Exported constructors data Prog String String TypeDecl FuncDec1 OpDec1 Prog Visibility Data ty
314. tructor amp however is not a constructor in the sense of abstract data type but more basically a defined constructing funtion A context is a node together withe the edges to and from this node into the nodes in the graph g For examples of how to use this library cf the module GraphAlgorithms Exported types type Node Int Nodes and edges themselves in contrast to their labels are coded as integers For both of them there are variants as labeled unlabelwd and quasi unlabeled labeled with Unlabeled node type LNode a Int a Labeled node type UNode Int Quasi unlabeled node type Edge Int Int Unlabeled edge type LEdge a Int Int a Labeled edge type UEdge Int Int Quasi unlabeled edge 147 type type type type type type type type type type type data Context a b b Int Int a b Int The context of a node is the node itself along with label and its adjacent nodes Thus a context is a quadrupel for node n it is of the form edges to n node n n s label edges from n MContext a b Maybe b Int Int a b Int maybe context Context a b b Int a b Int context with edges and node label only without the node identifier itself UContext Int Int Int Unlabeled context GDecomp a b b Int Int a b Int Graph a b A graph decompostion is a context for a node n and the remaining graph without tha
315. tructor arguments are the title the parameters and the contents body of the web page Exported constructors e HtmlPage String PageParam gt HtmlExp HtmlPage data PageParam The possible parameters of an HTML page Exported constructors e PageEnc String PageParam PageEnc the encoding scheme of this page e PageCSS String PageParam PageCsSS s a URL for a CSS file for this page 166 e PageJScript String PageParam PageJScript s a URL for a Javascript file for this page e PageMeta String String PageParam PageMeta as meta information in form of attributes for this page e PageLink String String PageParam PageLink as link information in form of attributes for this page e PageBodyAttr String String PageParam PageBodyAttr attr optional attribute for the body element of the page more than one occurrence is allowed Exported functions defaultEncoding String The default encoding used in generated web pages idOfCgiRef CgiRef String Internal identifier of a CgiRef intended only for internal use in other libraries formEnc String FormParam An encoding scheme for a HTML form formCSS String FormParam A URL for a CSS file for a HTML form formMetaInfo String String FormParam Meta information for a HTML form The argument is a list of attributes included in the meta tag in the
316. ts a character into an AbstractCurry expression string2ac String CExpr Converts a string into an AbstractCurry represention of this string toVar Int gt CExpr Converts an index i into a variable named xi cvar String CExpr Converts a string into a variable with index 1 cpvar String gt CPattern Converts a string into a pattern variable with index 1 ctvar String CTypeExpr Converts a string into a type variable with index 1 218 A 5 5 Library AbstractCurry Pretty Pretty printing of AbstractCurry This library provides a pretty printer for AbstractCurry modules Exported types data Qualification Exported constructors e Full Qualification e Imports Qualification e OnDemand Qualification e None Qualification data LayoutChoice Exported constructors e PreferNestedLayout LayoutChoice e PreferFilledLayout LayoutChoice data Options Exported constructors Exported functions defaultOptions Options defaultOptions options 78 2 Imports Therefore use these options only with functions like prettyCurryProg or ppCurryProg because they will overwrite the module name anyway Also avoid setting on demand qualification because no informa tion about related modules is given options Int gt Int gt Qualification gt String CurryProg Options setPageWith Int Options Options Sets the page width of the pretty printer option
317. ts of their bindings they must be introduced by a where free declaration For instance one can write not b where b free in order to obtain the following bindings and results b False True b True False Without these declarations an error is reported in order to avoid the unintended introduction of free variables in initial expressions by typos If the free variables in the initial goal are of a polymorphic type as in the expression xs t ys z where xs ys z free they are specialized to the type O since the current implementation of KiCS2 does not support computations with polymorphic logic variables eval expr Same as expr This command might be useful when putting commands as arguments when invoking kics2 quit Exit the system There are also a number of further commands that are often useful type expr Show the type of the expression expr programs Show the list of all Curry programs that are available in the load path cd dir Change the current working directory to dir edit Load the source code of the current main module into a text editor If the variable e editcommand is set in the configuration file kics2rc see Section 2 7 its value is used as an editor command otherwise the environment variable EDITOR is used as the editor program edit m Load the source text of module m which must
318. tty print a list of function declarations ppFuncDecl AFuncDecl a Doc pretty print a function declaration ppRule ARule a Doc pretty print a function rule ppExp AExpr a Doc pretty print a top level expression ppExpr Int AExpr a Doc pretty print an expression ppAVarIndex Int a gt Doc pretty print an annotated variable ppVarIndex Int Doc pretty print a variable ppLiteral Literal Doc pretty print a literal showEscape Char String Escape character literal ppComb Int gt String String a AExpr b gt Doc Pretty print a constructor or function call ppDecls Int a AExpr b Doc pretty print a list of declarations ppDecl Int a AExpr b Doc pretty print a single declaration ppCaseType CaseType Doc Pretty print the type of a case expression ppBranch ABranchExpr a Doc Pretty print a case branch ppPattern APattern a Doc 253 Pretty print a pattern ppPrefixOp String String gt Doc pretty print a prefix operator ppInfixOp String String Doc pretty print an infix operator ppQName String String gt Doc Pretty print a qualified name isInfixOp String String gt Bool Check whether an operator is an infix operator isListld String String gt Bool Check whether an identifier represents a list isTupleld String String Bool Check whether an identifier represents a tuple indent Doc gt
319. turns a pseudorandom sequence of values between 0 inclusive and the specified value exclusive 153 nextBoolean Int gt Bool Returns a pseudorandom sequence of boolean values getRandomSeed IO Int Returns a time dependent integer number as a seed for really random numbers Should only be used as a seed for pseudorandom number sequence and not as a random number since the precision is limited to milliseconds A 3 6 Library RedBlackTree Library with an implementation of red black trees Serves as the base for both TableRBT and SetRBT All the operations on trees are generic i e one has to provide two explicit order predicates lessThan and eq below on elements Exported types data RedBlackTree A red black tree consists of a tree structure and three order predicates These predicates generalize the red black tree They define 1 equality when inserting into the tree eg for a set eqInsert is for a multiset it is gt False for a lookUp table it is fst 2 equality for looking up values eg for a set eqLookUp is for a multiset it is for a lookUp table it is fst 3 the less than relation for the binary search tree Exported constructors Exported functions empty a gt a Bool a a gt Bool gt a gt a Bool gt RedBlackTree a The three relations are inserted into the structure by function empty Returns an empty tree i e an empty r
320. type for possible configurations of widget collections e g columns rows Exported constructors e CenterAlign ConfCollection CenterAlign centered alignment e LeftAlign ConfCollection LeftAlign left alignment e RightAlign ConfCollection RightAlign right alignment e TopAlign ConfCollection TopAlign top alignment e BottomAlign ConfCollection BottomAlign bottom alignment data Menultem The data type for specifying items in a menu Exported constructors e MButton GuiPort gt IO Reconfigureltem String Menultem MButton a button with an associated command and a label string e MSeparator Menultem MSeparator a separator between menu entries 79 e MMenuButton String Menultem Menultem MMenuButton a submenu with a label string data Canvasltem The data type of items in a canvas The last argument are further options in Tcl Tk for testing Exported constructors e CLine Int Int String gt CanvasItem e CPolygon Int Int gt String gt CanvasItem e CRectangle Int Int gt Int Int gt String gt CanvasItem e COval Int Int gt Int Int gt String gt CanvasItem e CText Int Int gt String gt String gt CanvasItem data WidgetRef The hidden data type of references to a widget in a GUI window Note that the constructor WRefLabel will not be exp
321. ude compare leqCharIgnoreCase Char Char Bool Less or equal on characters ignoring case considerations legString String String Bool Less or equal on strings deprecated use Prelude lt lt code gt lt lt code gt cmpString String String Ordering Comparison of strings deprecated use Prelude compare leqStringIgnoreCase String String Bool Less or equal on strings ignoring case considerations leqLexGerman String String Bool Lexicographical ordering on German strings Thus upper lowercase are not distin guished and Umlauts are sorted as vocals A 3 10 Library TableRBT Library with an implementation of tables as red black trees A table is a finite mapping from keys to values All the operations on tables are generic i e one has to provide an explicit order predicate cmp below on elements Each inner node in the red black tree contains a key value association 157 Exported types type TableRBT a b RedBlackTree a b Exported functions emptyTableRBT a a Bool gt RedBlackTree a b Returns an empty table i e an empty red black tree isEmptyTable RedBlackTree a b gt Bool tests whether a given table is empty lookupRBT a RedBlackTree a b Maybe b Looks up an entry in a table updateRBT a gt b RedBlackTree a b gt RedBlackTree a b Inserts or updates an element in a table tableRBT2list RedB
322. uence of values failVS Int gt ValueSequence a Adds a failure to a sequence of values The argument is the encapsulation level of the failure ValueSequence a gt ValueSequence a gt ValueSequence a Concatenates two sequences of values vsToList ValueSequence a la Transforms a sequence of values into a list of values A 3 Data Structures and Algorithms A 3 1 Library Array Implementation of Arrays with Braun Trees Conceptually Braun trees are always infinite Con sequently there is no test on emptiness Exported types data Array Exported constructors 141 Exported functions emptyErrorArray Array a Creates an empty array which generates errors for non initialized indexes emptyDefaultArray Int gt a gt Array a Creates an empty array call given function for non initialized indexes Array a gt Int a gt Array a Inserts a list of entries into an array update Array a gt Int gt a Array a Inserts a new entry into an array applyAt Array a gt Int gt a gt a gt Array a Applies a function to an element Array a gt Int gt a Yields the value at a given position listToDefaultArray Int gt a gt la Array a Creates a default array from a list of entries listToErrorArray a gt Array a Creates an error array from a list of entries combine a gt b gt c gt Array a gt Array b
323. ues Values a gt I0 Prints all elements of a multiset of values sortValues Values a gt la Transforms a multiset of values into a list sorted by the standard term ordering As a consequence the multiset of values is completely evaluated sortValuesBy a gt a Bool Values a gt a Transforms a multiset of values into a list sorted by a given ordering on the values As a consequence the multiset of values is completely evaluated In order to ensure that the result of this operation is independent of the evaluation order the given ordering must be a total order A 2 39 Library Socket Library to support network programming with sockets In standard applications the server side uses the operations listenOn and socketAccept to provide some service on a socket and the client side uses the operation connectToSocket to request a service Exported types data Socket The abstract type of sockets Exported constructors Exported functions listenOn Int I0 Socket Creates a server side socket bound to a given port number listenOnFresh IO Int Socket Creates a server side socket bound to a free port The port number and the socket is returned socketAccept Socket I0 String Handle Returns a connection of a client to a socket The connection is returned as a pair consisting of a string identifying the client the format of this string is implementation dependent and a handle to a st
324. uple type n gt 1 TypeExpr list type TypeExpr parenthesized type 23 Type VarID FirityDeclaration FixityKeyword InfirOpID FunctionDeclaration External Signature FunctionNames Equat FunLHS CondExprs Pattern ConsPattern SimplePat FieldPat QLabelID LocalDefs ValueDeclaration PatternDeclaration Expr see lexicon FixityKeyword Digit InfixOpID InfizOpID n gt 0 infixl infixr infix see lexicon Signature External Equat FunctionNames external externally defined functions FunctionNames TypeExpr FunctionName FunctionName n gt 0 FunLHS Expr where LocalDefs FunLHS CondExprs where LocalDefs FunctionName SimplePat SimplePat n gt 0 SimplePat InficOpID SimplePat InfixExpr Expr CondExprs ConsPattern QConsOp Pattern infix constructor pattern GDataConstr SimplePat SimplePat constructor pattern SimplePat Variable wildcard QDataConstr Literal Int negative pattern Float negative float pattern O empty tuple pattern Pattern Pattern n gt 1 Pattern Pattern Pattern 1 Variable SimplePat SimplePat SimplePat QFunOp SimplePat gt QFunctionName SimplePat QDataConstr FieldPati parenthesized pattern n gt 0 as pattern irrefutable pattern infix functional pattern SimplePat functional pattern n gt
325. v Repeatable j c XmlConv Repeatable k d gt XmlConv Repeatable 1 e gt XmlConv Repeatable m f gt XmlConv Repeatable Elem g Creates an XML converter for repetitions of sequences represented as an XML element that can be used in repetitions 205 A 5 Libraries for Meta Programming A 5 1 Library AbstractCurry Types This library contains a definition for representing Curry programs in Curry and an I O action to read Curry programs and transform them into this abstract representation Note this defines a slightly new format for AbstractCurry in comparison to the first proposal of 2003 Assumption an abstract Curry program is stored in file with extension acy Exported types type MName String A module name type QName String String The data type for representing qualified names In AbstractCurry all names are qual ified to avoid name clashes The first component is the module name and the second component the unqualified name as it occurs in the source program An exception are locally defined names where the module name is the empty string to avoid name clashes with a globally defined name type CTVarIName Int String The type for representing type variables They are represented by i n where i is a type variable index which is unique inside a function and n is a name if possible the name written in the source program type CField a String String a Labeled record fields type Arity Int Fun
326. wise is returned checkedbox CgiRef String HtmlExp A checkbox that is initially checked with a reference and a value The value is returned is returned if checkbox is on otherwise radio main CgiRef String HtmlExp A main button of a radio initially on with a reference and a value The value is returned of this button is on A complete radio button suite always consists of a main button radiomain and some further buttons radioothers with the same reference Initially the main button is selected or nothing is selected if one uses radiomainoff instead of radio_main The user can select another button but always at most one button of the radio can be selected The value corresponding to the selected button is returned in the environment for this radio reference radio_main_off CgiRef String HtmlExp A main button of a radio initially off with a reference and a value The value is returned of this button is on radio_other CgiRef String HtmlExp A further button of a radio initially off with a reference identical to the main button of this radio and a value The value is returned of this button is on selection CgiRef gt String String HtmlExp A selection button with a reference and a list of name value pairs The names are shown in the selection and the value is returned for the selected name selectionInitial CgiRef gt String String
327. without module qualifiers into the corresponding data term The first argument is a non empty list of module qualifiers that are tried to prefix the constructor in the string in order to get the qualified constructors that must be defined in the current program Example readUnqualifiedTerm Prelude Just 3 evaluates to Just 3 readsTerm String gt a String For backward compatibility Should not be used since their use can be problematic in case of constructors with identical names in different modules readTerm String gt a For backward compatibility Should not be used since their use can be problematic in case of constructors with identical names in different modules readsQTerm String gt a String Transforms a string containing a term in standard prefix notation with qualified con structor names into the corresponding data term In case of a successful parse the result is a one element list containing a pair of the data term and the remaining un parsed string readQTerm String gt a Transforms a string containing a term in standard prefix notation with qualified con structor names into the corresponding data term readQTermFile String gt 10 a Reads a file containing a string representation of a term in standard prefix notation and returns the corresponding data term readQTermListFile String gt I0 a Reads a file containing lines with string representations of terms of t
328. ws the interface of the module m which must be in the load path of KiCS2 usedimports Show all calls to imported functions in the currently loaded module This might be useful to see which import declarations are really necessary set option Set or turn on off a specific option of the KiCS2 environment see 2 3 for a description 4u_ of all options Options are turned on by the prefix and off by the prefix Options that can only be set e g path must not contain a prefix set Show a help text on the possible options together with the current values of all options save Save the currently loaded program as an executable evaluating the main expression main The executable is stored in the file Mod if Mod is the name of the currently loaded main module 6 save expr Similar as save but the expression expr typically a call to the main function will be evaluated by the executable fork expr The expression expr which is typically of type I0 is evaluated in an independent process which runs in parallel to the current KiCS2 process All output and error messages from this new process are suppressed This command is useful to test distributed Curry programs where one can start a new server process by this command The new process will be terminated when the evaluation of the expression expr is finished emd S
329. xistsDBKey Int gt a Dynamic Int gt Query Bool Checks whether the predicate has an entry with the given key allDBKeys Int gt a gt Dynamic Query Int Returns a list of all stored keys Do not use this function unless the database is small allDBInfos Int gt a Dynamic Query a Returns a list of all info parts of stored entries Do not use this function unless the database is small allDBKeyInfos Int gt a Dynamic Query Int a Returns a list of all stored entries Do not use this function unless the database is small Int a gt ColVal Constructs a value restriction for the column given as first argument someDBKeys Int gt a Dynamic gt ColVal gt Query Int Returns a list of those stored keys where the corresponding info part matches the gioven value restriction Safe to use even on large databases if the number of results is small someDBInfos Int gt a gt Dynamic gt ColVal Query a 98 Returns a list of those info parts of stored entries that match the given value restrictions for columns Safe to use even on large databases if the number of results is small someDBKeyInfos Int gt a Dynamic gt ColVal Query Int a Returns a list of those entries that match the given value restrictions for columns Safe to use even on large databases if the number of results is small someDBKe
330. xpr Infers the types of a single function specified by its qualified name inferNewFunctions Prog gt FuncDec1 gt I0 Either String AFuncDecl TypeExpr Infers the types of a group of possibly mutually recursive functions Note that the functions are only monomorphically instantiated i e polymorphic recursion is not sup ported The given type may be too general for instance a type variable only and will be specialised to the inferred type inferExpr Prog gt Expr gt I0 Either String AExpr TypeExpr inferProgEnv FM String String TypeExpr Prog Either String AProg TypeExpr Infers the type of a whole program Uses the given type environment instead of gener ating a new one inferFunctionEnv FM String String TypeExpr String String Prog gt Either String AFuncDecl TypeExpr Infers the types of a single function specified by its qualified name Uses the given type environment instead of generating a new one 269 getTypeEnv Prog gt IO FM String String TypeExpr Extract the type environment from the given Prog getTypeEnvFromProgEnv String Prog Prog Either String FM String String TypeExpr Extract the type environment from the given Prog by lookup in a module name gt Prog environment A 5 20 Library CurryStringClassifier The Curry string classifier is a simple tool to process strings containing Curry source code The source string
331. y 55 getCursorPosition 84 getDB 97 getDBInfo 99 getDBInfos 99 getDirectoryContents 55 getElapsedTime 134 getEnviron 134 getFileInPath 63 getFlatCurryFileInLoadPath 229 getFlexRigid 248 getHomeDirectory 56 getHostname 134 getLoadPathForModule 59 getLocalTime 136 getModificationTime 55 getOneSolution 48 getOneValue 48 getOpenFile 85 getOpenFileWithTypes 85 getOpt 72 getOpt 72 getPID 135 getPortInfo 53 getProcessInfos 121 getProgName 135 getRandomSeed 154 getRcVar 58 getRcVars 58 287 gets 62 getSaveFile 86 getSaveFileWithTypes 86 getSearchPath 64 getSearchTree 127 139 getSomeValue 68 getTemporaryDirectory 56 getTypeEnv 270 getTypeEnvFromProgEnv 270 getUrlParameter 174 getValue 83 ghc 12 14 ghci 14 Global 73 global 73 global installation 6 GlobalSpec 73 gmap 152 Graph 148 green 119 group 101 108 groupBy 101 guardedRule 217 GuiPort 74 h1 169 h2 169 h3 169 h4 170 h5 170 Handle 88 hang 108 hardline 108 hasDrive 65 hasExtension 65 hasTrailingPathSeparator 66 hcat 112 hClose 89 headedTable 171 header 170 hempty 169 hEncloseSep 113 hFlush 89 hGetChar 90 hGetContents 90 hGetLine 90 hiddenfield 174 hIsEOF 89 hIsReadable 90 hIsTerminalDevice 90 hIsWritable 90 hPrint 90 hPutChar 90 hPutStr 90 hPutStrLn 90 hReady 90 href 171 hrule 171 hSeek 89 hsep 111 htmldir 60 HtmlExp 163 H
332. yProjections Int gt a Dynamic Int gt ColVal gt Query Int b Returns a list of column projections on those entries that match the given value re strictions for columns Safe to use even on large databases if the number of results is small getDBInfo Int gt a gt Dynamic gt Int gt Query Maybe a Queries the information stored under the given key Yields Nothing if the given key is not present getDBInfos Int gt a gt Dynamic gt Int Query Maybe a Queries the information stored under the given keys Yields Nothing if a given key is not present deleteDBEntry Int gt a Dynamic Int gt Transaction Deletes the information stored under the given key If the given key does not exist this transaction is silently ignored and no error is raised deleteDBEntries Int gt a Dynamic Int gt Transaction Deletes the information stored under the given keys No error is raised if some of the keys do not exist updateDBEntry Int gt a Dynamic Int gt a Transaction Updates the information stored under the given key The transaction is aborted with a KeyNotExistsError if the given key is not present in the database newDBEntry Int gt a gt Dynamic gt a gt Transaction Int Stores new information in the database and yields the newly generated key newDBKeyEntry Int
333. ypeExpr Int gt a gt String String gt a gt a gt a gt a gt a gt TypeExpr gt a isTVar TypeExpr gt Bool is type expression a type variable isTCons TypeExpr Bool is type declaration a constructed type isFuncType TypeExpr Bool is type declaration a functional type updTVars Int TypeExpr TypeExpr TypeExpr update all type variables updTCons String String TypeExpr TypeExpr TypeExpr TypeExpr 258 update all type constructors updFuncTypes TypeExpr TypeExpr gt TypeExpr TypeExpr TypeExpr update all functional types argTypes TypeExpr gt TypeExpr get argument types from functional type resultType TypeExpr TypeExpr get result type from nested functional type rnmAllVarsInTypeExpr Int Int gt TypeExpr TypeExpr rename variables in type expression updQNamesInTypeExpr String String gt String String TypeExpr gt TypeExpr update all qualified names in type expression trOp String String gt Fixity Int gt a gt OpDecl gt a transform operator declaration opName OpDecl gt String String get name from operator declaration opFixity OpDecl Fixity get fixity of operator declaration opPrecedence OpDecl Int get precedence of operator declaration updOp String String String String gt Fixity gt Fixity gt Int gt Int Op
334. yped Abstract Curry program Thus the argument is the file name without suffix curry or lcurry and the result is a Curry term representing this program readCurryWithImports String gt 10 CurryProg Read an AbstractCurry file with all its imports tryReadCurryWithImports String gt 10 Either String CurryProg tryReadCurryFile String gt I0 Either String CurryProg tryParse String I0 Either String CurryProg Try to parse an AbstractCurry file readUntypedCurry String 10 CurryProg I O action which parses a Curry program and returns the corresponding untyped Ab stract Curry program Thus the argument is the file name without suffix curry or curry and the result is a Curry term representing this program readCurryWithParseOptions String FrontendParams gt IO CurryProg acy with respect to some parser options This I O action is used by the standard action I O action which reads a typed Curry program from a file with extension readCurry It is currently predefined only in Curry2Prolog readUntypedCurryWithParseOptions String FrontendParams IO CurryProg I O action which reads an untyped Curry program from a file with extension uacy with respect to some parser options For more details see function readCurryWithParseOptions abstractCurryFileName String String Transforms a name of a Curry program with or without suffix
Download Pdf Manuals
Related Search
Manual manual cars disappearing manual manualslib manuale digitale manually meaning manual timesheet manual transmission manual wheelchair manual arts high school manually update your device drivers windows manual definition manual for courts martial manual labor manual lawn mower manual muscle testing manually register devices with autopilot manual muscle testing grades manual transfer switch manualidades manual blood pressure cuff manual handling manual transmission cars for sale manual digital manual pdf manual autopilot enrollment
Related Contents
Untitled PARA SU ESTILO DE VIDA. EVGA X79 Classified P5B-MX/WiFi-AP Spezifikationsübersicht User's Guide - Honeywell Scanning and Mobility Lieferumfang Dirt Devil Rebel 21 SERIE BM Copyright © All rights reserved.
Failed to retrieve file