Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package-level interface #810

Open
emil14 opened this issue Dec 18, 2024 · 0 comments
Open

Package-level interface #810

emil14 opened this issue Dec 18, 2024 · 0 comments
Assignees

Comments

@emil14
Copy link
Collaborator

emil14 commented Dec 18, 2024

pub interface IKeyValueStore {
    Get<T>(key string) (some T, none any)
    Set<T>(key string, value T) (ok any, err error)
    Delete(key string) (res any, err error)
}

def Foo(sig any) (res any, err error) {
    kv_get IKeyValueStore.Get<int>
    kv_set IKeyValueStore.Set<int>
    kv_del IKeyValueStore.Delete?
    ---
    :sig -> 'foo' -> kv_get
    kv_get:some -> 'bar' -> kv_set
    kv_set:ok -> 'foo' -> kv_del -> :res
}

...

import {
    redis
    runtime
}

def Main(start any) (stop any) {
    foo_redis Foo{redis} // passing a package as a dependency
    panic runtime.Panic
    ---
    :start -> foo_redis
    foo_redis:res -> :stop
    foo_redis:err -> panic
}

Normal interface describes component - input and output ports. Package interface describes package - public components are like methods.

@emil14 emil14 self-assigned this Dec 18, 2024
@emil14 emil14 added Critical and removed Minor labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant