f#

F# syntax for async controller methods in ASP.NET Core

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-30 11:33:52
问题 I'm new to F# and trying to translate some C# ASP.NET Core code into F# There is a C# controller here, and a working translated F# controller here even though I got it working, I can't seem to figure out how to make the controller actions async. The methods call async code on a Commands object and a Queries object that are injected. The Commands and Queries are currently implemented in C#. So for example a couple of the async C# controller methods are: public async Task<IEnumerable<ToDoItem>>

F# syntax for async controller methods in ASP.NET Core

让人想犯罪 __ 提交于 2020-12-30 11:29:42
问题 I'm new to F# and trying to translate some C# ASP.NET Core code into F# There is a C# controller here, and a working translated F# controller here even though I got it working, I can't seem to figure out how to make the controller actions async. The methods call async code on a Commands object and a Queries object that are injected. The Commands and Queries are currently implemented in C#. So for example a couple of the async C# controller methods are: public async Task<IEnumerable<ToDoItem>>

How to include Akka.net framework for F# in VSCode

孤街浪徒 提交于 2020-12-26 08:22:09
问题 I am trying to use Akka.NET for F# in VSCode using this example I found on the internet. Code // ActorSayHello.fsx #time "on" // #load "Bootstrap.fsx" open System open Akka.Actor open Akka.Configuration open Akka.FSharp open Akka.TestKit // #Using Actor // Actors are one of Akka's concurrent models. // An Actor is a like a thread instance with a mailbox. // It can be created with system.ActorOf: use receive to get a message, and <! to send a message. // This example is an EchoServer which can

Indentation change after if-else expression not taken into account?

邮差的信 提交于 2020-12-25 04:25:24
问题 Given this this operator for evaluation of side effects in pipelines let inline (|>!) a f = f a ; a and this code snippet if 1 = 1 then "same" else "different" |>! printfn "The numbers are %s." |> printfn "Yes, they are %s." This never prints The numbers are same but it does print Yes, they are same . Why is the side effect operator |>! ignored here, but the |> taken into account, despite having the same indent? Would I have to define the side effect operator differently? written like this it

Is this shadowing a variable in F#?

故事扮演 提交于 2020-12-15 07:13:26
问题 let print_scene (y, v) = do Console.Clear() let y, v = int y, int v (* This is the code in question *) for j = 10 downto 0 do for i = 0 to 30 do if (y + 1) = j && i = 15 then Console.Write("b") elif j = 0 || i = 0 || j = 10 || i = 30 then Console.Write("*") else Console.Write(" ") Console.Write("\n") ignore(Console.ReadKey()) I don't understand what the int is doing in this code, what it is, or why it's there. 回答1: Indeed, this is parameter shadowing. let foo bar = let bar = bar * bar bar

linux下 tar解压 gz解压 bz2等各种解压文件使用方法

冷暖自知 提交于 2020-12-15 04:23:36
大致总结了一下linux下各种格式的压缩包的压缩、解压方法。但是部分方法我没有用到,也就不全,希望大家帮我补充,我将随时修改完善,谢谢!      .tar   解包:tar xvf FileName.tar   打包:tar cvf FileName.tar DirName   (注:tar是打包,不是压缩!)   ———————————————   .gz   解压 1:gunzip FileName.gz   解压2:gzip -d FileName.gz   压缩:gzip FileName   .tar.gz 和 .tgz   解压:tar zxvf FileName.tar.gz   压缩:tar zcvf FileName.tar.gz DirName   ———————————————   .bz2   解压1:bzip2 -d FileName.bz2   解压2:bunzip2 FileName.bz2   压缩: bzip2 -z FileName   .tar.bz2   解压:tar jxvf FileName.tar.bz2 或tar --bzip xvf FileName.tar.bz2   压缩:tar jcvf FileName.tar.bz2 DirName    ———————————————   .bz   解压1:bzip2 -d

type extension on a list in F#

佐手、 提交于 2020-12-13 03:34:19
问题 Let's say I have a type: let MyType = some info ... but, it is commonly used in a list: MyType list so I can define: let MyTypeList = MyType list is there a way to define a type augmentation on MyTypeList? my practical case is that the type returns results of some work, it is handled in batches and I have some code that tell me if the whole batch is ok, if it is partially ok, or if everything went wrong. If I could add extensions to the list type, the syntax would be simpler. let a :

type extension on a list in F#

笑着哭i 提交于 2020-12-13 03:25:52
问题 Let's say I have a type: let MyType = some info ... but, it is commonly used in a list: MyType list so I can define: let MyTypeList = MyType list is there a way to define a type augmentation on MyTypeList? my practical case is that the type returns results of some work, it is handled in batches and I have some code that tell me if the whole batch is ok, if it is partially ok, or if everything went wrong. If I could add extensions to the list type, the syntax would be simpler. let a :

Continued “Is there an equivalent of C#'s nameof(..) in F#?”

丶灬走出姿态 提交于 2020-12-10 17:01:33
问题 With reference to Is there an equivalent of C#'s nameof(..) in F#? how can the nameof function used or extended for the following case? let nameof (q:Expr<_>) = match q with | Patterns.Let(_, _, DerivedPatterns.Lambdas(_, Patterns.Call(_, mi, _))) -> mi.Name | Patterns.PropertyGet(_, mi, _) -> mi.Name | DerivedPatterns.Lambdas(_, Patterns.Call(_, mi, _)) -> mi.Name | _ -> failwith "Unexpected format" let any<'R> : 'R = failwith "!" let s = _nameof <@ System.Char.IsControl @> //OK type A<'a>()

Continued “Is there an equivalent of C#'s nameof(..) in F#?”

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-10 17:01:24
问题 With reference to Is there an equivalent of C#'s nameof(..) in F#? how can the nameof function used or extended for the following case? let nameof (q:Expr<_>) = match q with | Patterns.Let(_, _, DerivedPatterns.Lambdas(_, Patterns.Call(_, mi, _))) -> mi.Name | Patterns.PropertyGet(_, mi, _) -> mi.Name | DerivedPatterns.Lambdas(_, Patterns.Call(_, mi, _)) -> mi.Name | _ -> failwith "Unexpected format" let any<'R> : 'R = failwith "!" let s = _nameof <@ System.Char.IsControl @> //OK type A<'a>()