Is there something like Python help function in Fsharp interactive? - f#

Using Python in command line you can write help(function) to see docstring.
Is there something similar in Fsharp for fsi?
Do you have any tips and tricks for working in fsi anyway?
What is even possible to find out without using IDE? Just from interactive session.
EDIT:
This question is actually addressed to Python guys who know Fsharp as well. I guess MS guys relying on their VS might find my question pretty strange :)
So far it seems that my question has simple answer: NO.
EXAMPLE:
Lets say you are logged to remote computer via console. I dont know whether this is typical or even possible scenario. For some reason I started fsi and now what? Am I lost or do I have some chances to get some help from fsi directly
DISCLAMER:
I know Scott Wlaschins fsharpforfunandprofit.com pretty well. But his example is dedicated to C# users. Pythonists have different workflow.

If you are used to interactive python, and you like the approach, you may have a look at this F# engine for iPython Notebook:
https://github.com/fsprojects/IfSharp

Yes.
Simple introspection can be done by typeof <_> or typedefof<_>.
For example:
typeof<System.Console>;;
In fsi you can use TAB completation, but apperantly just from command line. It is not working in my Xamarin.
Neat trick is to run:
fsi --use:yourfile.fsx
which run your file and let you test it interactively.
For more info you can use in command line fsi.exe --help.

Related

Dart: Possible to exchange source code on the fly in a running system?

In this article it says: "The Dart VM reads and executes source code, which means there is no compile step between edit and run.". Does that mean that you can exchange source-code on the fly in a running Dart system like in Erlang? Maybe the compiler is removed from the runtime system and then this is no longer possible. So that's why I'm asking.
Dart is run "natively" only in Dartium, which is a flavour of Chrome with DartVM. When you develop an application you still need to compile it it to JavaScript. This way you get fast development lifecycle and in the end you can compile code to JS. Because it's compiled code there is lots more room for compiler to run optimisations on the code. So from my perspective, the compiler is still there and I don't think you would be able to replace code at runtime.
You can send around source code and run it, but it would need to be in a separate isolate. Isolates do have some relationship to Erlang concepts.
The Dart VM doesn't support hot swapping (Called live edit in V8). However, based on mailing list discussions, it sounds like this is something that the authors do want to support in the future.
However, as the others have mentioned, it is possible to dynamically load code into another isolate.

REPL for the Dart language

Is there a REPL for Dart to experiment with?
I tried inputing dart code in DevTools in Dartium and that also didn't work.
So I couldn't find an easy way to play with various APIs in dart.
I tried inputing dart code in devtools in Dartium and that also didn't
work.
I'm very new to Dart, but something I came across was that you CAN evaluate code in Dartium. In order to do so, you must first load a page with Dart code in it and then toggle this selector in the console from "javascript page context" to one that references a Dart package or Dart code.
Once you do that you should be able to execute Dart in the console:
As a VIM user, I hardly have to open the Dart Editor now :). I should also mention that breakpoints, hovering over stepped into code to get variable details, navigating the call stack, and some level of intellisense in the console also work. I couldn't get conditional breakpoints to work, though.
Though it is not really a REPL, you may find the Try Dart online tool useful for playing around. It's a bit slow, since it is actually compiling the Dart code to JavaScript in order to have it work within the browser.
There is also a console that someone built, which is probably better if you're looking for a real REPL, but it requires a bit of setup.
There is an announcement about REPL for Dartium - see Nathanial's comment below. There are plans for Smalltalk like super-REPL. Here is what Gilad Bracha (member of the Dart team at Google) wrote on this subject in Is there a REPL or console for Dart:
"I don't see this as a language question at all. It is a matter of tooling and reflective library support. With proper mirror builder APIs, building a REPL would be trivial. As it sands right now, it can be quite challenging. And of course, REPL is not the ultimate goal - there are more advanced interactive tools, like workspaces in Smalltalk/Self/Newspeak, where you not only evaluate things interactively at some top level, but can inspect the resulting objects, evaluate within the scope of an individual declaration or object etc. I am sure we will get there in time - and i much prefer sooner than later."
The correct answer is https://dartpad.dev/
That site didn't exist when the other answers were posted in 2013, but you've stumbled on this post after 2020. And now you know. https://dartpad.dev allows you to create and share new Dart snippets and even put them in a Flutter app running online. Very, very cool!
Since 2022.10.22, there is a REPL for Dart: https://github.com/fzyzcjy/dart_interactive :)
Features:
Use any third-party package freely
Auto hot-reload code anywhere, with state preserved
Supports full grammar in REPL
Play with existing code side-by-side
Disclaimer: I wrote that package.

OCRopus documentation?

Is there a documentation for ocropus?
I am looking for an explanation for the functions like:
make_SegmentPageByRAST():
segment()
RegionExtractor():
setPageLines()
extract()
Thank you.
A requirement of Lua API for OCRopus has been filed in the bug-tracker list of the project.
They will soon be releasing this documentation in the next beta release(expected).
First, note that you can use the command line tools without actual Lua programming.
A good place to see how to use ocroscript is to look at the test cases in
ocroscript/tests and the command line driver scripts in ocroscript/scripts.
Note: The Lua bindings follow the C++ API very closely (the binding is mostly
automatic), so C++ and Lua documentation are pretty much the same problem.

How do I implement an F# Read Eval Print Loop (REPL)?

I would like to add an F# REPL to my application for live debugging purposes. I am looking at the source code for fsi.exe (F# Interactive) and there is a ton of stuff going on that looks like it pokes around with F# compiler internals. I cannot get this same code to compile in the context of our application because of this.
Is there a nice simple example of implementing an F# REPL somewhere? I would have hoped for this to be fairly easy.
The short answer is that F# (unfortunatelly) doesn't currently provide any API for hosting F# Interactive in your applications. There are a lot of people asking for this - see for example this SO question.
There are essentially two things you could do about that:
You can modify the open-source release and compile fsi.exe as some DLL library that would provide the API you need. This isn't simple task - F# Interactive is tightly bound with the compiler (it compiles code you enter on the fly), but it should be doable to encapsulate the types implementing REPL into some type you could call (But you cannot just take some file out of it - you need to compile entire F# to get this working).
You can run fsi.exe as a separate process as Visual Studio does and send commands to it using standard input/output. You can get some more flexibility by loading your library when fsi.exe starts. The library could use .NET Remoting to connect back to your application and expose some data.
Unfortunatelly, these two options are probably the only things you can do at the moment.
EDIT I was thinking that I already answered this question somewhere (perhaps in email), but couldn't
find it! Thanks to Mauricio who found the exact duplicate (even with my duplicate answer... Doh!)
I've written a series of blog posts about using the open source F# interactive executable inside and WPF application.
The code base is available on github - https://github.com/oriches/Simple.Wpf.FSharp.Repl
The series of blog posts are:
http://awkwardcoder.blogspot.co.uk/2013/12/simple-f-repl-in-wpf-part-1.html
http://awkwardcoder.blogspot.co.uk/2013/12/simple-f-repl-in-wpf-part-2.html
http://awkwardcoder.blogspot.co.uk/2013/12/simple-f-repl-in-wpf-part-3.html
The final post is to follow soon.

Code completion in Vi editor [duplicate]

This question already has answers here:
Autocompletion in Vim
(7 answers)
Closed 9 years ago.
Is there an autocomplete feature for Vi? ctrlp looks for keywords already used in the document. But suppose I want a.funcname to automatically show members of object a. Is it possible with Vi?
YouCompleteMe. It’s a plugin that offers extremely fast, fully syntax-aware auto-completion. It furthermore shows code errors on the fly (by putting a marker inside the margin next to the offending line).
So far, C++, C# and Python are natively supported. However, the plugin has an easily accessible API to add support for more languages.
There are other plugins but with the exception of Jedi (for Python only) nothing comes even close to working properly.
Take a look at supertab: http://www.vim.org/scripts/script.php?script_id=1643
I realise this isn't quite answering your question, but have you looked at running vi within an IDE ?
viPlugin works with Eclipse and is a pretty good vi emulation. Since it runs within Eclipse you get all the code completion that Eclipse provides. Eclipse isn't just for Java, btw. It works with a variety of languages and may well cater for what you need.
This is the direction I took when I reluctantly realised that vi by itself wasn't providing as much help as I needed when developing, but I was reluctant to give up the power of the editor.
I use NetBeans with the jVi plugin. It gives me the editing power of vi with the intelligent auto-completion features of NetBeans.
It depends on your language. For c++, for example, there is omnicppcomplete.
Maybe this article will help, I haven't tried it to be honest but it looks suitable.

Resources