JFriCAS

jfricas.spad line 87 [edit on github]

The JFriCAS package contains functions to start a webserver and to initialize ioHooks for the communication between FriCAS and the Jupyter frontend. It also manages the communication between FriCAS (via the Hunchentoot webserver) and the Jupyter notebook.

addLinks: XHashTable(String, String) -> String -> String

addLinks(ht)(type) returns a string that for every constructor c that appears as a string in the keys of ht a link to the online API constructor documentation of c.

extendConstructorURLs: (XHashTable(String, String), String) -> XHashTable(String, String)

extendConstructorURLs(h,url) creates a copy of h where each constructor name that is not yet existing in h gets an entry with value url.

fricaskernel: () -> Void

fricaskernel() writes out a file fricaskernel.py to the current directory. This file should be installed together kernel.json (generated by the kernel() function call) in your jupyter/python environment.

handleOutput: (Boolean, String) -> String

handleOutput(err?, out) translates the output out into a string that contains a JSON structure that is to be understood by fricaskernel.py. The function interprets the “–FORMAT:BEG:”/”–FORMAT:END:” pairs, in particular reads off the step number from their end and groups the output into substructures indexed by the step number of FriCAS. The JSON record looks like {“error?”: true, “souts”: [s1,…, sn]} where ‘error?’ is either True or False (depending on whether or not the evaluation produced an error) and the responses si are dictionaries that represent stepped outputs, i.e are of the form {“step”: step, “outs”: [o1, …, om]} and the oi are of the form {content_type: content}. Note that content_type can be “ERROR”, which means that the respective content is an error message or is content that was outside of e “–FORMAT:BEG:”/”–FORMAT:END:” pair.

initialize: () -> Void

initialize() defines a number of functions for jFriCAS to work.

jfricasIOHandler: (Symbol, SExpression) -> Void

jfricasIOHandler(s) reacts on certain ioHooks and writes out begin and end markers to stdout so that the corresponding fricaskernel.py can single out the various kinds of messages that comes from FriCAS.

kernel: () -> Void

kernel() writes out a file kernel.json to the current directory. This file should be installed together fricaskernel.py (generated by the fricaskernel() function call) in your jupyter/python environment.

setTranslateType!: (String -> String) -> String -> String

setTranslateType!(fun) sets the function fun that is used in handleOutput to translate the type returnd by FriCAS into something more pleasing to the user. A good candidate for fun is addLinks(h) for a respective hashtable constructed via extendConstructorURLs.

start: NonNegativeInteger -> Boolean

start(p) initializes jFriCAS and starts a new webserver instance on port p. It returns true if successful and false if the hunchentoot webserver is not available.