为什么通用量化变量不在此Haskell函数的范围内?

bba*_*ker 5 haskell

我确信我已经能够在其他情况下执行类似的操作,并且我相信这应该是可能的(/sf/answers/3513516331/):

{-# LANGUAGE TypeApplications     #-}

module FDS.Database where

import           Data.Typeable
import           RIO                              (RIO)
-- other imports omitted

cowRecsByMark :: IsCowRec r => CowMark -> RIO FdsEnv [r]
cowRecsByMark markIn = do
  cs <- initCass
  liftIO $ cassGetRecsByMark cs tblName markIn
  where tblName = type2tblName $ typeRep $ Proxy @r
Run Code Online (Sandbox Code Playgroud)

但是有了这段代码,我得到:

: error: Not in scope: type variable ‘r’                                                                     
   |
24 |   where tblName = type2tblName $ typeRep $ Proxy @r
   |                                                   ^
Run Code Online (Sandbox Code Playgroud)