4
4
{-# LANGUAGE FlexibleContexts #-}
5
5
{-# LANGUAGE FlexibleInstances #-}
6
6
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
7
+ {-# LANGUAGE KindSignatures #-}
7
8
{-# LANGUAGE LambdaCase #-}
8
9
{-# LANGUAGE LinearTypes #-}
10
+ {-# LANGUAGE PolyKinds #-}
9
11
{-# LANGUAGE QuantifiedConstraints #-}
10
12
{-# LANGUAGE ScopedTypeVariables #-}
11
13
{-# LANGUAGE StandaloneDeriving #-}
18
20
module Data.Unrestricted.Linear.Internal.Movable
19
21
( -- * Movable
20
22
Movable (.. ),
23
+ ($^) ,
21
24
GMovable ,
22
25
genericMove ,
23
26
)
@@ -30,12 +33,11 @@ import qualified Data.Semigroup as Semigroup
30
33
import Data.Unrestricted.Linear.Internal.Dupable
31
34
import Data.Unrestricted.Linear.Internal.Ur
32
35
import GHC.Tuple (Solo )
33
- import GHC.Types ( Multiplicity ( .. ))
36
+ import GHC.Types
34
37
import Generics.Linear
35
38
import Prelude.Linear.Generically
36
39
import Prelude.Linear.Internal
37
40
import qualified Unsafe.Linear as Unsafe
38
- import Prelude (Bool (.. ), Char , Double , Float , Int , Ordering (.. ), Word )
39
41
import qualified Prelude as Prelude
40
42
41
43
-- | Use @'Movable' a@ to represent a type which can be used many times even
@@ -56,6 +58,11 @@ import qualified Prelude as Prelude
56
58
class Dupable a => Movable a where
57
59
move :: a % 1 -> Ur a
58
60
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
+
59
66
-- -------------
60
67
-- Instances
61
68
0 commit comments