lenses - Why can't I bind and reuse a haskell lens like a normal variable? -
(i'm using lens-family, not lens)
i have deep data structure , need focus on 2 parts have common path. intuitively define _table
intention reuse it:
let _table = _soutput.at (o.tname table)._just' tp' <- evalcacheable (_table.o._stperm) m.empty ... reuse _table
but yields error:
could not deduce (functor f0) arising use of ‘_soutput’ context (monadreader (evalconf state all) m, ...
yet, directly pasting value of _table
argument works:
tp' <- evalcacheable (_soutput.at (o.tname table)._just'.o._stperm) m.empty
what going on? can give more details types involved, me seems puzzling regardless. under impression that
let x = y z <- f x
was equivalent to
z <- f y
in cases.
this related monomorphism restriction. try putting {-# language nomonomorphismrestriction #-}
@ top of file. –randomusername
it worked! on #haskell
solved adding explicit type signature _table
. according him rank2types
messing type inference. – bruceberry
Comments
Post a Comment