Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyday567 committed Dec 4, 2023
1 parent 56355e3 commit 79caad4
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/haskell-ci.yml
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
ghc-version: ['9.6', '9.4', '9.2', '8.10']
ghc-version: ['9.8', '9.6', '9.4', '9.2', '8.10']
docspec: [false]
experimental: [false]

Expand Down
5 changes: 5 additions & 0 deletions ChangeLog.md
@@ -1,3 +1,8 @@
0.11.1.0
===
* Rect and Point show instances include negative brackets.
* removed NegativeLiterals as a requirement.

0.11.0.0
===
* fixes for numhask-0.11
Expand Down
10 changes: 5 additions & 5 deletions numhask-space.cabal
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: numhask-space
version: 0.11.0.1
version: 0.11.1.0
license: BSD-3-Clause
license-file: LICENSE
copyright: Tony Day (c) 2016
Expand Down Expand Up @@ -101,14 +101,14 @@ library
build-depends:
, adjunctions >=4.0 && <5
, base >=4.7 && <5
, containers >=0.6 && <0.7
, containers >=0.6 && <0.8
, distributive >=0.4 && <0.7
, numhask >=0.10 && <0.12
, numhask >=0.10 && <0.13
, random >=1.2 && <1.3
, semigroupoids >=5.3 && <6.1
, tdigest >=0.2.1 && <0.4
, text >=1.2 && <2.1
, time >=1.9 && <1.13
, text >=1.2 && <2.2
, time >=1.9.1 && <1.13
, vector >=0.12.3 && <0.14
exposed-modules:
NumHask.Space
Expand Down
12 changes: 0 additions & 12 deletions src/NumHask/Space.hs
@@ -1,4 +1,3 @@
{-# LANGUAGE NegativeLiterals #-}
{-# LANGUAGE RebindableSyntax #-}

-- | Mathematics does not rigorously define a [space](https://en.wikipedia.org/wiki/Space_(mathematics\)), leaving library devs free to explore.
Expand Down Expand Up @@ -63,14 +62,3 @@ import NumHask.Space.Types hiding ()
-- - A time span is a 'Space' containing moments of time.
--
-- - A 'Histogram' is a divided 'Range' with a count of elements within each division.

-- $extensions
-- > :t Point 1.0 -1.0
-- Point 1.0 -1.0
-- :: (Subtractive a, FromRatio a Integer,
-- FromRatio (a -> Point a) Integer) =>
-- a -> Point a
--
-- > :set -XNegativeLiterals
-- > :t Point 1.0 -1.0
-- Point 1.0 -1.0 :: FromRatio a Integer => Point a
1 change: 1 addition & 0 deletions src/NumHask/Space/Histogram.hs
Expand Up @@ -29,6 +29,7 @@ import NumHask.Space.Rect
import NumHask.Space.Types

-- $setup
-- >>> :set -XRebindableSyntax
-- >>> import NumHask.Prelude
-- >>> import NumHask.Space

Expand Down
11 changes: 2 additions & 9 deletions src/NumHask/Space/Point.hs
Expand Up @@ -22,7 +22,6 @@ module NumHask.Space.Point
where

import Data.Distributive
import Data.Functor.Classes
import Data.Functor.Rep
import NumHask.Prelude hiding (Distributive)
import NumHask.Space.Range
Expand All @@ -31,9 +30,9 @@ import System.Random
import System.Random.Stateful

-- $setup
-- >>> :set -XRebindableSyntax
-- >>> import NumHask.Prelude
-- >>> import NumHask.Space
-- >>> :set -XFlexibleContexts

-- | A 2-dimensional Point of a's
--
Expand Down Expand Up @@ -65,17 +64,11 @@ data Point a = Point
instance (Ord a, Additive a, Show a) => Show (Point a) where
show (Point a b) = "Point " <> wrap a <> " " <> wrap b
where
wrap x = bool (show x) ("(" <> show x <> ")") (x<zero)
wrap x = bool (show x) ("(" <> show x <> ")") (x < zero)

instance Functor Point where
fmap f (Point a b) = Point (f a) (f b)

instance Eq1 Point where
liftEq f (Point a b) (Point c d) = f a c && f b d

instance Show1 Point where
liftShowsPrec sp _ d (Point a b) = showsBinaryWith sp sp "Point" d a b

instance Applicative Point where
pure a = Point a a

Expand Down
8 changes: 0 additions & 8 deletions src/NumHask/Space/Range.hs
Expand Up @@ -11,7 +11,6 @@ where

import Data.Distributive as D
import Data.Functor.Apply (Apply (..))
import Data.Functor.Classes
import Data.Functor.Rep
import GHC.Show (show)
import NumHask.Prelude hiding (show)
Expand All @@ -20,7 +19,6 @@ import NumHask.Space.Types as S
-- $setup
--
-- >>> :set -XFlexibleContexts
-- >>> :set -XGADTs
-- >>> import NumHask.Prelude
-- >>> import NumHask.Space

Expand Down Expand Up @@ -60,12 +58,6 @@ data Range a = Range a a
instance (Show a) => Show (Range a) where
show (Range a b) = "Range " <> show a <> " " <> show b

instance Eq1 Range where
liftEq f (Range a b) (Range c d) = f a c && f b d

instance Show1 Range where
liftShowsPrec sp _ d (Range a b) = showsBinaryWith sp sp "Range" d a b

instance Functor Range where
fmap f (Range a b) = Range (f a) (f b)

Expand Down
7 changes: 3 additions & 4 deletions src/NumHask/Space/Rect.hs
@@ -1,4 +1,3 @@
{-# LANGUAGE NegativeLiterals #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE TypeFamilies #-}
Expand Down Expand Up @@ -36,7 +35,7 @@ import NumHask.Space.Types

-- $setup
--
-- >>> :set -XFlexibleContexts
-- >>> :set -XRebindableSyntax
-- >>> import NumHask.Prelude
-- >>> import NumHask.Space

Expand Down Expand Up @@ -101,7 +100,7 @@ instance (Ord a, Additive a, Show a) => Show (Rect a) where
show (Rect a b c d) =
"Rect " <> wrap a <> " " <> wrap b <> " " <> wrap c <> " " <> wrap d
where
wrap x = bool (show x) ("(" <> show x <> ")") (x<zero)
wrap x = bool (show x) ("(" <> show x <> ")") (x < zero)

instance Distributive Rect where
collect f x =
Expand Down Expand Up @@ -290,7 +289,7 @@ gridF f r g = (\x -> (x, f (mid x))) <$> gridSpace r g
-- >>> aspect 2
-- Rect (-1.0) 1.0 (-0.5) 0.5
aspect :: Double -> Rect Double
aspect a = Rect (a * -0.5) (a * 0.5) -0.5 0.5
aspect a = Rect (a * (-0.5)) (a * 0.5) (-0.5) 0.5

-- | convert a Rect to a ratio
--
Expand Down
4 changes: 1 addition & 3 deletions src/NumHask/Space/Time.hs
Expand Up @@ -29,13 +29,11 @@ import NumHask.Space.Types

-- $setup
--
-- >>> :set -XRebindableSyntax
-- >>> import NumHask.Prelude
-- >>> import NumHask.Space
-- >>> import NumHask.Space.Time
-- >>> import Data.Text (Text, pack)
-- >>> import Data.Time
--
-- > :set -XOverloadedStrings

-- | a step in time
data TimeGrain
Expand Down
1 change: 1 addition & 0 deletions src/NumHask/Space/Types.hs
Expand Up @@ -44,6 +44,7 @@ import System.Random.Stateful
import Prelude qualified as P

-- $setup
-- >>> :set -XRebindableSyntax
-- >>> import NumHask.Prelude
-- >>> import NumHask.Space
-- >>> import System.Random.Stateful
Expand Down

0 comments on commit 79caad4

Please sign in to comment.