Inaccessible fields in records
A bit more [indirectly] regarding m开发者_JS百科y previous question: there, my definition of lens was
data Iso α β = Iso { fw :: α -> β, bw :: β -> α }
data Lens α β = forall r. Lens (Iso α (β, r))
And this is fine, as long as the module is imported unqualified. Problems begin with the case where it is, and, for import qualified Util.Lens as L
, I get an error about fw
not being a (visible) field of constructor Iso
. The code itself is trivial,
data BValue = BValue { p :: Float, d :: Float, q :: Float } deriving Show
pLens :: L.Lens BValue Float
pLens = L.Lens (L.Iso { fw = pFwd, bw = pBwd })
The Util.Lens exports both Lens(..)
and Iso(..)
. TIA.
The record fields need to be qualified as well, i.e.:
L.Iso { L.fw = pFwd, L.bw = pBwd }
精彩评论