Giter VIP home page Giter VIP logo

Comments (8)

callmekohei avatar callmekohei commented on July 20, 2024 1

Hello. I'll see it later :-)

from deopletefs.

resolritter avatar resolritter commented on July 20, 2024 1

Nice @callmekohei ! Your tips led me to this command:

https://fsprojects.github.io/Paket/paket-generate-load-scripts.html#paket-generate-load-scripts

Now I generated my file with:

.paket/paket.exe generate-load-scripts -f netstandard2.0 -t fsx -v

Because I'm targetting netstandard2.0 in the browser. And I can see the file has been correctly generated in:

.paket/load/netstandard2.0/main.group.fsx

Now is there a way to automatically include this for deopletefs, so that I don't have to paste this code in every single file?

from deopletefs.

resolritter avatar resolritter commented on July 20, 2024 1

@callmekohei I took some time to read about this. Here's what I've found:

(As a disclaimer, I don't think good enough at F# to work with those solutions)

-Include load directive as a string before parsing the file

Maybe somewhere around here?

https://github.com/callmekohei/deopletefs/blob/master/src/deopletefs.fsx#L50

Instead of passing the file as an input, read the file first as a string, append the directive before the code, then pass the code string to the compiler service.

- Hosting FSI session

http://kcieslak.io/Dynamically-extending-F-applications
Seems to be about hosting a session of FSI and evaluating script files through it, as per the sample:

let fsi =
    let inStream = new StringReader("")
    let outStream = new StringWriter(sbOut)
    let errStream = new StringWriter(sbErr)
    let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration()
    let argv = [| "/temo/fsi.exe"; |]
    FsiEvaluationSession.Create(fsiConfig, argv, inStream, outStream, errStream)

let mdl = getOpen path
let load = getLoad path

fsi.EvalInteractionNonThrowing(sprintf "#load \"%s\";;" load)
fsi.EvalInteractionNonThrowing(sprintf "open %s;;" mdl)
fsi.EvalExpressionNonThrowing "map"

But maybe it would be too troublesome, I don't know.

- "Eval" FSharp files at runtime

https://stackoverflow.com/a/2608246/8401696

There is no function that would allow you to do this directly. However, when you want to compile an F# source file programatically, you can invoke the F# compiler from your application.

The answer shows how to compile and generate the code, but here is a more updated version:

http://fsprojects.github.io/FSharp.Compiler.CodeDom/tutorial.html#Tutorial

- Evaluate include directives at runtime, with template or macros

It seems like this is not possible in FSharp, sadly; or else we could invoke "#load" with a custom path at runtime.

- "Code-cracking" directives and passing custom options to the FSharp compiler service

I think this is what fsharp-language-server does.

https://github.com/fsprojects/fsharp-language-server/blob/master/src/ProjectCracker/ProjectCracker.fs#L366

https://github.com/fsprojects/fsharp-language-server/blob/master/src/ProjectCracker/ProjectCracker.fs#L328

This would need to parse the generated file and convert the #r directives into -r command line options, or whatever format FSC is using.

from deopletefs.

callmekohei avatar callmekohei commented on July 20, 2024 1

Hello! Thank you very much :-)
I would like to spend some time thinking about this issue.

from deopletefs.

resolritter avatar resolritter commented on July 20, 2024 1

Sure! Sadly I'm a noob at F# so I can't contribute with code, but I appreciate the work here. Take your time and thank you in advance. :^)

from deopletefs.

callmekohei avatar callmekohei commented on July 20, 2024

Hello. deopletefs needs #r.

#r "foo.dll"

example

F# Data

prepare library

$ paket init
$ vim paket.dependencies

     source https://www.nuget.org/api/v2
     generate_load_scripts: true
     nuget fsharp.data

write fsharp code

$ vim foo.fsx

  #load "./.paket/load/net48/main.group.fsx"
  open FSharp.Data
  type Stocks = csv

Screen Shot 2019-07-14 at 2 20 07

from deopletefs.

callmekohei avatar callmekohei commented on July 20, 2024

"./.paket/load/net48/main.group.fsx" file shows below

namespace PaketLoadScripts

#r "../../../packages/FSharp.Data/lib/net45/FSharp.Data.dll" 
#r "System.Xml.Linq" 

from deopletefs.

callmekohei avatar callmekohei commented on July 20, 2024

Now is there a way to automatically include this for deopletefs, so that I don't have to paste this code in every single file?

Oh... Surely! (^_^;;;

I will think about it.
If you have a good idea, please let me know.
Thank you very much.😀

from deopletefs.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.