Re: runST $ unsafeIOToST $ ioWhatever

Henning Thielemann <[email protected]>
Newsgroups gmane.comp.lang.haskell.cafe
Message-ID <[email protected]>
On Sun, 14 Apr 2024, Folsk Pratima wrote:

> memSet :: Ptr a -> Word8 -> Word32 -> IO (Ptr a)
> memSet ptr _ 0 = return ptr
> memSet ptr byte size = do
>    let voidptr = castPtr ptr :: Ptr Word8
>        acts =
>            map
>                (\i -> pokeByteOff voidptr i byte)
>                [0 .. fromIntegral (size - 1)]
>    mapM_ id acts
>    return ptr

I think you just want
   pokeArray ptr $ replicate (fromIntegral size) byte
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.