Vec-Boolean (empty) → 1.0.0
raw patch · 3 files changed
+102/−0 lines, 3 filesdep +Booleandep +Vecdep +basesetup-changed
Dependencies added: Boolean, Vec, base
Files
- Setup.lhs +6/−0
- Vec-Boolean.cabal +48/−0
- src/Data/Vec/Boolean.hs +48/−0
+ Setup.lhs view
@@ -0,0 +1,6 @@+#!/usr/bin/runhaskell +> module Main where +> import Distribution.Simple +> main :: IO () +> main = defaultMain +
+ Vec-Boolean.cabal view
@@ -0,0 +1,48 @@+name: Vec-Boolean+version: 1.0.0+cabal-version: >=1.2.3+build-type: Simple+license: BSD3+license-file: ""+copyright: Tobias Bexelius+maintainer: Tobias Bexelius+build-depends: Boolean -any, Vec -any, base ==4.1.0.0+stability:+homepage:+package-url:+bug-reports: mailto:tobias_bexelius@hotmail.com+synopsis: Provides Boolean instances for the Vec package+description: This package adds instances for the classes IfB and EqB in the Boolean package for the fixed length list data type in the Vec package.+ These intances are useful for example when using the GPipe package.+category: Math, Data+author: Tobias Bexelius+tested-with:+data-files:+data-dir: ""+extra-source-files:+extra-tmp-files:+exposed-modules: Data.Vec.Boolean+exposed: True+buildable: True+build-tools:+cpp-options:+cc-options:+ld-options:+pkgconfig-depends:+frameworks:+c-sources:+extensions: UndecidableInstances MultiParamTypeClasses+ FlexibleInstances TypeOperators+extra-libraries:+extra-lib-dirs:+includes:+install-includes:+include-dirs:+hs-source-dirs: src+other-modules:+ghc-prof-options:+ghc-shared-options:+ghc-options:+hugs-options:+nhc98-options:+jhc-options:
+ src/Data/Vec/Boolean.hs view
@@ -0,0 +1,48 @@+-----------------------------------------------------------------------------+--+-- Module : Data.Vec.Boolean+-- Copyright : Tobias Bexelius+-- License : BSD3+--+-- Maintainer : Tobias Bexelius+-- Stability :+-- Portability :+--+-- |+-- Besides the two functions listed below, this module provides 'Data.Boolean.IfB', 'Data.Boolean.EqB'+-- and 'Data.Boolean.OrdB' instances for the @()@ and the @:.@ data types.+--+-- Two fixed function lists are considered equal if all elements are equal. For element-wise comparisions,+-- use the 'all' and 'any' functions.+-----------------------------------------------------------------------------++module Data.Vec.Boolean (+ all,+ any,+) where++import Data.Boolean+import Data.Vec+import Prelude hiding (any, all)++instance Boolean bool => IfB bool () where+ ifB _ _ _ = ()++instance (IfB bool a, IfB bool b) => IfB bool (a:.b) where+ ifB bool (a1:.b1) (a2:.b2) = ifB bool a1 a2 :. ifB bool b1 b2++instance Boolean bool => EqB bool () where+ _ ==* _ = true+ _ /=* _ = false++instance (EqB bool a, EqB bool b) => EqB bool (a:.b) where+ (a1:.b1) ==* (a2:.b2) = a1==*a2 &&* b1==*b2+ (a1:.b1) /=* (a2:.b2) = a1/=*a2 ||* b1/=*b2++-- | Evaluates to 'true' if all elements in the fixed length list is 'true'+all :: (Boolean bool, Fold v bool) => v -> bool+all = fold (&&*)++-- | Evaluates to 'false' if all elements in the fixed length list is 'false'+any :: (Boolean bool, Fold v bool) => v -> bool+any = fold (||*)