Edit: Here's a complete, compiling, running solution to this problem:
module Main (
main
) where
import Prelude hiding ((.), id)
import qualified Prelude as Prelude
import Control.Wire
import Control.Wire.Interval
main :: IO ()
main = testWire clockSession_ (withoutErrors forYeah)
yeah :: Monad m => Wire s e m a String
yeah = pure "yes"
forYeah :: (Num t, HasTime t s, Monoid e, Monad m) => Wire s e m a String
forYeah = for 3 . yeah
-- This just is an easy way to specify to use () as the type for errors in testWire
withoutErrors :: Wire s () m a b -> Wire s () m a b
withoutErrors = Prelude.id
Here's the original answer, that discussed why we should change the type of yeah
, and then the necessary changes to the type of forYeah
:
Change the type of yeah
to Monad m => Wire s e m a String
. Monad m => (Wire s e m a)
has an Applicative
instance , so pure
should exist without specifying that the second type argument to Wire
in yeah
's type is ()
.
Note: I don't use netwire and I haven't tried compiling this. I've only looked at the types in the documentation.
Edit: You probably also need to change the type of forYeah
.
Wire
also has a Category
instance:
Monad m => Category (Wire s e m)
Category
's .
operator has the following type:
(.) :: cat b c -> cat a b -> cat a c
So for Wire
s it is:
(.) :: Monad m => Wire s e m b c -> Wire s e m a b -> Wire s e m a c
for
has the following type:
for :: (HasTime t s, Monoid e) => t -> Wire s e m a a
So for 3
would have a type like (HasTime Int s, Monoid e) => Wire s e m a a
. Combined with yeah's type of Monad m => Wire s e m a String
, for 3 . yeah
would have a type like
(HasTime Int s, Monoid e, Monad m) => Wire s e m a String
So we could probably change the type of forYeah
to:
forYeah :: (HasTime Int s, Monoid e, Monad m) => Wire s e m a String
Edit: Even better type for forYeah
Since an integer numeral (without a decimal point) is actually equivalent to an application of fromInteger to the value of the numeral as an Integer, and fromInteger :: (Num a) => Integer -> a
, the literal 3
actually has type Num t => t
. The best type we can choose is therefore probably:
forYeah :: (Num t, HasTime t s, Monoid e, Monad m) => Wire s e m a String