Mixture of Integer and Float arithmetic without "fromIntegral"?

Christian Lescher christian@lescher.de
Wed, 06 Dec 2000 11:45:43 +0100


> You could try wheeling out Haskell's Least Used Keyword:
>
>     module Defs where
>
>     default(Double, Int)
>
>     n = 3       -- This is defaulted to Double
>     x = 12.3
>
>     test = ceiling (x / n)
>
> Other than that, I only know an answer that starts with "Design and
> implement a language extension for ...", sorry.

Never mind - thank you for the hint concerning the "default"
declaration; I didn't know about that keyword yet.

When writing the module as follows, no "fromIntegral" is necessary:

  module Defs where

  n :: Num a => a
  n = 3

  x :: Fractional a => a
  x = 12.3

  test = ceiling (x / n)

However, I would like to have it without writing the type signature. Who
knows a way to do this?

Christian