[Haskell-cafe] Binary constants in Haskell
Henning Thielemann
lemming at henning-thielemann.de
Thu Oct 25 15:25:14 EDT 2007
On Thu, 25 Oct 2007, Don Stewart wrote:
> claus.reinke:
> >
> > how about using ghc's new overloaded strings for this?
> >
> > "10111011"::Binary
> >
> > there used to be a way to link to ghc head's docs, but
> > i can't find it right now. the test is
> >
> > http://darcs.haskell.org/testsuite/tests/ghc-regress/typecheck/should_compile/tc224.hs
> >
> > and the xml docs would be
> >
> > http://darcs.haskell.org/ghc/docs/users_guide/glasgow_exts.xml
>
> Why not use a Num instance for Binary, with fromInteger :: Integer -> a,
> Yielding,
>
> 10111011 :: Binary
>
> Overloaded numeric literals seem better here than strings :)
The result would be very unexpected - it reminds me much on C's octal
interpretation of all number literals starting with a 0.
More information about the Haskell-Cafe
mailing list