f#

Is it possible to remove the full-paths from .NET assemblies created with dotnet build?

穿精又带淫゛_ 提交于 2021-02-20 19:10:32
问题 The bounty expires in 2 days . Answers to this question are eligible for a +50 reputation bounty. sdgfsdh wants to draw more attention to this question. I build my project with dotnet build , targeting netcoreapp3.1 . The problem is that the assemblies contain the full path to the source-files: /home/runner/my-app/App.fs This means that the hash of the assemblies depends on the directory where the code was built. I want it to only depend on the hash of the source-files and the .NET SDK itself

Just installed v16.8.3 of visual studio and I seem to be getting tabs for F#

邮差的信 提交于 2021-02-20 18:49:13
问题 instead of spaces. I use F# quite a lot, not had this problem before. My F# settings seem to imply tabs are converted to 4 spaces..."insert spaces = 4" v16.8.3 very odd (actually this is a new install on a fresh machine not an upgrade, that may be relevant....I may have done something on my normal machine many moons ago, that Ive now forgotten) 回答1: I think this is the Adaptive Formatting behavior in Visual Studio: To turn off this behavior, please go to Tools > Options, and then Text Editor

Cyclic dependency of modules

点点圈 提交于 2021-02-20 06:45:48
问题 I want to write a parser in F# and because of reasons I have to use Antlr. This means I have to define a Visitor class for every AST node I want to parse. Now I have the problem that there are some rules with cyclic dependencies like: boolExpr : boolTerm 'or' boolTerm ; boolTerm : boolAtom 'and' boolAtom ; boolAtom : '(' boolExpr ')' | ... ; which means I need 3 visitor classes that have the same cyclic dependency and I want to have each of them in their own file //BoolExprVisitor.fs let

F# type alias for non-nullable string

走远了吗. 提交于 2021-02-20 06:06:32
问题 I have a couple of domain types in my code that I use to distinguish different types of strings, so the compiler can stop me from e.g. passing arguments in the wrong order: type Foo = string type Bar = string let baz (foo : Foo) (bar : Bar) = printfn "%A %A" foo bar let f : Foo = "foo" let b : Bar = "bar" baz f b // this should be OK baz b f // this shouldn't compile However, this currently doesn't work satisfactorily, for two reasons: I haven't been able to figure out a way to specify that

F# - constructing nested types

依然范特西╮ 提交于 2021-02-19 07:13:18
问题 I guess this is pretty basic F# question: Types are: type Id1 = | Id1 of int type Id2 = | Id2 of string type Id = | Id1 | Id2 type Child = { Id : Id; Smth : string list } type Node = | Child of Child | Compos of Node * Node where Node and Child should represent replacement for Composite OOP design pattern. The problem is that I cannot instantiate types in this way: let i1 : Child = {Id = Id1(1); Smth = []} //Id1 value is not a function and cannot be applied let i2 : Child = {Id = Id1(1); Smth

F# - constructing nested types

眉间皱痕 提交于 2021-02-19 07:12:56
问题 I guess this is pretty basic F# question: Types are: type Id1 = | Id1 of int type Id2 = | Id2 of string type Id = | Id1 | Id2 type Child = { Id : Id; Smth : string list } type Node = | Child of Child | Compos of Node * Node where Node and Child should represent replacement for Composite OOP design pattern. The problem is that I cannot instantiate types in this way: let i1 : Child = {Id = Id1(1); Smth = []} //Id1 value is not a function and cannot be applied let i2 : Child = {Id = Id1(1); Smth

F# type definition syntax

寵の児 提交于 2021-02-19 05:28:03
问题 I'm working on the '99 problems of F#', and saw the following definition of NestedList : type 'a NestedList = List of 'a NestedList list | Elem of 'a I'm a little confused by the syntax here, as normally there is only a type name after the type . Can someone clarify it? Thanks! 回答1: This is a discriminated union in a condensed syntax. You can also write it as: type 'a NestedList = | List of 'a NestedList list | Elem of 'a or type NestedList<'a> = | List of NestedList<'a> list | Elem of 'a

F# type definition syntax

五迷三道 提交于 2021-02-19 05:25:06
问题 I'm working on the '99 problems of F#', and saw the following definition of NestedList : type 'a NestedList = List of 'a NestedList list | Elem of 'a I'm a little confused by the syntax here, as normally there is only a type name after the type . Can someone clarify it? Thanks! 回答1: This is a discriminated union in a condensed syntax. You can also write it as: type 'a NestedList = | List of 'a NestedList list | Elem of 'a or type NestedList<'a> = | List of NestedList<'a> list | Elem of 'a

F# understanding discriminated union

纵饮孤独 提交于 2021-02-19 04:35:13
问题 I've kind of asked this question earlier so sorry for asking a bit similar question again. But unfortunately im not able to really understand how to design a discriminated unions. so i have bunch of data structures which look like type Artist( artistId : int, name : String ) = do if name = null then nullArg String.Empty new(artistId: int) = Artist(artistId) member x.ArtistId = artistId member x.Name = name and Genre() = let mutable name = String.Empty let mutable genreId : int = 0 let mutable

Automatically figuring out function name in f#

我是研究僧i 提交于 2021-02-18 11:00:28
问题 If I have a function that is part of a module, and I want a log entry while inside the function,I have to manually print the function namespace and name e.g. namespace MyModuleNamespace module MyModule = let AddTwoNums logger x y = logger.Info("MyModuleNamespace.AddTwoNums - Start") let res = x+y logger.Info("MyModuleNamespace.AddTwoNums - End") res Is there any way I can automatically work out what "MyModuleNamespace.AddTwoNums" is as it is very cumbersome/error prone especially when you