invertible-hlist (empty) → 0.2.0.2
raw patch · 5 files changed
+132/−0 lines, 5 filesdep +HListdep +basedep +invertiblesetup-changed
Dependencies added: HList, base, invertible
Files
- Control/Invertible/Monoidal/HList.hs +35/−0
- Data/Invertible/HList.hs +36/−0
- LICENSE +30/−0
- Setup.hs +2/−0
- invertible-hlist.cabal +29/−0
+ Control/Invertible/Monoidal/HList.hs view
@@ -0,0 +1,35 @@+-- |+-- Combine monoidal functors into HLists.+{-# LANGUAGE TypeOperators, DataKinds, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, TypeFamilies, UndecidableInstances #-}+module Control.Invertible.Monoidal.HList+ ( hConsI+ , (>:*<)+ , HSequenceI(..)+ ) where++import Prelude hiding (Functor(..), (<$>), fst, snd, id)+import qualified Data.HList as HL++import Data.Invertible.HList+import Control.Invertible.Monoidal++-- |'HL.HCons' two monoidal functors.+hConsI :: Monoidal f => f a -> f (HL.HList l) -> f (HL.HList (a ': l))+hConsI = liftI2 hCons++-- |Infix alias for 'hConsI'.+(>:*<) :: Monoidal f => f a -> f (HL.HList l) -> f (HL.HList (a ': l))+(>:*<) = hConsI++infixr 4 >:*<++-- |A monoidal version of 'HL.HSequence': a heteogeneous version of 'sequenceMaybesI'.+class (Monoidal m, HL.SameLength a b) => HSequenceI m a b | a -> b, m b -> a where+ hSequenceI :: HL.HList a -> m (HL.HList b)++instance Monoidal m => HSequenceI m '[] '[] where+ hSequenceI _ = pureI HL.HNil++instance (m1 ~ m, Monoidal m, HSequenceI m as bs) => HSequenceI m (m1 a ': as) (a ': bs) where+ hSequenceI (HL.HCons a b) = a >:*< hSequenceI b+
+ Data/Invertible/HList.hs view
@@ -0,0 +1,36 @@+-- |+-- Bidirectional version of "Data.HList.HList".+{-# LANGUAGE DataKinds, QuasiQuotes, TypeOperators, FlexibleContexts #-}+module Data.Invertible.HList+ ( hCons+ , hReverse+ , hReverse_+ , hAppend+ , hZip+ ) where++import qualified Data.HList as HL+import Data.Proxy (Proxy(..))++import Data.Invertible.Bijection+import Data.Invertible.TH++-- |(De)construct an list from a head and tail.+hCons :: (a, HL.HList l) <-> HL.HList (a ': l)+hCons = [biCase|(a, l) <-> HL.HCons a l|]++-- |'HL.hReverse' the order of a list.+hReverse :: (HL.HReverse a b, HL.HReverse b a) => HL.HList a <-> HL.HList b+hReverse = HL.hReverse :<->: HL.hReverse++-- |'HL.hReverse_' the order of a list.+hReverse_ :: (HL.HRevApp a '[] b, HL.HRevApp b '[] a) => HL.HList a <-> HL.HList b+hReverse_ = HL.hReverse_ :<->: HL.hReverse_++-- |'HL.hAppend' (concatenate) or split two lists.+hAppend :: (HL.HAppendList a b, HL.HSplitAt n (HL.HAppendListR a b) a b) => (HL.HList a, HL.HList b) <-> HL.HList (HL.HAppendListR a b)+hAppend = uncurry HL.hAppendList :<->: HL.hSplitAt Proxy++-- |'HL.hZip' two lists together.+hZip :: HL.HZipList a b l => (HL.HList a, HL.HList b) <-> HL.HList l+hZip = uncurry HL.hZipList :<->: HL.hUnzipList
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2016-2017, Dylan Simon++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 Dylan Simon 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
+ invertible-hlist.cabal view
@@ -0,0 +1,29 @@+name: invertible-hlist+version: 0.2.0.2+synopsis: invertible functions and instances for HList+description: Provides invertible functions and instances for HList. This was formerly part of invertible itself and has been split off.+license: BSD3+license-file: LICENSE+author: Dylan Simon+maintainer: dylan@dylex.net+copyright: 2016+category: Data, Control, Composition+build-type: Simple+cabal-version: >=1.10+tested-with: GHC == 7.10.3, GHC == 8.0.1++source-repository head+ type: git+ location: https://github.com/dylex/invertible++library+ exposed-modules:+ Data.Invertible.HList+ Control.Invertible.Monoidal.HList++ build-depends:+ base >= 4.8 && <5,+ invertible > 0.2.0.1,+ HList == 0.4.*+ default-language: Haskell2010+ ghc-options: -Wall