touch_grass/harness/browser

The harness describes all the effects available in an execution environment. This is similar to the Hardware Abstraction Layer (HAL) from the rust ecosystem. Or platforms in from Roc ecosystem.

The touch grass library consists of modules that specify individual interfaces to the platform. For example Log, with definitions for types and casting values.

The browser workspace/environment is a collection of all effects available in the browser platform. The browser workspace can look very similar to the cli workspace, but might have a different implementation.

The harness specification is not shared with the cli specification because there are a few differences in effects available. Consistency accross platforms is managed by resusing touch_grass interfaces

Types

pub type Effect {
  Abort(String)
  Alert(String)
  Copy(String)
  DecodeJson(BitArray)
  Download(download.Input)
  Fetch(request.Request(BitArray))
  Flip
  Now
  Paste
  Print(String)
  Prompt(String)
  Random(Int)
  Visit(uri.Uri)
  Spotless(
    service: Service,
    operation: operation.Operation(BitArray),
  )
}

Constructors

The harness types concretly implementing the browser harness effect types

pub type Harness(a, b) =
  List(interface.Interface(Effect, a, b))
pub type Service {
  DNSimple
  GitHub
  Vimeo
}

Constructors

  • DNSimple
  • GitHub
  • Vimeo

Values

pub fn cast(
  label: String,
  input: value.Value(a, b),
) -> Result(Effect, break.Reason(a, b))
pub fn decode_list(
  harness: List(interface.Interface(a, b, c)),
) -> List(
  #(
    String,
    fn(value.Value(b, c)) -> Result(a, break.Reason(b, c)),
  ),
)
pub fn effect_label(service: Service) -> String
pub fn effects() -> List(interface.Interface(Effect, a, b))
pub fn infer_context(
  references: dict.Dict(v1.Cid, isomorphic.Type(#(Bool, Int))),
) -> contextual.Context
pub fn take(
  labels: List(String),
) -> List(interface.Interface(Effect, a, b))
pub fn types(
  harness: List(interface.Interface(Effect, a, b)),
) -> List(
  #(String, #(isomorphic.Type(Int), isomorphic.Type(Int))),
)
Search Document