Skip to content

Question: How to make library classes work with own runtime implementations? #1231

Answered by louthy
aloslider asked this question in Q&A
Discussion options

You must be logged in to vote

First thing is that you can't have your own HasCancel<RT> unless you extend the original trait/interface. It is the only thing that's built-in to the asynchronous effects (Aff) system, because it's the trait that allows you to cancel an asynchronous process.

The key thing to note is that because the 'traits' are just interfaces, they can be extended through inheritance. I would 'extend' the current console trait and interface:

    public interface ConsoleExtendedIO : ConsoleIO
    {
        public Option<ConsoleKeyInfo> ReadKey(bool hideKeys);
    }

    public interface HasConsoleExtended<RT> : HasConsole<RT>
       where RT : struct, HasCancel<RT>
    {
        Eff<RT, ConsoleExtendedIO>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aloslider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants