packages feed

closed 0.2.0.1 → 0.2.0.2

raw patch · 5 files changed

+76/−65 lines, 5 filesdep ~QuickCheckdep ~aesondep ~cassavanew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: QuickCheck, aeson, cassava, deepseq, hashable, hspec, markdown-unlit, persistent, text, vector

API changes (from Hackage documentation)

+ Closed: clamp :: forall n m a. (KnownNat n, KnownNat m, n <= m, Integral a) => a -> Closed n m
+ Closed.Internal: clamp :: forall n m a. (KnownNat n, KnownNat m, n <= m, Integral a) => a -> Closed n m
- Closed: type FiniteNat (rhs :: Endpoint) = Bounds ( 'Inclusive 0) rhs
+ Closed: type FiniteNat (rhs :: Endpoint) = Bounds ('Inclusive 0) rhs
- Closed: type Single (n :: Nat) = Bounds ( 'Inclusive n) ( 'Inclusive n)
+ Closed: type Single (n :: Nat) = Bounds ('Inclusive n) ('Inclusive n)
- Closed.Internal: Closed :: Integer -> Closed
+ Closed.Internal: Closed :: Integer -> Closed (n :: Nat) (m :: Nat)
- Closed.Internal: [getClosed] :: Closed -> Integer
+ Closed.Internal: [getClosed] :: Closed (n :: Nat) (m :: Nat) -> Integer
- Closed.Internal: type FiniteNat (rhs :: Endpoint) = Bounds ( 'Inclusive 0) rhs
+ Closed.Internal: type FiniteNat (rhs :: Endpoint) = Bounds ('Inclusive 0) rhs
- Closed.Internal: type Single (n :: Nat) = Bounds ( 'Inclusive n) ( 'Inclusive n)
+ Closed.Internal: type Single (n :: Nat) = Bounds ('Inclusive n) ('Inclusive n)

Files

LICENSE view
@@ -1,6 +1,6 @@-The MIT License+The MIT License (MIT) -Copyright (c) 2013-2019 Freckle Education, Inc. www.freckle.com+Copyright (c) 2020 Renaissance Learning Inc  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal@@ -9,13 +9,13 @@ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in-all copies or substantial portions of the Software.+The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN-THE SOFTWARE.+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
README.lhs view
@@ -80,6 +80,19 @@       let result = unsafeClosed @2 @4 1       evaluate (getClosed result) `shouldThrow` anyErrorCall +  describe "construction with clamp" $ do+    it "should round up to lower bound" $ do+      let result = clamp @2 @4 @Int 0+      getClosed result `shouldBe` 2 ++    it "should round down to upper bound" $ do+      let result = clamp @2 @4 @Int 6+      getClosed result `shouldBe` 4++    it "should accept internal value as-is" $ do+      let result = clamp @2 @4 @Int 3+      getClosed result `shouldBe` 3+   describe "unsafe literal construction" $ do      it "should successfully construct values in the specified bounds" $ do
closed.cabal view
@@ -1,63 +1,55 @@-cabal-version: 1.12---- This file has been generated from package.yaml by hpack version 0.31.1.------ see: https://github.com/sol/hpack------ hash: 624ec706a439d32d6323b27102c9ab706d7db6dcb01fd792b513011438f5d796+cabal-version:      1.12+name:               closed+version:            0.2.0.2+license:            MIT+license-file:       LICENSE+maintainer:         Freckle Education <engineering@freckle.com>+author:             Chris Parks <chris@freckle.com>+homepage:           https://github.com/frontrowed/closed#readme+bug-reports:        https://github.com/frontrowed/closed/issues+synopsis:           Integers bounded by a closed interval+description:+    Integers bounded by a closed interval checked at compile time -name:           closed-version:        0.2.0.1-synopsis:       Integers bounded by a closed interval-description:    Integers bounded by a closed interval checked at compile time-category:       Data-homepage:       https://github.com/frontrowed/closed#readme-bug-reports:    https://github.com/frontrowed/closed/issues-author:         Chris Parks <chris@freckle.com>-maintainer:     Freckle Education <engineering@freckle.com>-license:        MIT-license-file:   LICENSE-build-type:     Simple-extra-source-files:-    README.lhs+category:           Data+build-type:         Simple+extra-source-files: README.lhs  source-repository head-  type: git-  location: https://github.com/frontrowed/closed+    type:     git+    location: https://github.com/frontrowed/closed  library-  exposed-modules:-      Closed-      Closed.Internal-  other-modules:-      Paths_closed-  hs-source-dirs:-      library-  build-depends:-      QuickCheck-    , aeson-    , base >=4.9 && <5-    , cassava-    , deepseq-    , hashable-    , persistent-    , text-  default-language: Haskell2010+    exposed-modules:+        Closed+        Closed.Internal +    hs-source-dirs:   library+    other-modules:    Paths_closed+    default-language: Haskell2010+    build-depends:+        QuickCheck >=2.11.3,+        aeson >=1.3.1.1,+        base >=4.9 && <5,+        cassava >=0.5.1.0,+        deepseq >=1.4.3.0,+        hashable >=1.2.7.0,+        persistent >=2.8.2,+        text >=1.2.3.1+ test-suite readme-  type: exitcode-stdio-1.0-  main-is: README.lhs-  other-modules:-      Paths_closed-  ghc-options: -Wall -pgmL markdown-unlit-  build-depends:-      aeson-    , base >=4.9 && <5-    , cassava-    , closed-    , hspec-    , markdown-unlit-    , persistent-    , text-    , vector-  default-language: Haskell2010+    type:             exitcode-stdio-1.0+    main-is:          README.lhs+    other-modules:    Paths_closed+    default-language: Haskell2010+    ghc-options:      -Wall -pgmL markdown-unlit+    build-depends:+        aeson >=1.3.1.1,+        base >=4.9 && <5,+        cassava >=0.5.1.0,+        closed -any,+        hspec >=2.5.5,+        markdown-unlit >=0.5.0,+        persistent >=2.8.2,+        text >=1.2.3.1,+        vector >=0.12.0.1
library/Closed.hs view
@@ -6,6 +6,7 @@   , FiniteNat   , closed   , unsafeClosed+  , clamp   , getClosed   , lowerBound   , upperBound
library/Closed/Internal.hs view
@@ -1,9 +1,7 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE ExplicitForAll #-} {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE KindSignatures #-}-{-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-}@@ -88,6 +86,13 @@     if x >= natVal (lowerBound result) && x <= natVal (upperBound result)       then Closed x       else error $ unrepresentable x result "unsafeClosed"++-- | Clamp an @'Integral'@ in the range constrained by a @'Closed'@ interval+clamp :: forall n m a. (KnownNat n, KnownNat m, n <= m, Integral a) => a -> Closed n m+clamp x+  | fromIntegral x < getClosed (minBound @(Closed n m)) = minBound+  | fromIntegral x > getClosed (maxBound @(Closed n m)) = maxBound+  | otherwise = Closed (fromIntegral x)  -- | Test equality on 'Closed' values in the same range instance Eq (Closed n m) where