MK
Size: a a a
MK
MK
AP
:t getField
getField :: forall k (x :: k) r a. HasField x r a => r -> a
AP
k
?AP
send :: forall k (x :: k) a m r. (MonadIO m, HasField x r (TQueue a), MonadReader r m) => a -> m ()
send act = do
chan <- asks (getField @x)
atomically $ writeTQueue chan act
AP
AP
MK
send :: forall k (x :: k) a m r. (MonadIO m, HasField x r (TQueue a), MonadReader r m) => a -> m ()
send act = do
chan <- asks (getField @x)
atomically $ writeTQueue chan act
JS
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module B where
import Control.Concurrent.STM
import Control.Monad.IO.Class
import Control.Monad.Reader
import GHC.Records
send ::
forall x m a r.
(MonadIO m, HasField x r (TQueue a), MonadReader r m) => a -> m ()
send a = do
chan <- asks (getField @x)
liftIO $ atomically $ writeTQueue chan a
AP
x0
AP
AP
JS
JS
MK
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module B where
import Control.Concurrent.STM
import Control.Monad.IO.Class
import Control.Monad.Reader
import GHC.Records
send ::
forall x m a r.
(MonadIO m, HasField x r (TQueue a), MonadReader r m) => a -> m ()
send a = do
chan <- asks (getField @x)
liftIO $ atomically $ writeTQueue chan a
MK
JS
AllowAmbiguousTypes
нужен, потому что x нет в типе выражения. откуда его компилятор возьмёт?JS
AP
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module B where
import Control.Concurrent.STM
import Control.Monad.IO.Class
import Control.Monad.Reader
import GHC.Records
send ::
forall x m a r.
(MonadIO m, HasField x r (TQueue a), MonadReader r m) => a -> m ()
send a = do
chan <- asks (getField @x)
liftIO $ atomically $ writeTQueue chan a
Action x a
AP