You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first of all I would like to say Thank you for your enormous effort to keep it up.
I am at the beginning of my FP journey, so sorry for all the questions coming. 😃
Here is QueueExample from Samples in a bit modified version.
I have two issues:
I wont see this line from _2 in Eff(fun(() => Console.WriteLine("I can't see this line"))), probably forked task never gets cancelled.
I have an IDisposable object new TcpClient("127.0.0.1", 23), but I don't know how to use use (I tried, but it was already closed).
An additional question, in WriteToQueue I have to use ternary operator to check whether x is empty or not. Why the more elegant guard(notEmpty(x), Errors.Cancelled) is not work for me (Type arguments cannot be inferred...)?
Thanks for your help in advance.
Best Regards, András
publicclassQueueExample<RT>whereRT:struct,HasCancel<RT>,HasConsole<RT>{publicstaticAff<RT,Unit>Main(){varqueue=Queue<RT,string>();returnfromstreaminEff(()=>newTcpClient("127.0.0.1",23).GetStream())fromcinfork(queue|WriteToClient(stream))fromxinrepeat(Console<RT>.readLines)|WriteToQueue(queue)from_2inEff(fun(()=>Console.WriteLine("I can't see this line")))from_1inc// cancels the forked taskselectunit;}privatestaticConsumer<RT,string,Unit>WriteToQueue(Queue<RT,string,Unit>queue)=>fromxinawaiting<string>()// from _ in guard(notEmpty(x), Errors.Cancelled) from_innotEmpty(x)?queue.EnqueueEff(x):FailEff<Unit>(Errors.Cancelled)selectunit;privatestaticConsumer<RT,string,Unit>WriteToClient(Streamstream)=>fromlinawaiting<string>()from_1inConsole<RT>.writeLine(l)from_2inEff(fun(()=>stream.Write(Encoding.ASCII.GetBytes(l))))selectunit;}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Paul,
first of all I would like to say Thank you for your enormous effort to keep it up.
I am at the beginning of my FP journey, so sorry for all the questions coming. 😃
Here is
QueueExamplefromSamplesin a bit modified version.I have two issues:
from _2 in Eff(fun(() => Console.WriteLine("I can't see this line"))), probably forked task never gets cancelled.IDisposableobjectnew TcpClient("127.0.0.1", 23), but I don't know how to useuse(I tried, but it was already closed).An additional question, in
WriteToQueueI have to use ternary operator to check whetherxis empty or not. Why the more elegantguard(notEmpty(x), Errors.Cancelled)is not work for me (Type arguments cannot be inferred...)?Thanks for your help in advance.
Best Regards,
András
Beta Was this translation helpful? Give feedback.
All reactions