44{-# LANGUAGE FlexibleContexts #-}
55{-# LANGUAGE FlexibleInstances #-}
66{-# LANGUAGE GeneralizedNewtypeDeriving #-}
7+ {-# LANGUAGE KindSignatures #-}
78{-# LANGUAGE LambdaCase #-}
89{-# LANGUAGE LinearTypes #-}
10+ {-# LANGUAGE PolyKinds #-}
911{-# LANGUAGE QuantifiedConstraints #-}
1012{-# LANGUAGE ScopedTypeVariables #-}
1113{-# LANGUAGE StandaloneDeriving #-}
1820module Data.Unrestricted.Linear.Internal.Movable
1921 ( -- * Movable
2022 Movable (.. ),
23+ ($^) ,
2124 GMovable ,
2225 genericMove ,
2326 )
@@ -30,12 +33,11 @@ import qualified Data.Semigroup as Semigroup
3033import Data.Unrestricted.Linear.Internal.Dupable
3134import Data.Unrestricted.Linear.Internal.Ur
3235import GHC.Tuple (Solo )
33- import GHC.Types ( Multiplicity ( .. ))
36+ import GHC.Types
3437import Generics.Linear
3538import Prelude.Linear.Generically
3639import Prelude.Linear.Internal
3740import qualified Unsafe.Linear as Unsafe
38- import Prelude (Bool (.. ), Char , Double , Float , Int , Ordering (.. ), Word )
3941import qualified Prelude as Prelude
4042
4143-- | Use @'Movable' a@ to represent a type which can be used many times even
@@ -56,6 +58,11 @@ import qualified Prelude as Prelude
5658class Dupable a => Movable a where
5759 move :: a % 1 -> Ur a
5860
61+ ($^) :: forall {rep } a (b :: TYPE rep ). Movable a => (a -> b ) % 1 -> a % 1 -> b
62+ f $^ a =
63+ move a & \ case
64+ Ur a' -> f a'
65+
5966-- -------------
6067-- Instances
6168
0 commit comments