[GHC] #10055: Offer PolyKinded instances for Data.Fixed.HasResolution (was: Offer PolyKinded instances Data.Fixed.HasResolution)

GHC ghc-devs at haskell.org
Sun Feb 1 02:17:53 UTC 2015


#10055: Offer PolyKinded instances for Data.Fixed.HasResolution
-------------------------------------+-------------------------------------
        Reporter:  redneb            |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  low               |               Milestone:
       Component:  libraries/base    |                 Version:  7.8.4
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
Description changed by redneb:

Old description:

> Now that we have `DataKinds` and `PolyKinds`, how about offering an
> instance of `Data.Fixed.HasResolution` for type level natural numbers.
> For example
>
> {{{#!hs
> instance KnownNat n => HasResolution (n :: Nat) where
>     resolution proxy = 10 ^ natVal proxy
> }}}
>
> or even
>
> {{{#!hs
> instance KnownNat n => HasResolution (n :: Nat) where
>     resolution = natVal
> }}}
>
> This will make it very easy to create fixed-point types on the fly. The
> following extensions are required for that to work: `DataKinds`,
> `PolyKinds`, `FlexibleInstances`, and `UndecidableInstances`.

New description:

 Now that we have `DataKinds` and `PolyKinds`, how about offering an
 instance of `Data.Fixed.HasResolution` for type level natural numbers. For
 example

 {{{#!hs
 instance KnownNat n => HasResolution (n :: Nat) where
     resolution proxy = 10 ^ natVal proxy
 }}}

 or even

 {{{#!hs
 instance KnownNat n => HasResolution (n :: Nat) where
     resolution = natVal
 }}}

 This will make it very easy to create fixed-point types on the fly. For
 example, it would be possible to say `0.3 :: Fixed 17`.

 The following extensions are required for that to work: `DataKinds`,
 `PolyKinds`, `FlexibleInstances`, and `UndecidableInstances`.

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10055#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list