packages feed

oi 0.2.0.1 → 0.2.1.0

raw patch · 4 files changed

+21/−14 lines, 4 filesdep ~comonadPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: comonad

API changes (from Hackage documentation)

- Data.OI.Combinator: (|>) :: (a -> b) -> (b -> c) -> (a -> c)
- Data.OI.Internal: instance Extend OI
+ Data.OI.Combinator: foldOI :: (a :-> (b -> b)) -> b -> ([a] :-> b)
+ Data.OI.Combinator: sequenceOI :: [a :-> b] -> [a] :-> [b]

Files

oi.cabal view
@@ -1,5 +1,5 @@ Name:			oi-Version:		0.2.0.1+Version:		0.2.1.0 Category:		Data Synopsis:		Library for purely functional lazy interactions with the outer world. Description:		This package implements a data structure and operations on it for writing interactive program with no imperative flavor of IO monads.@@ -20,7 +20,7 @@ Library   Default-Language:         Haskell2010   Hs-Source-Dirs:	    src/-  Build-Depends:	    base >= 4.5 && < 5, parallel, comonad, filepath+  Build-Depends:	    base >= 4.5 && < 5, parallel, comonad >= 3, filepath   GHC-Options:		    -Wall -O0   Exposed-modules:	    Data.OI                            ,Data.OI.Internal
sample/recdircs.hs view
@@ -14,7 +14,7 @@ main = runInteraction pmain  pmain :: (([String], [(Bool, IOResult [FilePath])]), ()) :-> ()-pmain = ((args |> head) |/| getDirCsRec) |> snd |/| putStrOI . unlines+pmain = (((args >>> head) |/| getDirCsRec) >>> snd) |/| putStrOI . unlines  putStrOI :: String -> () :-> () putStrOI = iooi . putStr@@ -23,7 +23,7 @@ isDirectory = iooi . doesDirectoryExist  getDirCs' :: FilePath -> IOResult [FilePath] :-> [FilePath]-getDirCs' fp = iooi'  (getDirectoryContents fp) |> valid+getDirCs' fp = iooi'  (getDirectoryContents fp) >>> valid  valid :: IOResult [FilePath] -> [FilePath] valid (Success fps) = filter (flip notElem [".",".."]) fps
src/Data/OI/Combinator.hs view
@@ -12,13 +12,14 @@ module Data.OI.Combinator   (    -- * Utility functions-   (|>)-  ,choice+   choice    -- * Interaction Combinators   ,(|:|)   ,(|>|),(|/|)   ,(|><|)    -- * Iteration+  ,sequenceOI+  ,foldOI   ,mapOI   ,zipWithOI   ,zipWithOI'@@ -62,11 +63,19 @@   (a,b) -> (c,d) where (q,c) = f a p; (p,d) = g b q  -- | Iteration+foldOI :: (a :-> (b -> b)) -> b -> ([a] :-> b)+foldOI op z xxs = case deList xxs of+  Just (x,xs) -> x `op` foldOI op z xs+  _           -> z -mapOI :: (a :-> b) -> ([a] :-> [b])-mapOI f os = case deList os of -  Just (x,xs) -> f x : mapOI f xs+sequenceOI :: [a :-> b] -> [a] :-> [b]+sequenceOI (f:fs) oos = case deList oos of+  Just (o,os) -> f o : sequenceOI fs os   _           -> []+sequenceOI _ _ = []++mapOI :: (a :-> b) -> ([a] :-> [b])+mapOI f = sequenceOI (repeat f)  zipWithOI :: (a -> (b :-> c)) -> ([a] -> ([b] :-> [c])) zipWithOI _ [] _ = []
src/Data/OI/Internal.hs view
@@ -49,14 +49,14 @@ import Prelude hiding ((.),id,catch)  -- | Datatype for intermediating interaction: --- @OI@ has two states, non-expressed and exressed. +-- @OI@ has two states (programmer cannot distinguish), non-expressed and exressed. -- `Non-expressed' indicates that no computation is assigned. -- In other words, it's value is never denotated by any expression. -- So, if you refer the value then the process will be suspended  -- until other process determins the value. -- Non-expressed value can be determined to become 'expressed' for a value by a expression at most once. -- `Expressed' indicates that some computation is assigned for the value.--- And expressed values are never changed.+-- Once expressed, the value never be back to non-expressed nor be changed. data OI a = OI (LeftValueOf a) (RightValueOf a)  -- | Interaction (a function from a intermediating type to another type) type@@ -70,11 +70,9 @@   return = (##)   (>>=)  = flip ($) . (??) -instance Extend OI where-  duplicate = (##)- instance Comonad OI where   extract = (??)+  duplicate = (##)  -- | Dereference operator (??) :: OI a -> a