Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Semigroup (Vector u v c) instance to make compatible with GHC >= 8.4 #9

Merged
merged 1 commit into from
Dec 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion hybrid-vectors.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ library
base >= 4 && < 5,
deepseq >= 1.1 && < 1.5,
primitive >= 0.5 && < 0.7,
vector >= 0.10 && < 0.13
vector >= 0.10 && < 0.13,
semigroups >= 0.9 && < 1

hs-source-dirs: src

Expand Down
29 changes: 15 additions & 14 deletions src/Data/Vector/Hybrid/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE CPP, DeriveDataTypeable, FlexibleInstances, GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving, KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

#ifndef MIN_VERSION_base
#define MIN_VERSION_base(x,y,z) 1
Expand All @@ -22,10 +16,12 @@ module Data.Vector.Hybrid.Internal
, Vector(..)
) where

import Control.Monad
import Data.Monoid
import Control.Monad
import qualified Data.Foldable as F
import Data.Monoid
import Data.Semigroup
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Generic as G


#if MIN_VERSION_vector(0,11,0)
Expand All @@ -35,7 +31,8 @@ import Data.Vector.Fusion.Stream as Stream
#endif

import Data.Data
import Prelude hiding ( length, null, replicate, reverse, map, read, take, drop, init, tail )
import Prelude hiding (drop, init, length, map, null, read, replicate,
reverse, tail, take)
import Text.Read

data MVector :: (* -> * -> *) -> (* -> * -> *) -> * -> * -> * where
Expand Down Expand Up @@ -142,6 +139,10 @@ instance (G.Vector u a, G.Vector v b) => G.Vector (Vector u v) (a, b) where
elemseq (V ks vs) (k,v) b = G.elemseq ks k (G.elemseq vs v b)
{-# INLINE elemseq #-}

instance (G.Vector u a, G.Vector v b, c ~ (a, b)) => Semigroup (Vector u v c) where
(<>) = mappend
sconcat = mconcat . F.toList

instance (G.Vector u a, G.Vector v b, c ~ (a, b)) => Monoid (Vector u v c) where
mappend = (G.++)
{-# INLINE mappend #-}
Expand Down