Skip to content

Instantly share code, notes, and snippets.

@zclod

zclod/test.hs Secret

Last active March 26, 2021 12:34
Show Gist options
  • Save zclod/c8315fa0102329bebd8e88aac84164e8 to your computer and use it in GitHub Desktop.
Save zclod/c8315fa0102329bebd8e88aac84164e8 to your computer and use it in GitHub Desktop.
import Control.Monad.State
import Control.Monad.ST
-- import Control.Lens (use, ix, preview, iso, over, both, Lens', Index, IxValue, Ixed)
import Control.Lens
import Control.Lens.Operators
import Control.Lens.TH (makeLenses)
import Data.Array.ST
import Data.Array.IArray ((!))
data MyState s = MyState { _x :: Word8
, _y :: STUArray s Word8 Word8}
makeLenses ''MyState
newtype Computation s a = Computation {unComp :: StateT (MyState s) (ST s) a}
deriving (Functor,Applicative,Monad,MonadState (MyState s), MArray (STUArray s) Word8 (StateT (MyState s) (ST s)))
readMemory :: Computation s ()
readMemory = do
s <- get
x' <- readArray (s^.y) 0
x .= x'
• ‘MArray (STUArray s) Word8 (StateT (MyState s) (ST s))’ is not a unary constraint, as expected by a deriving clause
• In the newtype declaration for ‘Computation’
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment