trivia (empty) → 0.0
raw patch · 5 files changed
+118/−0 lines, 5 filesdep +basedep +comonaddep +distributivesetup-changed
Dependencies added: base, comonad, distributive
Files
- Control/Comonad/Zero.hs +20/−0
- Control/Monad/One.hs +44/−0
- LICENSE +30/−0
- Setup.hs +2/−0
- trivia.cabal +22/−0
+ Control/Comonad/Zero.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, DeriveFoldable, DeriveTraversable, StandaloneDeriving #-} +module Control.Comonad.Zero (Zero) where +import Control.Comonad +import Data.Traversable +import Data.Foldable +import Data.Typeable + +data Zero a + +deriving instance Show (Zero a) +deriving instance Eq (Zero a) +deriving instance Ord (Zero a) +deriving instance Functor Zero +deriving instance Foldable Zero +deriving instance Traversable Zero +deriving instance Typeable1 Zero + +instance Comonad Zero where + extract z = extract z + extend f e = extend f e
+ Control/Monad/One.hs view
@@ -0,0 +1,44 @@+{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, DeriveFoldable, DeriveTraversable #-} +module Control.Monad.One (One(..)) where + +import Control.Applicative +import Data.Foldable +import Data.Traversable +import Data.Monoid +import Data.Distributive +import Control.Monad +import Data.Typeable + +data One a = One deriving (Show, Read, Eq, Ord, Enum, Functor, Foldable, Traversable, Typeable) + +instance Monoid (One a) where + mempty = One + mappend _ _ = One + +instance Monad One where + return _ = One + {-# INLINE return #-} + _ >>= _ = One + {-# INLINE (>>=) #-} + +instance Applicative One where + pure _ = One + {-# INLINE pure #-} + _ <*> _ = One + {-# INLINE (<*>) #-} + +instance Alternative One where + empty = One + {-# INLINE empty #-} + _ <|> _ = One + {-# INLINE (<|>) #-} + +instance MonadPlus One where + mzero = One + mplus _ _ = One + +instance Distributive One where + distribute _ = One + {-# INLINE distribute #-} + collect _ _ = One + {-# INLINE collect #-}
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2014, Fumiaki Kinoshita + +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 Fumiaki Kinoshita 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
+ trivia.cabal view
@@ -0,0 +1,22 @@+name: trivia +version: 0.0 +synopsis: The trivial monad and comonad +-- description: +homepage: https://github.com/fumieval/trivia +license: BSD3 +license-file: LICENSE +author: Fumiaki Kinoshita +maintainer: fumiexcel@gmail.com +-- copyright: +category: Control +build-type: Simple +-- extra-source-files: +cabal-version: >=1.10 + +library + exposed-modules: Control.Monad.One, Control.Comonad.Zero + -- other-modules: + other-extensions: DeriveDataTypeable, DeriveFunctor, DeriveFoldable, DeriveTraversable + build-depends: base == 4.*, distributive, comonad + -- hs-source-dirs: + default-language: Haskell2010