How do I view the definition of a function in elm-repl? - elm

If I type the name of the function in elm-repl, I receive the function signature. I would like to see the actual definition.

elm-repl does not provide the source code to functions, but it will show you the function signature as you described.
The Elm core package page has a search box where you can type in the name of a function to get an immediate link to the function's documentation, and from there you can get to the source, almost always hosted on Github.

Related

C# to Vb.NET code convert

below code is c#
ctx.CreateStreamResponse(stream => new Session(_Sessions, stream).Process(),"video/mp4");
and i need to this code as VB.NET code. am converting as below
ctx.CreateStreamResponse(Function(stream) New Session(_Sessions, stream).Process(), "video/mp4")
But getting error
overload resolution failed because no accessible
"CreateStreamResponse" can be called with these arguments.
CreateStreamResponse needs 2 parameters
Stream (as my sample Function(stream) New Session(_Sessions, stream).Process())
content type (as my sample "video/mp4")
Anyone can help me, please
I believe the issue seems to be that the method which you pass into CreateStreamResponse should be a Sub not a Function. i.e:
ctx.CreateStreamResponse(Sub(stream) New Session(_Sessions, stream).Process(), "video/mp4")
CreateStreamResponse takes an Action(Of Stream) delegate as the first argument and a contentType of String as the second argument.
Thus you need to use Sub rather than a Function as in this case an Action delegate can only encapsulate methods that return void (sub procedures). Also, ensure that the Process method being invoked is also a Sub procedure.
If the problem persists then as suggested by Microsoft docs:
Review all the overloads for the method and determine which one you
want to call.
In your calling statement, make the data types of the arguments
match the data types of the parameters defined for the desired
overload. You might have to use the CType Function to convert one or
more data types to the defined types.
for more information see here

Why is this structure declaration allowed in a built-in Function Module but not in a new one?

I'm working on a Function Module to assist with dealing with included text with logic embedded. While looking into the way SAP handles SAPScript files and parses the logic I found a structure that is declared as so:
DATA BEGIN OF events OCCURS 100.
INCLUDE STRUCTURE ITCCA.
DATA: command LIKE BOOLEAN,
template LIKE BOOLEAN,
mask LIKE BOOLEAN,
END OF events.
This obviously works, as I can trace through it while it is running a print program. So I thought I would try a similar structure in my own code but even when I copied the code 1 for 1 like above I get an error during activation. The error is
"BOOLEAN" must be a flat structure. Internal tables, references,
strings and structures are forbidden as components.
Can someone explain to me why this structure is valid in one program and not mine?
To explain the actual effect: LIKE usually refers to a data object (an actual variable) on the right-hand side, not a data type. As you rightly discovered, once you provide a data object named BOOLEAN, that is used to construct the type. If a data object of that name is not present and you're not within a class or an interface, an obsolete variant of the LIKE statement will be triggered that also takes data types into account, but only allows for certain elements on the right-hand side - namely only flat structured objects or their components. LIKE DATATYPE-BOOLEAN should have worked. As usual, the error message is somewhat less than helpful.
It seems during my initial investigation I missed a declaration for the BOOLEAN type. In the STXC function group SAP decided to declare their own variable for boolean in a different include file like this:
data: boolean(1) type c.
I had originally assumed that they were doing this with the dictionary defined type which has a similar name and is a 1 character long string. What I also found is that if I were to change my structure declaration like this:
DATA BEGIN OF events OCCURS 100.
INCLUDE STRUCTURE ITCCA.
DATA: command TYPE BOOLEAN,
template TYPE BOOLEAN,
mask TYPE BOOLEAN,
END OF events.
My code would be valid because it would then be using the dictionary defined value. So either I have to add a declaration for my own definition of boolean so that I can use the LIKE keyword or I have to use the TYPE keyword to use the dictionary definition.

How can I return JSONP in RestXQ (using eXist-db)?

I cannot figure out how to return JSONP in RestXQ. After adding
let $x := util:declare-option("exist:serialize", fn:concat("method=json jsonp=",request:get-parameter("callback", "callback")))
to the function, I get the error message:
err:XPTY0004:It is a type error if, during the static analysis phase, an expression is found to have a static type that is not appropriate for the context in which the expression occurs, or during the dynamic evaluation phase, the dynamic type of a value does not match a required type as specified by the matching rules in 2.5.4 SequenceType Matching.
The beginning of the GET function is:
declare
%rest:GET
%rest:path("/demo/contacts/submit")
%rest:query-param("email", "{$email}", '')
%rest:query-param("nomail", "{$nomail}", 0)
%rest:produces("application/javascript")
%output:media-type("application/javascript")
%output:method("json")
function contacts:submit($email as xs:string*, $nomail as xs:integer*)
{
try
{
let $x := util:declare-option("exist:serialize", fn:concat("method=json jsonp=",request:get-parameter("callback", "callback")))
As discussed on the eXist-open mailing list (I'd suggest joining!), the request module's get-parameter() function is not available inside a RestXQ function. Instead, you can get your callback parameter via the %rest:query-param annotation. Add %rest:query-param("callback", "{$callback}", '') to your contacts:submit() function, and I think you'll be a step closer.
#joewiz is correct. Your initial problem is related to the use of eXist request module from RESTXQ, which is unsupported.
Also, RESTXQ does not currently support JSONP serialization. If you want to use JSONP serialization, your best bet at the moment is to manage the serialization to JSON yourself, perhaps using the xqjson library or similar and then wrapping the result in a JSON function using concat or similar.

Documentation for user-defined functions in Scilab

I'm finishing a Scilab project for school, and I've added comments to all my function based on this passage from the documentation:
Inside a function, the first comment lines, up to the first instruction or an empty line may be used to provide the default contents for the function help.
Yet help does not display the comments when I type help myfunction. Instead, it launches the help browser, on the search page.
Any ideas? Basically I'm looking for an equivalent of Matlab's "H1 lines" and "Help text".
The right instruction is
head_comments myfunction
When there is no native function named myfunction and myfunction is known as a user-defined one, indeed it would be fine to use directly
help myfunction
This wish is reported # http://bugzilla.scilab.org/10785
You have to use this function to convert comments to a help page:
http://help.scilab.org/docs/current/en_US/help_from_sci.html
and then compile it.

Drupal: CCK API Docs

Any good CCK API docs out there? I have seen http://api.audean.com/, but can't find what I want there.
Basically, I need a function that takes a field name and returns what node type has that field. I wrote my own, but would rather make an API call.
CCK is an awesome module but has terrible, outdated documentation. :(
Looking through the module files revealed content_fields($field_name) which may provide the functionality you are looking for.
The function takes in the field name and returns an array of all the settings for that field.
The node type is stored in ['type_name'] so you could write something like the following:
$field = content_fields('field_myfield');
$node_type = $field['type_name'];
That should give you the node type for field_myfield.