Skip to content

&, T tensor #474

@Jashweii

Description

@Jashweii

Is there a reason this isn't present in linear-base? I know you can't make & (co)datatypes directly in Haskell and have to encode them, but it seems like it's worth having. I think I read somewhere the main motivation for not having it was that it doesn't include effects in the choice (aside from places where linearity is used to do allocations etc) but couldn't you just have an effect element and sequence it?

-- movable
data Y a b c where
  L :: Y a b a
  R :: Y a b b

-- a or b, consumer choice
newtype a & b = With (forall c . Y a b c -> c)

-- dupable - easily created (Top ()) and cannot observe difference, not consumable (contains linear resource)
data Top = forall a . Top a

Seems like a fruitful place to look

  • Binary operator & representing exclusive consumer choice
  • Unit ⊤ (or Top) (exclusive consumer choice of 0 things), this is also useful for a type that accumulates all linear resources and cannot be consumed
  • N-ary vector of choices (lazy vector since Ur (a & b) is (a, b))
  • Dependent choice (parameterise Y a b)
  • Various & analogues of classes of functors (monoidal functors, distribution laws, contravariant versions)
  • Optics (e.g. strong wrt &) identifying a choice that can be made within a structure
    Some of this stuff might find use for protocols.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions