
The error message: time.hs:13:8: No instance for (Show e0) arising from a use of ‘testWire’ The type variable ‘e0’ is ambiguous Note: there are several potential instances: instance Show Double -- Defined in ‘GHC.Float’ instance Show Float -- Defined in ‘GHC.Float’ instance (Integral a, Show a) => Show (GHC.Real.Ratio a) -- Defined in ‘GHC.Real’ ...plus 45 others In the expression: testWire clockSession_ pos In an equation for ‘main’: main = testWire clockSession_ pos Failed, modules loaded: none. So here's my type debugging. (netwire sure is convoluted) pos => Wire s e m a Float integral => a -> Wire s e m a a clockSession_ => Session m (Timed NominalDiffTime ()) looks to me like the problem is probably rooted in the interaction of pos with (Timed NominalDiffTime) as it does not seem to have a float instance, but that doesn't seem like it should result in an error about ambiguity. Any help appreciated. Thanks Brian ---- import Prelude hiding ((.)) -- To use (.) in the scope of Categories instead import Control.Wire import FRP.Netwire speed :: Float speed = 0.5 pos :: (HasTime t s, Monad m) => Wire s e m a Float pos = integral 0 . pure speed -- The main function main :: IO () main = testWire clockSession_ pos

On Sun, Mar 22, 2015, at 05:57 AM, briand@aracnet.com wrote:
The error message:
time.hs:13:8: No instance for (Show e0) arising from a use of ‘testWire’ The type variable ‘e0’ is ambiguous Note: there are several potential instances: instance Show Double -- Defined in ‘GHC.Float’ instance Show Float -- Defined in ‘GHC.Float’ instance (Integral a, Show a) => Show (GHC.Real.Ratio a) -- Defined in ‘GHC.Real’ ...plus 45 others In the expression: testWire clockSession_ pos In an equation for ‘main’: main = testWire clockSession_ pos Failed, modules loaded: none.
The problem is that `testWire` wants to print the inhibition value but has no way of choosing which `Show` instance to use, because the type of `e` is left unspecified in your snippet. This is obvious if you look at the constraints on `testWire`, but not so obvious from the error message. The solution is to fix the inhibition type to `()` (or whatever).

On Sun, 22 Mar 2015 07:15:09 +0100 joachifm@fastmail.fm wrote:
On Sun, Mar 22, 2015, at 05:57 AM, briand@aracnet.com wrote:
The error message:
time.hs:13:8: No instance for (Show e0) arising from a use of ‘testWire’ The type variable ‘e0’ is ambiguous Note: there are several potential instances: instance Show Double -- Defined in ‘GHC.Float’ instance Show Float -- Defined in ‘GHC.Float’ instance (Integral a, Show a) => Show (GHC.Real.Ratio a) -- Defined in ‘GHC.Real’ ...plus 45 others In the expression: testWire clockSession_ pos In an equation for ‘main’: main = testWire clockSession_ pos Failed, modules loaded: none.
The problem is that `testWire` wants to print the inhibition value but has no way of choosing which `Show` instance to use, because the type of `e` is left unspecified in your snippet. This is obvious if you look at the constraints on `testWire`, but not so obvious from the error message. The solution is to fix the inhibition type to `()` (or whatever).
I change the type of pos to pos :: (HasTime t s, Monad m) => Wire s () m a Float and that did it. Also, () could just be Float, or, as you were saying, whatever. Thank you, thank you ! Brian p.s. and for the record not my snippet, got it from a blog. i'm guessing it was untested...
participants (2)
-
briand@aracnet.com
-
joachifm@fastmail.fm