Deedle, F# and read csv - f#

I am facing an issue when I try to use the function Deedle.Frame.ReadCsv
I am trying to use the overload here: https://collective2.com/c2explorer_help/html/806c0295-1a9f-1bf4-50eb-a221419abe06.htm
let schemaSource = "dateRep (DateTime),,,,,,,,,"
let dataSource = Deedle.Frame.ReadCsv(path = "data.csv", schema = schemaSource)
When I do so, I get the following error:
error FS0503: A member or object constructor 'ReadCsv' taking 0 arguments is not accessible from this code location. All accessible versions of method 'ReadCsv' take 9 arguments.
What I do not get is that all but path are optional. If I use just:
Deedle.Frame.ReadCsv("data.csv")
It then works...
Any idea? I tried to find some resources on using overloaded functions from other .Net languages with optional parameters but I have not been successful.

I am not sure why the Intellisense/Signature shown in Visual Studio was wrong but using location = works...

Related

SOLANA - How to check for mint supply on chain?

folks, how do I check for the supply of a mint account on-chain?
I have no idea on how to do this.
I've tried using:
let mint = Mint::unpack_unchecked(accounts.mint.data).unwrap();
Then I get this error:
expected reference `&[u8]`
found struct `Rc<RefCell<&mut [u8]>>`
Also, in my function, if I try to get accounts.mint.data to &[u8]format by doing this:
let data = accounts.mint.data.borrow().as_ref();
I get this non-sense error:
consider using a `let` binding to create a longer lived valuerustcE0716
mod.rs(98, 64): temporary value is freed at the end of this statement
mod.rs(99, 51): borrow later used here
Nevermind:
let mint = Mint::unpack_unchecked(&accounts.mint.data.borrow()).unwrap();
to get the supply, just access mint.supply

F# non-static methods in modules

I am an absolute newbie to coding, but I need to modify a F# script. It always gives me the error "Method or object constructor 'x' is not static". I read that this might be due to the fact that I try to call a non-static method within a module, which is by default static. For example 'x' = Get.Axis():
module Primitives =
let axis1 = Zaber.Motion.Ascii.Device.GetAxis(1)
The manual only provides code in C#: var axis1 = device.GetAxis(1);
If I use static member instead of let, I'll get a 'unexpected keyword static in definition' error, although I checked the indentation as suggested in another question.
Assuming you're using the Zaber Motion Library, I think what you need to do is get an instance of a device first, instead of trying to access the class in a static context.
Their documentation includes an example of how to get a list of devices by opening a serial port:
open Zaber.Motion.Ascii
use connection = Connection.OpenSerialPort("COM3")
let deviceList = connection.DetectDevices()
match deviceList |> Seq.tryHead with // See if we got at least one device
| Some device ->
let axis = device.GetAxis(1)
// TODO: Do whatever you want with the axis here
| None ->
failwith "No Devices Found on COM3"

FSharp.Data.JsonProvider - Getting json from types

The FSharp.Data.JsonProvider provides a means to go from json to an F# type. Is it possible to go in the reverse direction i.e. declare an instance of one of the types created by FSharp.Data.JsonProvider, set the field values to be what I need, and then get the equivalent json?
I've tried things like this,
type Simple = JsonProvider<""" { "name":"John", "age":94 } """>
let fred = Simple(
Age = 5, // no argument or settable property 'Age'
Name = "Fred")
The latest version of F# Data now supports this. See the last example in http://fsharp.github.io/FSharp.Data/library/JsonProvider.html.
Your example would be:
type Simple = JsonProvider<""" { "name":"John", "age":94 } """>
let fred = Simple.Root(age = 5, name = "Fred")
This is one area where C# has an edge over F#, at least in Visual Studio. You can copy your JSON example code into the clipboard and in Visual Studio use the Edit -> Paste Special -> Paste JSON As Classes and it will create a class to match the JSON example. From there you can easily use the class in F#.
More details on paste special here
Hopefully a matching feature will come for F# soon too.

Specifying optional parameters when calling JavaScript functions in Dart

I'm calling the function window.navigator.geolocation.getCurrentPosition from Dart code. The final parameter to this function is optional. In JavaScript I would set the optional parameters as follows:
var wpid = navigator.geolocation.watchPosition(geo_success, geo_error,
{enableHighAccuracy:true, maximumAge:30000, timeout:27000});
What would the equivalent be in Dart code? I've tried the following but I'm not sure if it is correct:
window.navigator.geolocation.watchPosition(geo_success, geo_error,
{'enableHighAccuracy':true, 'maximumAge':30000, 'timeout':27000});
You are using this method: http://api.dartlang.org/docs/bleeding_edge/dart_html/Geolocation.html#watchPosition
int watchPosition(PositionCallback successCallback, [PositionErrorCallback errorCallback, Object options])
I do not have Dark SDK on this machine, but to me it looks completely fine. If the JavaScript equivalent code is just an object, then passing a Dart Map just like what you have done should be working. Is there a problem with it?
Hopefully passing a Map works, please try and let us know.
Even if it does work, this is a bad Dart API. The options really should be optional parameters, not properties of an options object. I filed a bug here: http://dartbug.com/6280

Visual studio - f# - Error FS0588 : Block following this 'let' is unfinished. Expect expression

i have got several times , trying to implement different functions, the message you see as title. I would like to know if anyone can tell me the general meaning (and reason) of this error message. As i mentioned before, i have got the problem several times and manage to fix it, but still didnt get the exact reason, so i will not post any specific code.
Thank you in advance
The most common case when you may get this error is when you write let binding that is not followed by an expression that calculates the result. In F#, everything is an expression that returns some result, so if you write let a = 10 it is generally not a valid expression. To make it valid, you need to return something:
let foo () =
let a = 10
() // return unit value (which doesn't represent any information)
The only exception where you can write just let a = 10 is a global scope of an F# source file - for example, inside a module declaration or in an F# script file. (This is why the declaration of foo above is valid).
It is difficult to give any advice without seeing your code, but you probably have a let declaration that is not followed by an F# expression.
Out of curiosity, the following example shows that let can really be used inside an expression (where it must return some meaningful result):
let a = 40 + (let a = 1
a + a)

Resources