turion / rhine

Haskell Functional Reactive Programming framework with type-level clocks
http://hackage.haskell.org/package/rhine
123 stars 21 forks source link

Implement Semigroup-Monoid-Proposal (needed for GHC 8.4.1) #32

Closed ggreif closed 6 years ago

ggreif commented 6 years ago
    [24 of 29] Compiling FRP.Rhine.Clock.Realtime.Stdin ( src/FRP/Rhine/Clock/Realtime/Stdin.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/FRP/Rhine/Clock/Realtime/Stdin.o )

    /home/ggreif/stack16020/rhine-0.4.0.0/src/FRP/Rhine/Clock/Realtime/Stdin.hs:33:10: error:
        ? No instance for (Semigroup StdinClock)
            arising from the superclasses of an instance declaration
        ? In the instance declaration for ?Monoid StdinClock?
       |
    33 | instance Monoid StdinClock where
       |          ^^^^^^^^^^^^^^^^^
ggreif commented 6 years ago

I have locally now:

diff --git a/rhine/src/FRP/Rhine/Clock/Realtime/Stdin.hs b/rhine/src/FRP/Rhine/Clock/Realtime/Stdin.hs
index a3c06bd..913e516 100644
--- a/rhine/src/FRP/Rhine/Clock/Realtime/Stdin.hs
+++ b/rhine/src/FRP/Rhine/Clock/Realtime/Stdin.hs
@@ -30,6 +30,9 @@ instance MonadIO m => Clock m StdinClock where
       , initialTime
       )

+instance Semigroup StdinClock where
+  (<>) = mappend
+
 instance Monoid StdinClock where
   mempty      = StdinClock
   mappend _ _ = StdinClock

It should probably use CPP conditionals to activate only with new base.

turion commented 6 years ago

StdinClock and all other singleton clocks should only be a Semigroup, since this is all that is ever used (currently).