Transaction Type Security

I have a Transaction monad that looks like this:

newtype Transaction t m a = .. my monad stack here ..

t is the type of phantom that I use to make sure that the transactions I connect belong to the same file storage.

In my main loop iteration, a type type is used:

Transaction DB IO (Widget (Transaction DB IO ()))

The above type means: "a transaction that generates a user interface widget whose user inputs are converted to transactions for execution."

In addition, I have:

data Property m a = Property { get :: m a, set :: a -> m () }

which is extremely useful (especially because of its ability to link with FCLabels.

I make a lot of use Property (Transaction t m)to create my transactions.

, , , , , , , .

-, phantom, :

  • Transaction ReadOnly Transaction ReadWrite . , , .

  • , , /, "m" ReadWrite. -, .

, .

+3
1

, " " "-", . , :

data Property rm wm a = Property { get :: rm a, set :: a -> wm () }

. :

newtype Transaction t c m a = .. my monad stack here

data Property mc c1 c2 a = Property { get :: mc c1 a, set :: a -> mc c2 () }

mc - ; . , , , .

, , .

newtype ReadOnly = ReadOnly

newtype ReadWrite = ReadWrite

class ReadContext rm where

class WriteContext rm where

instance ReadContext ReadOnly where
instance ReadContext ReadWrite where

instance WriteContext ReadWrite where

someGetter :: ReadContext c => Transaction t c m a

someSetter :: WriteContext c => a -> Transaction t c m ()

/, , .

+3

Source: https://habr.com/ru/post/1756087/


All Articles