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

Genericize generic types #22

Open
propensive opened this issue Jan 2, 2025 · 0 comments
Open

Genericize generic types #22

propensive opened this issue Jan 2, 2025 · 0 comments
Assignees
Labels
api Relates to the API design core Describes core required functionality enhancement An improvement to existing functionality minor Has only a small impact for the majority of users

Comments

@propensive
Copy link
Owner

Rather than introduce different generic traits to represent various proto-typeclasses for converting libraries' types to a lowest-common-denominator representation, with "specific" counterparts for converting back, it might be possible to use just two:

trait Specializable:
  type Operand
  type Self
  type Domain
  def specialize(op: Operand): Self

trait Generalizable:
  type Self
  type Result
  type Domain
  def generalize(op: Self): Result

With additional definitions, such as:

erased trait Instants
erased trait Durations
erased trait Paths

we can have given instances such as, MyInstant is Generalizable across Instants into Long and MyPath is Specializable across Paths by Text.

Then, we can define general methods:

def runningTime[T: Specializable across Durations by Long]: T = T.specialize(now() - start)

or,

def load[P: Generalizable across Paths by Text](path: P): Bytes = Io.loadByFilename(P.generalize(path.s))
@propensive propensive self-assigned this Jan 2, 2025
@propensive propensive added enhancement An improvement to existing functionality api Relates to the API design minor Has only a small impact for the majority of users core Describes core required functionality labels Jan 2, 2025
@github-project-automation github-project-automation bot moved this to Todo in Soundness Jan 2, 2025
propensive added a commit to propensive/soundness that referenced this issue Jan 31, 2025
propensive added a commit to propensive/soundness that referenced this issue Jan 31, 2025
propensive added a commit to propensive/soundness that referenced this issue Feb 4, 2025
* Start work on propensive/anticipation#22

* Use generalized instants

* More work on build, towards generalized URLs

* Update submodules with generic URLs

* Rename `Generalizable` to `Abstractable`; `Specializable` to `Concretizable`

* Further progress abstracting over abstraction

* Updates to build and submodules

* Obviate `SpecificUrl`

* Obviate `GenericHttpRequest`

* Refactor `Postable` typeclass and make Anticipation HTTP support more generic

* Clean up generic types for HTTP

* Eliminate one generic HTML typeclass; one remains
@propensive propensive moved this from Todo to Started in Soundness Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Relates to the API design core Describes core required functionality enhancement An improvement to existing functionality minor Has only a small impact for the majority of users
Projects
Status: Started
Development

No branches or pull requests

1 participant