closed 0.2.0 → 0.2.0.1
raw patch · 3 files changed
+35/−28 lines, 3 filesdep ~QuickCheckdep ~aesondep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: QuickCheck, aeson, base, cassava, deepseq, hashable, persistent, text
API changes (from Hackage documentation)
- Closed.Internal: instance (n GHC.TypeNats.<= m, GHC.TypeNats.KnownNat n, GHC.TypeNats.KnownNat m) => Data.Aeson.Types.Class.FromJSON (Closed.Internal.Closed n m)
- Closed.Internal: instance Data.Aeson.Types.Class.ToJSON (Closed.Internal.Closed n m)
+ Closed: type family Bounds (lhs :: Endpoint) (rhs :: Endpoint) :: Type
+ Closed.Internal: instance (n GHC.TypeNats.<= m, GHC.TypeNats.KnownNat n, GHC.TypeNats.KnownNat m) => Data.Aeson.Types.FromJSON.FromJSON (Closed.Internal.Closed n m)
+ Closed.Internal: instance Data.Aeson.Types.ToJSON.ToJSON (Closed.Internal.Closed n m)
+ Closed.Internal: type family Bounds (lhs :: Endpoint) (rhs :: Endpoint) :: Type
Files
- LICENSE +1/−1
- closed.cabal +17/−20
- library/Closed/Internal.hs +17/−7
LICENSE view
@@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2013-2017 Front Row Education, Inc. www.frontrowed.com+Copyright (c) 2013-2019 Freckle Education, Inc. www.freckle.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
closed.cabal view
@@ -1,23 +1,23 @@--- This file has been generated from package.yaml by hpack version 0.20.0.+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: e5fbf1e0d45f270ab3829a93b28d76aac53b63b7dc3ff9d76dc0c69309541594+-- hash: 624ec706a439d32d6323b27102c9ab706d7db6dcb01fd792b513011438f5d796 name: closed-version: 0.2.0+version: 0.2.0.1 synopsis: Integers bounded by a closed interval-description: 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@frontrowed.com>-maintainer: Front Row Education <engineering@frontrowed.com>+author: Chris Parks <chris@freckle.com>+maintainer: Freckle Education <engineering@freckle.com> license: MIT license-file: LICENSE build-type: Simple-cabal-version: >= 1.10- extra-source-files: README.lhs @@ -26,6 +26,11 @@ location: https://github.com/frontrowed/closed library+ exposed-modules:+ Closed+ Closed.Internal+ other-modules:+ Paths_closed hs-source-dirs: library build-depends:@@ -37,30 +42,22 @@ , hashable , persistent , text- exposed-modules:- Closed- Closed.Internal- other-modules:- Paths_closed default-language: Haskell2010 test-suite readme type: exitcode-stdio-1.0 main-is: README.lhs+ other-modules:+ Paths_closed ghc-options: -Wall -pgmL markdown-unlit build-depends:- QuickCheck- , aeson- , base+ aeson+ , base >=4.9 && <5 , cassava , closed- , deepseq- , hashable , hspec , markdown-unlit , persistent , text , vector- other-modules:- Paths_closed default-language: Haskell2010
library/Closed/Internal.hs view
@@ -1,29 +1,39 @@-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE ExplicitForAll #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE KindSignatures #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE FlexibleContexts #-}++-- Prevent kind errors arising from using * to mean multiplication on+-- type-level natural numbers.+#if __GLASGOW_HASKELL__ >= 806+{-# LANGUAGE NoStarIsType #-}+#endif+ {-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}+ module Closed.Internal where import Control.DeepSeq import Control.Monad import Data.Aeson-import Database.Persist.Sql+import qualified Data.Csv as CSV import Data.Hashable+import Data.Kind (Type) import Data.Maybe import Data.Proxy import Data.Ratio import Data.Text (pack)+import Database.Persist.Sql import GHC.Generics import GHC.Stack import GHC.TypeLits-import qualified Data.Csv as CSV import Test.QuickCheck newtype Closed (n :: Nat) (m :: Nat)@@ -40,7 +50,7 @@ -- | Syntactic sugar to express open and half-open intervals using -- the 'Closed' type-type family Bounds (lhs :: Endpoint) (rhs :: Endpoint) :: * where+type family Bounds (lhs :: Endpoint) (rhs :: Endpoint) :: Type where Bounds (Inclusive n) (Inclusive m) = Closed n m Bounds (Inclusive n) (Exclusive m) = Closed n (m - 1) Bounds (Exclusive n) (Inclusive m) = Closed (n + 1) m@@ -158,7 +168,7 @@ Closed <$> choose (natVal @n Proxy, natVal @m Proxy) instance (n <= m, KnownNat n, KnownNat m) => PersistField (Closed n m) where- toPersistValue = toPersistValue . (fromIntegral @Integer @Int) . getClosed+ toPersistValue = toPersistValue . fromIntegral @Integer @Int . getClosed fromPersistValue value = do x <- fromIntegral @Int @Integer <$> fromPersistValue value case closed @n @m x of