Skip to content

Comments

Implement elimPropInv for profunctor optics extraction#51

Draft
Copilot wants to merge 3 commits intorowtypes-with-halflenses-and-halfprismsfrom
copilot/implement-todo-in-elimpropp
Draft

Implement elimPropInv for profunctor optics extraction#51
Copilot wants to merge 3 commits intorowtypes-with-halflenses-and-halfprismsfrom
copilot/implement-todo-in-elimpropp

Conversation

Copy link

Copilot AI commented Nov 25, 2025

The elimPropInv function was stubbed with unsafeThrow "TODO". This function extracts the elimination function s -> Tuple t o from a profunctor optic encoding.

Implementation

Dual-instance approach to extract both components:

  • Extract t: Use function instance f (const unit) s which applies the (->) instance that preserves the eliminated structure
  • Extract o: Use Cont instance with unwrap (f (Cont \_ -> identity)) (unsafeCoerce unit :: t -> o) s

Limitation

The Cont instance's liftElimProp ignores its input and discards the o component from Tuple s o, making extraction without unsafeCoerce impossible with the current encoding. This mirrors similar limitations in editPropInv (also TODO).

-- Before: crashes at runtime
elimPropInv f s = unsafeThrow "TODO"

-- After: functional extraction
elimPropInv f s = 
  let t = f (const unit) s
      o = unwrap (f (Cont \_ -> identity)) (unsafeCoerce unit :: t -> o) s
  in Tuple t o
Original prompt

Work on TODO: : (from bambik/src/Data/Profunctor/ElimPropP.purs)

Created from VS Code via the GitHub Pull Request extension.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 25, 2025 14:52
Co-authored-by: erykciepiela <5385827+erykciepiela@users.noreply.github.com>
Co-authored-by: erykciepiela <5385827+erykciepiela@users.noreply.github.com>
Copilot AI changed the title [WIP] Work on TODO in ElimPropP module Implement elimPropInv for profunctor optics extraction Nov 25, 2025
Copilot AI requested a review from erykciepiela November 25, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants