hydrogen-prelude 0.7.1 → 0.8
raw patch · 5 files changed
+152/−10 lines, 5 filesdep +networkdep ~hydrogen-versionPVP ok
version bump matches the API change (PVP)
Dependencies added: network
Dependency ranges changed: hydrogen-version
API changes (from Hackage documentation)
+ Hydrogen.Prelude: (!) :: Has a => a -> K a -> V a
+ Hydrogen.Prelude: (|>) :: a -> (a -> b) -> b
+ Hydrogen.Prelude: __ :: a
+ Hydrogen.Prelude: class Has a where type family K a type family V a
+ Hydrogen.Prelude: class TMap a where type family Component x type family Transform x
+ Hydrogen.Prelude: data Seq a :: * -> *
+ Hydrogen.Prelude: instance Eq k => Has [(k, v)]
+ Hydrogen.Prelude: instance Ix i => Has (Array i e)
+ Hydrogen.Prelude: instance Ord k => Has (Map k v)
+ Hydrogen.Prelude: instance TMap (Map k v)
+ Hydrogen.Prelude: instance TMap (Seq a)
+ Hydrogen.Prelude: instance TMap (a, a)
+ Hydrogen.Prelude: instance TMap (a, a, a)
+ Hydrogen.Prelude: instance TMap (a, a, a, a)
+ Hydrogen.Prelude: instance TMap [a]
+ Hydrogen.Prelude: safeHead :: a -> [a] -> a
+ Hydrogen.Prelude: tmap :: TMap a => (Component a -> b) -> a -> Transform ((Component a -> b) -> a)
+ Hydrogen.Prelude: type List a = [a]
Files
- LICENSE +19/−0
- README.md +3/−0
- hydrogen-prelude.cabal +12/−8
- src/Hydrogen/Prelude.hs +108/−2
- src/Hydrogen/Prelude/Network.hs +10/−0
LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2014 Julian Fleischer++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+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 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.
+ README.md view
@@ -0,0 +1,3 @@+++
hydrogen-prelude.cabal view
@@ -1,15 +1,15 @@ name: hydrogen-prelude-version: 0.7.1-homepage: https://github.com/scravy/hydrogen-prelude+version: 0.8+homepage: https://scravy.de/hydrogen-prelude/ synopsis: Hydrogen Prelude license: BSD3 license-file: LICENSE-extra-source-files: CHANGELOG.md+extra-source-files: CHANGELOG.md, README.md author: Julian Fleischer-maintainer: julfleischer@paypal.com+maintainer: julian@scravy.de category: Language build-type: Simple-cabal-version: >=1.18+cabal-version: >=1.14 source-repository head type: git@@ -18,6 +18,7 @@ library exposed-modules: Hydrogen.Prelude , Hydrogen.Prelude.IO+ , Hydrogen.Prelude.Network , Hydrogen.Prelude.System build-depends: base ==4.7.* , array ==0.5.*@@ -26,7 +27,8 @@ , directory ==1.2.* , filepath ==1.3.* , hashable ==1.2.*- , hydrogen-version >=1.1+ , hydrogen-version >=1.2+ , network >=2.4.2.2 , process ==1.2.* , random ==1.0.* , regex-base ==0.93.*@@ -39,13 +41,14 @@ ghc-options: -Wall default-language: Haskell2010 default-extensions: CPP- , DefaultSignatures , DeriveDataTypeable , DeriveFunctor , DeriveGeneric+ , EmptyCase , FlexibleInstances , FlexibleContexts , GADTs+ , LambdaCase , MultiWayIf , NegativeLiterals , NoImplicitPrelude@@ -54,4 +57,5 @@ , RecordWildCards , ScopedTypeVariables , StandaloneDeriving-+ , TupleSections+ , TypeFamilies
src/Hydrogen/Prelude.hs view
@@ -37,14 +37,21 @@ , (.|) , (=~) , (=~~)+ , (|>) , for , uuidFromString , randomUUID+ , safeHead , UUID , Generic+ , List , Map , Set+ , Seq , ShowBox+ , TMap (..)+ , Has (..)+ , __ ) where import "base" Prelude hiding (@@ -77,7 +84,8 @@ , sequence_ ) -import "array" Data.Array+import "array" Data.Array hiding ((!))+import qualified "array" Data.Array as Array import "base" Data.Bits hiding (bitSize) import "base" Data.Bool@@ -125,7 +133,7 @@ import "base" Data.Typeable import "base" Data.Word -import "base" GHC.Generics+import "base" GHC.Generics (Generic) import "base" Numeric @@ -133,7 +141,11 @@ import "regex-tdfa" Text.Regex.TDFA import "containers" Data.Map (Map)+import qualified "containers" Data.Map as Map import "containers" Data.Set (Set)+-- import qualified "containers" Data.Set as Set+import "containers" Data.Sequence (Seq)+-- import qualified "containers" Data.Sequence as Seq import "hydrogen-version" Hydrogen.Version @@ -182,6 +194,9 @@ f .| g = \x -> f x || g x f .& g = \x -> f x && g x +(|>) :: a -> (a -> b) -> b+(|>) = flip ($)+ for :: Functor f => f a -> (a -> b) -> f b for = flip fmap @@ -193,4 +208,95 @@ randomUUID :: IO UUID randomUUID = Data.UUID.V4.nextRandom++safeHead :: a -> [a] -> a+safeHead d = \case+ x : _ -> x+ _ -> d+++class TMap a where++ type Component x+ type Transform x++ tmap :: (Component a -> b) -> a -> Transform ((Component a -> b) -> a)+++instance TMap (a, a) where++ type Component (a, a) = a+ type Transform ((a -> b) -> (a, a)) = (b, b)++ tmap f (a, b) = (f a, f b)++instance TMap (a, a, a) where++ type Component (a, a, a) = a+ type Transform ((a -> b) -> (a, a, a)) = (b, b, b)++ tmap f (a, b, c) = (f a, f b, f c)++instance TMap (a, a, a, a) where++ type Component (a, a, a, a) = a+ type Transform ((a -> b) -> (a, a, a, a)) = (b, b, b, b)++ tmap f (a, b, c, d) = (f a, f b, f c, f d)++instance TMap [a] where++ type Component [a] = a+ type Transform ((a -> b) -> [a]) = [b]++ tmap = map++instance TMap (Map k v) where++ type Component (Map k v) = v+ type Transform ((v -> w) -> Map k v) = Map k w++ tmap = Map.map++instance TMap (Seq a) where++ type Component (Seq a) = a+ type Transform ((a -> b) -> Seq a) = Seq b++ tmap = fmap+++type List a = [a]++class Has a where++ type K a+ type V a++ (!) :: a -> K a -> V a+++instance Ord k => Has (Map k v) where++ type K (Map k v) = k+ type V (Map k v) = v++ (!) = (Map.!)++instance Eq k => Has [(k, v)] where++ type K [(k, v)] = k+ type V [(k, v)] = v++ list ! key = maybeKey (lookup key list)+ where+ maybeKey = maybe (error "Hydrogen.Prelude.! key not found") id++instance Ix i => Has (Array i e) where++ type K (Array i e) = i+ type V (Array i e) = e++ (!) = (Array.!)+
+ src/Hydrogen/Prelude/Network.hs view
@@ -0,0 +1,10 @@+module Hydrogen.Prelude.Network (+ module Hydrogen.Prelude.IO+ , module Network+) where++import Hydrogen.Prelude.IO++import "network" Network++