<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.E-mailStijl17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1070998685;
        mso-list-type:hybrid;
        mso-list-template-ids:2138766236 1246146846 68354051 68354053 68354049 68354051 68354053 68354049 68354051 68354053;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:88.8pt;
        text-indent:-18.0pt;
        font-family:Wingdings;
        mso-fareast-font-family:"Times New Roman";
        mso-bidi-font-family:"Courier New";}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:124.8pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:160.8pt;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:196.8pt;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:232.8pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:268.8pt;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:304.8pt;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:340.8pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:376.8pt;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l1
        {mso-list-id:1209879181;
        mso-list-type:hybrid;
        mso-list-template-ids:1115730392 2123894330 68354051 68354053 68354049 68354051 68354053 68354049 68354051 68354053;}
@list l1:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:90.0pt;
        text-indent:-18.0pt;
        font-family:Wingdings;
        mso-fareast-font-family:"Times New Roman";
        mso-bidi-font-family:"Courier New";}
@list l1:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:126.0pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l1:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:162.0pt;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l1:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:198.0pt;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l1:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:234.0pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l1:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:270.0pt;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l1:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:306.0pt;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l1:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:342.0pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l1:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:378.0pt;
        text-indent:-18.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>David, <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>I tried your first suggestion $!. Nothing changed.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>When I tried ‘Right <$> evaluate (TE.decodeUtf8 bufferStrict)’ success. handleException catches the exception. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>I don’t understand why. Maybe the documentation for the evaluate function below has to do with it:<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;background:white'><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>There is a subtle difference between </span><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Control-Exception-Base.html#v:evaluate" title=Control.Exception.Base><span lang=EN-US style='color:#AB6954'>evaluate</span></a></span></code><code><span lang=EN-US style='font-size:10.0pt;color:black'> x</span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'> and </span><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Control-Monad.html#v:return" title=Control.Monad><span lang=EN-US style='color:#AB6954'>return</span></a></span></code><code><span lang=EN-US style='font-size:10.0pt;color:black'> </span></code><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html#v:-36--33-" title=Prelude><span lang=EN-US style='color:#AB6954'>$!</span></a></span></code><code><span lang=EN-US style='font-size:10.0pt;color:black'> x</span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>, analogous to the difference between </span><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Control-Exception-Base.html#v:throwIO" title=Control.Exception.Base><span lang=EN-US style='color:#AB6954'>throwIO</span></a></span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'> and </span><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Control-Exception-Base.html#v:throw" title=Control.Exception.Base><span lang=EN-US style='color:#AB6954'>throw</span></a></span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>. If the lazy value </span><code><span lang=EN-US style='font-size:10.0pt;color:black'>x</span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'> throws an exception, </span><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Control-Monad.html#v:return" title=Control.Monad><span lang=EN-US style='color:#AB6954'>return</span></a></span></code><code><span lang=EN-US style='font-size:10.0pt;color:black'> </span></code><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html#v:-36--33-" title=Prelude><span lang=EN-US style='color:#AB6954'>$!</span></a></span></code><code><span lang=EN-US style='font-size:10.0pt;color:black'> x</span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'> will fail to return an </span><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/System-IO.html#t:IO" title=System.IO><span lang=EN-US style='color:#AB6954'>IO</span></a></span></code><code><span style='font-size:10.0pt;color:black'> </span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>action and will throw an exception instead. </span><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Control-Exception-Base.html#v:evaluate" title=Control.Exception.Base><span lang=EN-US style='color:#AB6954'>evaluate</span></a></span></code><code><span lang=EN-US style='font-size:10.0pt;color:black'> x</span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>, on the other hand, always produces an </span><code><span style='font-size:10.0pt;color:black'><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/System-IO.html#t:IO" title=System.IO><span lang=EN-US style='color:#AB6954'>IO</span></a></span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'> action; that action will throw an exception upon <em><span style='font-family:"Arial",sans-serif'>execution</span></em> iff </span><code><span lang=EN-US style='font-size:10.0pt;color:black'>x</span></code><span lang=EN-US style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'> throws an exception upon <em><span style='font-family:"Arial",sans-serif'>evaluation</span></em>.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>I don’t fully understand this, but evaluate works. Thanks!<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Kees<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#DCDCAA'>readCDFile</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>::</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>FilePath</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>-></span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>FilePath</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>-></span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>IO</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> (</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>Either</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>String</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>T</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>.</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>Text</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>)<o:p></o:p></span></p><p class=MsoNormal style='line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>readCDFile baseDir fn = </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#C586C0'>do</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'><o:p></o:p></span></p><p class=MsoNormal style='line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>  catch ( </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#C586C0'>do</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> <o:p></o:p></span></p><p class=MsoNormal style='line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>            buffer <- B.readFile (combine baseDir fn)  </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#6A9955'>--reads strict the whole file</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'><o:p></o:p></span></p><p class=MsoNormal style='line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>            </span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>let</span><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'> bufferStrict = B.toStrict buffer<o:p></o:p></span></p><p class=MsoNormal style='margin-left:35.4pt;text-indent:35.4pt;line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>return $ Right $! TE.decodeUtf8 bufferStrict    -- this doesn’t work   <o:p></o:p></span></p><p class=MsoNormal style='margin-left:35.4pt;text-indent:35.4pt;line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>Right <$> evaluate (TE.decodeUtf8 bufferStrict) –- this does    <o:p></o:p></span></p><p class=MsoNormal style='margin-left:35.4pt;text-indent:35.4pt;line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>liftM Right $ evaluate (TE.decodeUtf8 bufferStrict) – this works too   <o:p></o:p></span></p><p class=MsoNormal style='line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>         ) exceptionHandler<o:p></o:p></span></p><p class=MsoNormal style='line-height:14.25pt;background:#1E1E1E'><span lang=EN-US style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>Van:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> David Fox [mailto:dsf@seereason.com] <br><br></span><span lang=EN-US><o:p></o:p></span></p><div><div><div><div><p class=MsoNormal><span lang=EN-US>This fixes it by forcing the evaluation of the decode where it can be caught:<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal>return $ Right $! TE.decodeUtf8 bufferStrict<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>or <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Right <$> evaluate (TE.decodeUtf8 bufferStrict)<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span style='color:#1F497D'><snip></span><o:p></o:p></p></div></div></div></div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /> <table style="border-top: 1px solid #D3D4DE;">
        <tr>
      <td style="width: 55px; padding-top: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
                <td style="width: 470px; padding-top: 17px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virusvrij. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>                </td>
        </tr>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body></html>