예제
-
F# Async TCP Server Simple ExampleF# 2021. 1. 2. 18:59
[Original Source] http://www.fssnip.net/1E/title/Async-TCP-Server [Modifed] .net core에서 컴파일되도록 일부 수정한 코드입니다. (Option type 적용등) 작동 확인 : 2021-01-02 open System open System.Net open System.Net.Sockets open System.Threading type Socket with member socket.AsyncAccept() = Async.FromBeginEnd(socket.BeginAccept, socket.EndAccept) member socket.AsyncReceive(buffer: byte [], ?offset, ?count) = let offset ..
-
ReceiveActor 예제ETC 2018. 12. 20. 15:29
메시지를 받는 기본 액터객체를 생성해보자using System; using System.Threading; using System.Threading.Tasks; using System.Xml; using Akka.Actor; //메시지 객체public class Greet { public Greet(string who) { Who = who; } public string Who { get; private set; } } //액터 객체public class GreetingActor : ReceiveActor { public GreetingActor() { Receive(greet => { Console.WriteLine("[GreetingActor] :" + greet.Who); }); } } //실행 코..
-
Fsharp.Data (F# Data) Json parsing exampleF# 2016. 10. 20. 00:50
#1. set of properties { "a" : "apple", "b" : "banana", "c" : "cocoa" } open FSharp.Data open FSharp.Data.JsonExtensions [] let main argv = let json_txt= """{"a":"apple","b":"banana","c":"cocoa"}""" JsonValue.Parse(json_txt).Properties |> Array.iter(fun (key,value) -> printfn "%s:%s" key (value.AsString())) 0 // return an integer exit code #2. array of values ["apple","banana","cocoa"] open FShar..