packages feed

unfoldable-restricted (empty) → 0.0.0

raw patch · 4 files changed

+130/−0 lines, 4 filesdep +basedep +constraintsdep +containerssetup-changed

Dependencies added: base, constraints, containers, hashable, unfoldable, unit-constraint, unordered-containers

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2016, Athan Clark++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Athan Clark nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Data/Unfoldable/Restricted.hs view
@@ -0,0 +1,72 @@+{-# LANGUAGE+    KindSignatures+  , ConstraintKinds+  , MultiParamTypeClasses+  , FunctionalDependencies+  , FlexibleInstances+  #-}++module Data.Unfoldable.Restricted where++import Data.Unfolder        (Unfolder (choose))+import Data.Constraint      (Constraint)+import Data.Constraint.Unit (Unit)++import qualified Data.Set as Set+import qualified Data.Map as Map++import qualified Data.HashMap.Lazy as HashMap+import qualified Data.HashSet      as HashSet++import Data.Hashable (Hashable)+++class UnfoldableR+        (pred :: * -> Constraint)+        (t :: * -> *)+      | t -> pred where+  unfoldRestrict :: (pred a, Unfolder f) => f a -> f (t a)++class BiUnfoldableR+        (predA :: * -> Constraint)+        (predB :: * -> Constraint)+        (t :: * -> * -> *)+      | t -> predA predB where+  biunfoldRestrict :: (predA a, predB b, Unfolder f) => f a -> f b -> f (t a b)+++-- Containers++instance UnfoldableR (Ord) Set.Set where+  unfoldRestrict fa = choose+    [ pure Set.empty+    , Set.singleton <$> fa+    , Set.union <$> unfoldRestrict fa <*> unfoldRestrict fa+    ]++instance BiUnfoldableR (Ord) Unit Map.Map where+  biunfoldRestrict fa fb = choose+    [ pure Map.empty+    , Map.singleton <$> fa <*> fb+    , Map.union <$> biunfoldRestrict fa fb <*> biunfoldRestrict fa fb+    ]+++-- Unordered Containers+++class (Hashable a, Eq a) => Hashable' a++instance UnfoldableR (Hashable') HashSet.HashSet where+  unfoldRestrict fa = choose+    [ pure HashSet.empty+    , HashSet.singleton <$> fa+    , HashSet.union <$> unfoldRestrict fa <*> unfoldRestrict fa+    ]++instance BiUnfoldableR (Hashable') (Unit) HashMap.HashMap where+  biunfoldRestrict fa fb = choose+    [ pure HashMap.empty+    , HashMap.singleton <$> fa <*> fb+    , HashMap.union <$> biunfoldRestrict fa fb <*> biunfoldRestrict fa fb+    ]
+ unfoldable-restricted.cabal view
@@ -0,0 +1,26 @@+Name:                   unfoldable-restricted+Version:                0.0.0+Author:                 Athan Clark <athan.clark@gmail.com>+Maintainer:             Athan Clark <athan.clark@gmail.com>+License:                BSD3+License-File:           LICENSE+Synopsis:               An alternative to the Unfoldable typeclass+Cabal-Version:          >= 1.10+Build-Type:             Simple++Library+  Default-Language:     Haskell2010+  HS-Source-Dirs:       src+  GHC-Options:          -Wall+  Exposed-Modules:      Data.Unfoldable.Restricted+  Build-Depends:        base >= 4.8 && < 5+                      , constraints+                      , containers+                      , hashable+                      , unfoldable+                      , unit-constraint+                      , unordered-containers++Source-Repository head+  Type:                 git+  Location:             git@github.com:athanclark/unfoldable-restricted.git