Skip to content

Split the internal and external representation of LookupTables #573

@TurtlePU

Description

@TurtlePU

As of now, the internal (what's stored inside ArithmeticCircuit) and external (what's used in MonadCircuit interface) representations coincide: there's a unique LookupTable type. However, it is a bit clunky:

  • on user side, having to first call registerFunction is non-intuitive;
  • on implementation side, having this GADT-inside-existential is much harder to work with than its possible simply typed counterpart with erased functor parameter.

So I propose to split this in two types:

-- | Type for MonadCircuit API
data LookupTable a f where
  ... same as before ...
  Plot :: (forall w. IsWitness a w => f w -> g w) -> LookupTable a f -> LookupTable a (f :*: g)
  -- ^ note the use of function instead of its ID

-- | Type for internal use
newtype FunctionId = FunctionId ByteString
data LookupType a -- note the absence of functor parameter
  = LTRanges (Set (a, a))
  | LTProduct (LookupType a) (LookupType a)
  | LTPlot FunctionId (LookupType a)

Metadata

Metadata

Assignees

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