[commit: nofib] master: fannkuch-redux: Implement Semigroup along with Monoid (5748d42)
git at git.haskell.org
git at git.haskell.org
Thu Sep 14 20:42:51 UTC 2017
Repository : ssh://git@git.haskell.org/nofib
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/5748d428204ea0552f70b2981eaf30d4a5cfd3e9/nofib
>---------------------------------------------------------------
commit 5748d428204ea0552f70b2981eaf30d4a5cfd3e9
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Thu Sep 14 16:41:58 2017 -0400
fannkuch-redux: Implement Semigroup along with Monoid
so that it builds with GHC-8.3 post 8ae263c.
>---------------------------------------------------------------
5748d428204ea0552f70b2981eaf30d4a5cfd3e9
shootout/fannkuch-redux/Main.hs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/shootout/fannkuch-redux/Main.hs b/shootout/fannkuch-redux/Main.hs
index d115350..b920e9f 100644
--- a/shootout/fannkuch-redux/Main.hs
+++ b/shootout/fannkuch-redux/Main.hs
@@ -12,15 +12,17 @@ import Control.Concurrent
import Control.Monad
import System.Environment
import Foreign hiding (rotate)
-import Data.Monoid
+import Data.Semigroup
type Perm = Ptr Word8
data F = F {-# UNPACK #-} !Int {-# UNPACK #-} !Int
+instance Semigroup F where
+ F s1 m1 <> F s2 m2 = F (s1 + s2) (max m1 m2)
+
instance Monoid F where
mempty = F 0 0
- F s1 m1 `mappend` F s2 m2 = F (s1 + s2) (max m1 m2)
incPtr = (`advancePtr` 1)
decPtr = (`advancePtr` (-1))
More information about the ghc-commits
mailing list