[Haskell-beginners] Netwire fromRational
nathan.huesken at posteo.de
Wed Oct 3 18:12:13 CEST 2012
On 10/03/2012 02:04 PM, Ertugrul Söylemez wrote:
> When you write 'pure 1.0', then you're using,
> say, Double's Fractional instance directly. If you write just '1.0',
> then you're using Wire's Fractional instance, which is just defined as:
> fromRational = pure . fromRational
> So it's the same thing.
Let me simplify the example:
testW1 :: WireP () Double
testW1 = pure 1.0
testW2 :: WireP () Double
testW2 = 1.0
main = do
let (res, _) = stepWire 1.0 () testW
putStrLn $ show res
(set testW to testW1 or testW2).
When I test this with testW=testW2 I see that "fromRational" is called
which converts a Rational (=Ration Integer) to a WireP () Double (I
tested this by adding a "trace" to the fromRational
This means the "1.0" is converted to a Rational and then back to a WireP
() Double, correct?
> Michael Snoyman has reported that Netwire 4 compiled fine using GHCJS.
> Give that one a try.
I currently can not get ghcjs to work, but I will continue trying.
More information about the Beginners