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

Add a missing semigroup instance #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions splines.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ Library
containers,
polynomial,
vector >= 0.8,
vector-space
vector-space,
semigroups
Test-Suite splines-test
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs

build-depends: base >= 3 && <5,
containers,
polynomial,
Expand Down
4 changes: 4 additions & 0 deletions src/Math/Spline/Knots.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import Data.Maybe (fromJust)
import qualified Data.Map as M
import Data.Monoid (Monoid(..))
import Data.Ord
import Data.Semigroup
import qualified Data.Set as S (Set, fromAscList)
import qualified Data.Vector as V

Expand All @@ -65,6 +66,9 @@ instance Show a => Show (Knots a) where
. showsPrec 11 (knots ks)
)

instance Ord a => Semigroup (Knots a) where
(<>) = mappend

instance (Ord a) => Monoid (Knots a) where
mempty = empty
mappend (Knots v1) (Knots v2) =
Expand Down