<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>A `Word8` would be enough instead of 4 or 8 bytes for `CInt`.<br>
    </p>
    <div class="moz-cite-prefix">On 08/10/2019 17:33, Sven Panne wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CANBN=muJ+j=LFZMT5bBbARn0CS2tmgxZRXQ0F2vO4GmOcHHNHg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">Am Di., 8. Okt. 2019 um 16:57 Uhr schrieb Simon
          Jakobi via Libraries <<a
            href="mailto:libraries@haskell.org" moz-do-not-send="true">libraries@haskell.org</a>>:<br>
        </div>
        <div class="gmail_quote">
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            <div dir="ltr">That seems like a good idea! [...]</div>
          </blockquote>
          <div><br>
          </div>
          <div>Looks OK, but let's use toEnum in peekElemOff:</div>
          <div><br>
          </div>
          <div>  instance Storable Ordering where<br>
                sizeOf _ = sizeOf (undefined :: CInt)<br>
                alignment _ = alignment (undefined :: CInt)<br>
                peekElemOff p i = toEnum . fromIntegral <$>
            peekElemOff (castPtr p :: Ptr CInt) i<br>
                pokeElemOff p i = pokeElemOff (castPtr p :: Ptr CInt) i
            . fromIntegral . fromEnum</div>
          <div><br>
          </div>
          <div>This is more symmetrical with pokeElemOff and less
            obfuscated. Note that the instance works for every Enum, so
            if there are more cases like Ordering, it might be worth to
            abstract that out.<br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Libraries mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Libraries@haskell.org">Libraries@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>
</pre>
    </blockquote>
  </body>
</html>