Skip to content

Commit

Permalink
Merge pull request #70 from stefan-hoeck/editor_iso
Browse files Browse the repository at this point in the history
[ new ] view an editor through an isomorphism
  • Loading branch information
stefan-hoeck committed Apr 21, 2024
2 parents 4e1472a + 23f2dfb commit fd0c4b3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions extra/src/Web/MVC/Controller.idr
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ record Editor (i,st,ev,new : Type) where
||| Create an initial state from an optional value of type `new`
toState : Maybe new -> st

||| View an editor through an isomorphism.
export
newIso : Iso' n1 n2 -> Editor i st ev n1 -> Editor i st ev n2
newIso i = {stToNew $= (map i.get_ .), toState $= (. map i.reverseGet)}

||| Utility for editors without initial command.
export %inline
noInit : i -> s -> Cmd e
Expand Down

0 comments on commit fd0c4b3

Please sign in to comment.