-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
I spent considerable time searching the base-linear
library for a function that would allow me to use a unrestricted function as a linear one provided the domain is Moveable
. Is there something like that?
If not, these could be sensible additions to the library:
applyMove :: Movable a => (a -> b) %1 -> a %1 -> b
applyMove f x = f `applyUr` move x
applyUr :: (a -> b) %1 -> Ur a %1 -> b
applyUr f (Ur a) = f a
Example use:
import Control.Functor.Linear
import Data.HashMap.Mutual.Linear
lookupSt :: String %1 -> State (HashMap String v) (Ur (Maybe v))
lookupSt k = state (lookup `applyMove` k)
-- lookup :: String -> HashMap String v %1 -> ...
Bikeshedding of the names welcome!
Maybe there are suitable operators for these function reminiscent of $
.
Metadata
Metadata
Assignees
Labels
No labels