@@ -6,7 +6,9 @@
6{-# LANGUAGE DataKinds #-}
6{-# LANGUAGE DataKinds #-}
7{-# LANGUAGE PolyKinds #-}
7{-# LANGUAGE PolyKinds #-}
8{-# LANGUAGE GeneralizedNewtypeDeriving #-}
8{-# LANGUAGE GeneralizedNewtypeDeriving #-}
9−{-# LANGUAGE MagicHash #-}
9+{-# LANGUAGE AllowAmbiguousTypes #-}
10+{-# LANGUAGE TypeApplications #-}
11+{-# LANGUAGE ScopedTypeVariables #-}
11-- | See "Control.Monad.Trans.Writer".
13-- | See "Control.Monad.Trans.Writer".
@@ -28,7 +30,6 @@ module Control.Monad.Trans.Ether.Writer
31−import GHC.Prim (Proxy#)
32import Data.Functor.Identity (Identity(..))
33import Data.Functor.Identity (Identity(..))
33import qualified Control.Monad.Trans.Writer.Lazy as Trans
34import qualified Control.Monad.Trans.Writer.Lazy as Trans
34import Control.Monad.Trans.Ether.Tagged
35import Control.Monad.Trans.Ether.Tagged
@@ -48,43 +49,43 @@ type Writer tag w = WriterT tag w Identity
48type WriterT tag w = TaggedTrans tag (Trans.WriterT w)
49type WriterT tag w = TaggedTrans tag (Trans.WriterT w)
50-- | Constructor for computations in the writer monad transformer.
51-- | Constructor for computations in the writer monad transformer.
51−writerT :: Proxy# tag -> m (a, w) -> WriterT tag w m a
52+writerT :: forall tag w m a . m (a, w) -> WriterT tag w m a
52−writerT _ = pack . Trans.WriterT
53+writerT = pack . Trans.WriterT
54-- | Constructor for computations in the writer monad
55-- | Constructor for computations in the writer monad
55-- (the inverse of 'runWriter').
56-- (the inverse of 'runWriter').
56−writer :: Monad m => Proxy# tag -> (a, w) -> WriterT tag w m a
57+writer :: forall tag w m a . Monad m => (a, w) -> WriterT tag w m a
57−writer _ = pack . Trans.writer
58+writer = pack . Trans.writer
59-- | Runs a 'WriterT' and returns both the normal value
60-- | Runs a 'WriterT' and returns both the normal value
60-- and the final accumulator.
61-- and the final accumulator.
61−runWriterT :: Proxy# tag -> WriterT tag w m a -> m (a, w)
62+runWriterT :: forall tag w m a . WriterT tag w m a -> m (a, w)
62−runWriterT _ = Trans.runWriterT . unpack
63+runWriterT = Trans.runWriterT . unpack
64-- | Runs a 'Writer' and returns both the normal value
65-- | Runs a 'Writer' and returns both the normal value
65-- and the final accumulator.
66-- and the final accumulator.
66−runWriter :: Proxy# tag -> Writer tag w a -> (a, w)
67+runWriter :: forall tag w a . Writer tag w a -> (a, w)
67−runWriter _ = Trans.runWriter . unpack
68+runWriter = Trans.runWriter . unpack
69-- | Runs a 'WriterT' and returns the final accumulator,
70-- | Runs a 'WriterT' and returns the final accumulator,
70-- discarding the normal value.
71-- discarding the normal value.
71−execWriterT :: Monad m => Proxy# tag -> WriterT tag w m a -> m w
72+execWriterT :: forall tag w m a . Monad m => WriterT tag w m a -> m w
72−execWriterT _ = Trans.execWriterT . unpack
73+execWriterT = Trans.execWriterT . unpack
74-- | Runs a 'Writer' and returns the final accumulator,
75-- | Runs a 'Writer' and returns the final accumulator,
75-- discarding the normal value.
76-- discarding the normal value.
76−execWriter :: Proxy# tag -> Writer tag w a -> w
77+execWriter :: forall tag w a . Writer tag w a -> w
77−execWriter _ = Trans.execWriter . unpack
78+execWriter = Trans.execWriter . unpack
79-- | Appends a value to the accumulator within the monad.
80-- | Appends a value to the accumulator within the monad.
80−tell :: Monad m => Proxy# tag -> w -> WriterT tag w m ()
81+tell :: forall tag w m . Monad m => w -> WriterT tag w m ()
81−tell t w = writer t ((), w)
82+tell w = writer @tag ((), w)
83-- | Executes an action and adds its accumulator to the value of the computation.
84-- | Executes an action and adds its accumulator to the value of the computation.
84−listen :: Monad m => Proxy# tag -> WriterT tag w m a -> WriterT tag w m (a, w)
85+listen :: forall tag w m a . Monad m => WriterT tag w m a -> WriterT tag w m (a, w)
85−listen _ = pack . Trans.listen . unpack
86+listen = pack . Trans.listen . unpack
87-- | Executes an action which returns a value and a function, and returns the
88-- | Executes an action which returns a value and a function, and returns the
88-- value, applying the function to the accumulator.
89-- value, applying the function to the accumulator.
89−pass :: Monad m => Proxy# tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a
90+pass :: forall tag w m a . Monad m => WriterT tag w m (a, w -> w) -> WriterT tag w m a
90−pass _ = pack . Trans.pass . unpack
91+pass = pack . Trans.pass . unpack