<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>(Alexandre asked me to forward the email below on his behalf, because he is experiencing technical difficulties with this mail list. — Andrew)<br><br></div><div>

<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:"Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style>


<div class="WordSection1">
<p class="MsoNormal">Greetings CLC;<br>
<br>
I'm writing this email to propose a change to `Data.Fixed`. Full credit for this idea goes to Bhavik Mehta (@b-mehta on GitHub), who implemented it in this
<a href="https://github.com/dmcclean/exact-pi/pull/8">PR</a> for `exact-pi`.<br>
<br>
In `Data.Fixed` there are several `E`-prefixed datatypes used to represent a certain number of digits of precision in fixed-precision arithmetic. For example, `E1` has 1 decimal place, `E12` has 12. Each of them, `E{0,1,2,3,6,9,12}` is hardcoded. If more precision
 types are to be provided, they have to be hardcoded as well, and all of these types resemble each other. I think there is room for improvement here.<br>
<br>
Instead of having<br>
<br>
```<br>
data E0<br>
<br>
instance HasResolution E0 where<br>
    resolution _ = 1<br>
```<br>
<br>
and repeating it as many times as there are `E` datatypes, I propose to add the following type:<br>
<br>
```<br>
{-# LANGUAGE DataKinds      #-}<br>
{-# LANGUAGE KindSignatures #-}<br>
<br>
import GHC.TypeLits (Nat, KnownNat, natVal)<br>
<br>
data E (n :: Nat)<br>
```<br>
<br>
and then do<br>
<br>
```<br>
instance KnownNat n => HasResolution (E n) where<br>
    resolution _ = 10^natVal (undefined :: E n)<br>
```<br>
<br>
just once, replacing `data E0` with `type E0 = E 0` (and the same for the rest of them) to continue reexporting these types. `E` should also be exported.<br>
<br>
I have created a Trac feature request <a href="https://ghc.haskell.org/trac/ghc/ticket/15622">
ticket</a> with the same contents as this email, and made a <a href="https://github.com/ghc/ghc/pull/196">
PR</a> to GHC’s repository on GitHub.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">To finalize, there are a few topics I’d like to raise regarding this change.<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">1. Does the community find this change beneficial in general?<br>
2. Does the community approve of using DataKinds in a mundane section of the base package?<br>
3. Does everyone accept a small breaking change of E0, E1, etc. from a data type to a type synonym? Or should we go the conservative way and just add E without refactoring E0, E1, etc.?<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">Regards,<br>
<br>
Alexandre<o:p></o:p></p>
<p class="MsoNormal"><br></p></div></div><blockquote type="cite"><div class="WordSection1">
</div>


</blockquote></body></html>