-
-
Save zclod/c8315fa0102329bebd8e88aac84164e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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