midas/task

Types

pub type Effect(a, key) {
  Done(a)
  Abort(snag.Snag)
  Bundle(
    module: String,
    function: String,
    resume: fn(Result(String, String)) -> Effect(a, key),
  )
  ExportJsonWebKey(
    key: key,
    resume: fn(Result(json.Json, String)) -> Effect(a, key),
  )
  Follow(
    uri: String,
    resume: fn(Result(uri.Uri, Nil)) -> Effect(a, key),
  )
  Fetch(
    request: request.Request(BitArray),
    resume: fn(Result(response.Response(BitArray), FetchError)) -> Effect(
      a,
      key,
    ),
  )
  GenerateKeyPair(
    algorithm: KeyPairAlgorithm,
    extractable: Bool,
    usages: List(KeyUsage),
    resume: fn(Result(KeyPair(key), String)) -> Effect(a, key),
  )
  Hash(
    algorithm: HashAlgorithm,
    bytes: BitArray,
    resume: fn(Result(BitArray, String)) -> Effect(a, key),
  )
  List(
    directory: String,
    resume: fn(Result(List(String), String)) -> Effect(a, key),
  )
  Log(
    message: String,
    resume: fn(Result(Nil, Nil)) -> Effect(a, key),
  )
  Read(
    file: String,
    resume: fn(Result(BitArray, String)) -> Effect(a, key),
  )
  Serve(
    port: option.Option(Int),
    handle: fn(request.Request(BitArray)) -> response.Response(
      BitArray,
    ),
    resume: fn(Result(Nil, String)) -> Effect(a, key),
  )
  Sign(
    algorithm: SignAlgorithm,
    key: key,
    data: BitArray,
    resume: fn(Result(BitArray, String)) -> Effect(a, key),
  )
  StrongRandom(
    length: Int,
    resume: fn(Result(BitArray, String)) -> Effect(a, key),
  )
  Write(
    file: String,
    bytes: BitArray,
    resume: fn(Result(Nil, String)) -> Effect(a, key),
  )
  Visit(
    uri: uri.Uri,
    resume: fn(Result(Nil, String)) -> Effect(a, key),
  )
  Zip(
    files: List(#(String, BitArray)),
    resume: fn(Result(BitArray, Nil)) -> Effect(a, key),
  )
  UnixNow(resume: fn(Int) -> Effect(a, key))
}

Constructors

  • Done(a)
  • Abort(snag.Snag)
  • Bundle(
      module: String,
      function: String,
      resume: fn(Result(String, String)) -> Effect(a, key),
    )
  • ExportJsonWebKey(
      key: key,
      resume: fn(Result(json.Json, String)) -> Effect(a, key),
    )
  • Follow(
      uri: String,
      resume: fn(Result(uri.Uri, Nil)) -> Effect(a, key),
    )
  • Fetch(
      request: request.Request(BitArray),
      resume: fn(Result(response.Response(BitArray), FetchError)) -> Effect(
        a,
        key,
      ),
    )
  • GenerateKeyPair(
      algorithm: KeyPairAlgorithm,
      extractable: Bool,
      usages: List(KeyUsage),
      resume: fn(Result(KeyPair(key), String)) -> Effect(a, key),
    )
  • Hash(
      algorithm: HashAlgorithm,
      bytes: BitArray,
      resume: fn(Result(BitArray, String)) -> Effect(a, key),
    )
  • List(
      directory: String,
      resume: fn(Result(List(String), String)) -> Effect(a, key),
    )
  • Log(
      message: String,
      resume: fn(Result(Nil, Nil)) -> Effect(a, key),
    )
  • Read(
      file: String,
      resume: fn(Result(BitArray, String)) -> Effect(a, key),
    )
  • Serve(
      port: option.Option(Int),
      handle: fn(request.Request(BitArray)) -> response.Response(
        BitArray,
      ),
      resume: fn(Result(Nil, String)) -> Effect(a, key),
    )
  • Sign(
      algorithm: SignAlgorithm,
      key: key,
      data: BitArray,
      resume: fn(Result(BitArray, String)) -> Effect(a, key),
    )
  • StrongRandom(
      length: Int,
      resume: fn(Result(BitArray, String)) -> Effect(a, key),
    )
  • Write(
      file: String,
      bytes: BitArray,
      resume: fn(Result(Nil, String)) -> Effect(a, key),
    )
  • Visit(
      uri: uri.Uri,
      resume: fn(Result(Nil, String)) -> Effect(a, key),
    )
  • Zip(
      files: List(#(String, BitArray)),
      resume: fn(Result(BitArray, Nil)) -> Effect(a, key),
    )
  • UnixNow(resume: fn(Int) -> Effect(a, key))
pub type FetchError {
  NetworkError(String)
  UnableToReadBody
  NotImplemented
}

Constructors

  • NetworkError(String)
  • UnableToReadBody
  • NotImplemented
pub type HashAlgorithm {
  SHA1
  SHA256
  SHA384
  SHA512
}

Constructors

  • SHA1
  • SHA256
  • SHA384
  • SHA512
pub type KeyPair(key) {
  KeyPair(public: key, private: key)
}

Constructors

  • KeyPair(public: key, private: key)
pub type KeyPairAlgorithm {
  EcKeyGenParams(name: String, named_curve: String)
}

Constructors

  • EcKeyGenParams(name: String, named_curve: String)
pub type KeyUsage {
  CanEncrypt
  CanDecrypt
  CanSign
  CanVerify
  CanDeriveKey
  CanDeriveBits
  CanWrapKey
  CanUnwrapKey
}

Constructors

  • CanEncrypt
  • CanDecrypt
  • CanSign
  • CanVerify
  • CanDeriveKey
  • CanDeriveBits
  • CanWrapKey
  • CanUnwrapKey
pub type SignAlgorithm {
  EcdsaParams(hash: HashAlgorithm)
}

Constructors

Values

pub fn abort(value: snag.Snag) -> Effect(a, b)
pub fn bundle(m: String, f: String) -> Effect(String, a)
pub fn catch_error(
  task: Effect(a, b),
) -> Effect(Result(a, snag.Snag), b)
pub fn do(
  eff: Effect(a, b),
  then: fn(a) -> Effect(c, b),
) -> Effect(c, b)
pub fn done(value: a) -> Effect(a, b)
pub fn each(
  items: List(a),
  run: fn(a) -> Effect(b, c),
) -> Effect(List(b), c)
pub fn expect_abort(
  task: Effect(a, b),
) -> Result(snag.Snag, Effect(a, b))
pub fn expect_bundle(
  task: Effect(a, b),
) -> Result(
  #(String, String, fn(Result(String, String)) -> Effect(a, b)),
  Effect(a, b),
)
pub fn expect_done(task: Effect(a, b)) -> Result(a, Effect(a, b))
pub fn expect_export_jwk(
  task: Effect(a, b),
) -> Result(
  #(b, fn(Result(json.Json, String)) -> Effect(a, b)),
  Effect(a, b),
)
pub fn expect_fetch(
  task: Effect(a, b),
) -> Result(
  #(
    request.Request(BitArray),
    fn(Result(response.Response(BitArray), FetchError)) -> Effect(
      a,
      b,
    ),
  ),
  Effect(a, b),
)
pub fn expect_follow(
  task: Effect(a, b),
) -> Result(
  #(String, fn(Result(uri.Uri, Nil)) -> Effect(a, b)),
  Effect(a, b),
)
pub fn expect_generate_keypair(
  task: Effect(a, b),
) -> Result(
  #(
    KeyPairAlgorithm,
    Bool,
    List(KeyUsage),
    fn(Result(KeyPair(b), String)) -> Effect(a, b),
  ),
  Effect(a, b),
)
pub fn expect_hash(
  task: Effect(a, b),
) -> Result(
  #(
    HashAlgorithm,
    BitArray,
    fn(Result(BitArray, String)) -> Effect(a, b),
  ),
  Effect(a, b),
)
pub fn expect_list(
  task: Effect(a, b),
) -> Result(
  #(String, fn(Result(List(String), String)) -> Effect(a, b)),
  Effect(a, b),
)
pub fn expect_log(
  task: Effect(a, b),
) -> Result(
  #(String, fn(Result(Nil, Nil)) -> Effect(a, b)),
  Effect(a, b),
)
pub fn expect_read(
  task: Effect(a, b),
) -> Result(
  #(String, fn(Result(BitArray, String)) -> Effect(a, b)),
  Effect(a, b),
)
pub fn expect_serve(
  task: Effect(a, b),
) -> Result(
  #(
    option.Option(Int),
    fn(request.Request(BitArray)) -> response.Response(BitArray),
    fn(Result(Nil, String)) -> Effect(a, b),
  ),
  Effect(a, b),
)
pub fn expect_sign(
  task: Effect(a, b),
) -> Result(
  #(
    SignAlgorithm,
    b,
    BitArray,
    fn(Result(BitArray, String)) -> Effect(a, b),
  ),
  Effect(a, b),
)
pub fn expect_strong_random(
  task: Effect(a, b),
) -> Result(
  #(Int, fn(Result(BitArray, String)) -> Effect(a, b)),
  Effect(a, b),
)
pub fn expect_unix_now(
  task: Effect(a, b),
) -> Result(fn(Int) -> Effect(a, b), Effect(a, b))
pub fn expect_visit(
  task: Effect(a, b),
) -> Result(
  #(uri.Uri, fn(Result(Nil, String)) -> Effect(a, b)),
  Effect(a, b),
)
pub fn expect_write(
  task: Effect(a, b),
) -> Result(
  #(String, BitArray, fn(Result(Nil, String)) -> Effect(a, b)),
  Effect(a, b),
)
pub fn expect_zip(
  task: Effect(a, b),
) -> Result(
  #(
    List(#(String, BitArray)),
    fn(Result(BitArray, Nil)) -> Effect(a, b),
  ),
  Effect(a, b),
)
pub fn export_jwk(key: a) -> Effect(json.Json, a)
pub fn fetch(
  request: request.Request(BitArray),
) -> Effect(response.Response(BitArray), a)
pub fn follow(uri: String) -> Effect(uri.Uri, a)
pub fn generate_keypair(
  algorithm: KeyPairAlgorithm,
  extractable: Bool,
  usages: List(KeyUsage),
) -> Effect(KeyPair(a), a)
pub fn hash(
  algorithm: HashAlgorithm,
  bytes: BitArray,
) -> Effect(BitArray, a)
pub fn list(file: String) -> Effect(List(String), a)
pub fn log(message: String) -> Effect(Nil, a)
pub fn proxy(
  task: Effect(a, b),
  scheme: http.Scheme,
  host: String,
  port: option.Option(Int),
  prefix: String,
) -> Effect(a, b)
pub fn read(file: String) -> Effect(BitArray, a)
pub fn sequential(
  tasks: List(Effect(a, b)),
) -> Effect(List(a), b)
pub fn serve(
  port: option.Option(Int),
  handle: fn(request.Request(BitArray)) -> response.Response(
    BitArray,
  ),
) -> Effect(Nil, a)
pub fn serve_static(
  port: option.Option(Int),
  files: List(#(String, BitArray)),
) -> Effect(Nil, a)
pub fn sign(
  algorithm: SignAlgorithm,
  key: a,
  data: BitArray,
) -> Effect(BitArray, a)
pub fn strong_random(length: Int) -> Effect(BitArray, a)
pub fn try(
  result: Result(a, snag.Snag),
  then: fn(a) -> Effect(b, c),
) -> Effect(b, c)
pub fn unix_now() -> Effect(Int, a)
pub fn visit(message: uri.Uri) -> Effect(Nil, a)
pub fn write(file: String, bytes: BitArray) -> Effect(Nil, a)
pub fn zip(
  message: List(#(String, BitArray)),
) -> Effect(BitArray, a)
Search Document