chatty 0.6 → 0.6.1.0
raw patch · 2 files changed
+98/−3 lines, 2 filesdep +chatty-utilsdep ~ansi-terminaldep ~unixPVP ok
version bump matches the API change (PVP)
Dependencies added: chatty-utils
Dependency ranges changed: ansi-terminal, unix
API changes (from Hackage documentation)
+ System.Chatty.Filesystem: FSSucc :: a -> FSExec a
+ System.Chatty.Filesystem: File :: m (FSExec ()) -> m (FSExec ()) -> m () -> String -> String -> File m
+ System.Chatty.Filesystem: FilePrinter :: (FileA m -> m a) -> FilePrinterT m a
+ System.Chatty.Filesystem: FileScanner :: (FileA m -> m a) -> FileScannerT m a
+ System.Chatty.Filesystem: NoPermission :: FSExec a
+ System.Chatty.Filesystem: NotFound :: FSExec a
+ System.Chatty.Filesystem: class Monad m => CanLoad m n
+ System.Chatty.Filesystem: class Monad m => CanSave m n
+ System.Chatty.Filesystem: class ChAtoms m => ChFilesystem m
+ System.Chatty.Filesystem: closeFun :: File m -> m ()
+ System.Chatty.Filesystem: data FSExec a
+ System.Chatty.Filesystem: data File m
+ System.Chatty.Filesystem: data FilePrinterT m a
+ System.Chatty.Filesystem: data FileScannerT m a
+ System.Chatty.Filesystem: fload :: CanLoad m n => FileA n -> m (FSExec ())
+ System.Chatty.Filesystem: fopen :: ChFilesystem m => String -> m (FSExec (FileA m))
+ System.Chatty.Filesystem: fsave :: CanSave m n => FileA n -> m (FSExec ())
+ System.Chatty.Filesystem: instance ChAtoms m => ChPrinter (FilePrinterT m)
+ System.Chatty.Filesystem: instance ChAtoms m => ChScanner (FileScannerT m)
+ System.Chatty.Filesystem: instance Functor f => Functor (FilePrinterT f)
+ System.Chatty.Filesystem: instance Functor f => Functor (FileScannerT f)
+ System.Chatty.Filesystem: instance Monad m => Monad (FilePrinterT m)
+ System.Chatty.Filesystem: instance Monad m => Monad (FileScannerT m)
+ System.Chatty.Filesystem: instance MonadIO m => MonadIO (FilePrinterT m)
+ System.Chatty.Filesystem: instance MonadIO m => MonadIO (FileScannerT m)
+ System.Chatty.Filesystem: instance MonadTrans FilePrinterT
+ System.Chatty.Filesystem: instance MonadTrans FileScannerT
+ System.Chatty.Filesystem: leftBehind :: File m -> String
+ System.Chatty.Filesystem: loadFun :: File m -> m (FSExec ())
+ System.Chatty.Filesystem: rightPending :: File m -> String
+ System.Chatty.Filesystem: runFilePrinterT :: FilePrinterT m a -> FileA m -> m a
+ System.Chatty.Filesystem: runFileScannerT :: FileScannerT m a -> FileA m -> m a
+ System.Chatty.Filesystem: saveFun :: File m -> m (FSExec ())
+ System.Chatty.Filesystem: type FileA m = Atom (File m)
Files
- System/Chatty/Filesystem.hs +95/−0
- chatty.cabal +3/−3
+ System/Chatty/Filesystem.hs view
@@ -0,0 +1,95 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-+ This module is part of Chatty.+ Copyleft (c) 2014 Marvin Cohrs++ All wrongs reversed. Sharing is an act of love, not crime.+ Please share Antisplice with everyone you like.++ Chatty is free software: you can redistribute it and/or modify+ it under the terms of the GNU Affero General Public License as published by+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ Chatty is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU Affero General Public License for more details.++ You should have received a copy of the GNU Affero General Public License+ along with Chatty. If not, see <http://www.gnu.org/licenses/>.+-}++module System.Chatty.Filesystem where++import Control.Monad+import Control.Monad.State+import Control.Monad.Identity+import Data.Chatty.Atoms+import Text.Chatty.Printer+import Text.Chatty.Scanner++data FSExec a = FSSucc a+ | NoPermission+ | NotFound++data File m = File {+ loadFun :: m (FSExec ()),+ saveFun :: m (FSExec ()),+ closeFun :: m (),+ leftBehind :: String,+ rightPending :: String+ }+type FileA m = Atom (File m)++class ChAtoms m => ChFilesystem m where+ fopen :: String -> m (FSExec (FileA m))++class Monad m => CanLoad m n where+ fload :: FileA n -> m (FSExec ())++class Monad m => CanSave m n where+ fsave :: FileA n -> m (FSExec ())++data FilePrinterT m a = FilePrinter { runFilePrinterT :: FileA m -> m a }+data FileScannerT m a = FileScanner { runFileScannerT :: FileA m -> m a }++instance Monad m => Monad (FilePrinterT m) where+ return a = FilePrinter $ \_ -> return a+ m >>= f = FilePrinter $ \d -> do a <- runFilePrinterT m d; runFilePrinterT (f a) d++instance Monad m => Monad (FileScannerT m) where+ return a = FileScanner $ \_ -> return a+ m >>= f = FileScanner $ \d -> do a <- runFileScannerT m d; runFileScannerT (f a) d++instance Functor f => Functor (FilePrinterT f) where+ fmap f a = FilePrinter $ fmap f . runFilePrinterT a++instance Functor f => Functor (FileScannerT f) where+ fmap f a = FileScanner $ fmap f . runFileScannerT a++instance MonadTrans FilePrinterT where+ lift m = FilePrinter $ \_ -> m++instance MonadTrans FileScannerT where+ lift m = FileScanner $ \_ -> m++instance MonadIO m => MonadIO (FilePrinterT m) where+ liftIO = lift . liftIO++instance MonadIO m => MonadIO (FileScannerT m) where+ liftIO = lift . liftIO++instance ChAtoms m => ChPrinter (FilePrinterT m) where+ mprint s = FilePrinter $ \d -> do+ f <- getAtom d+ putAtom d f{leftBehind=reverse (take (length s) $ rightPending f) ++ leftBehind f, rightPending=drop (length s) $ rightPending f}++instance ChAtoms m => ChScanner (FileScannerT m) where+ mscan1 = FileScanner $ \d -> do+ f <- getAtom d+ putAtom d f{leftBehind=head (rightPending f) : leftBehind f, rightPending=tail $ rightPending f}+ return $ head $ rightPending f+ mscanL = FileScanner $ liftM rightPending . getAtom+ mscannable = FileScanner $ liftM (not . null . rightPending) . getAtom+ mready = mscannable
chatty.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.6+version: 0.6.1.0 -- A short (one-line) description of the package. synopsis: Some monad transformers and typeclasses for abstraction of global dependencies.@@ -49,7 +49,7 @@ library -- Modules exported by the library.- exposed-modules: Text.Chatty.Expansion, System.Chatty.Commands, System.Chatty.Spawn, Text.Chatty.Printer, Text.Chatty.Finalizer, Text.Chatty.Templates, Text.Chatty.Scanner, Text.Chatty.Interactor, System.Chatty.Spawn.Overlay, System.Chatty.Spawn.Builtins, Text.Chatty.Interactor.Templates, System.Chatty.Misc, Text.Chatty.Extended.Printer, Text.Chatty.Extended.HTML, Text.Chatty.Extended.ANSI, Text.Chatty.Expansion.Vars, Text.Chatty.Expansion.History, Text.Chatty.Channel.Printer, Text.Chatty.Channel.Broadcast, Text.Chatty.Scanner.Buffered+ exposed-modules: Text.Chatty.Expansion, System.Chatty.Commands, System.Chatty.Spawn, Text.Chatty.Printer, Text.Chatty.Finalizer, Text.Chatty.Templates, Text.Chatty.Scanner, Text.Chatty.Interactor, System.Chatty.Spawn.Overlay, System.Chatty.Spawn.Builtins, Text.Chatty.Interactor.Templates, System.Chatty.Misc, Text.Chatty.Extended.Printer, Text.Chatty.Extended.HTML, Text.Chatty.Extended.ANSI, Text.Chatty.Expansion.Vars, Text.Chatty.Expansion.History, Text.Chatty.Channel.Printer, Text.Chatty.Channel.Broadcast, Text.Chatty.Scanner.Buffered, System.Chatty.Filesystem -- Modules included in this library but not exported. -- other-modules: @@ -58,7 +58,7 @@ other-extensions: ExistentialQuantification, RankNTypes, Rank2Types, FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies, TemplateHaskell, QuasiQuotes, UndecidableInstances -- Other library packages from which modules are imported.- build-depends: base >=4.6 && <4.7, transformers >=0.3 && <0.4, directory >=1.2 && <1.3, process >=1.1 && <1.2, mtl >=2.1 && <2.2, template-haskell >=2.8 && <2.9, setenv >= 0.1 && <0.2, unix >= 2.6 && < 2.7, random >= 1.0 && < 1.1, time >= 1.4 && < 1.5, ansi-terminal >= 0.6 && <0.7+ build-depends: base >=4.6 && <4.7, transformers >=0.3 && <0.4, directory >=1.2 && <1.3, process >=1.1 && <1.2, mtl >=2.1 && <2.2, template-haskell >=2.8 && <2.9, setenv >= 0.1 && <0.2, unix >= 2.6 && < 2.8, random >= 1.0 && < 1.1, time >= 1.4 && < 1.5, ansi-terminal >= 0.6 && <0.8, chatty-utils >= 0.7.1 && <0.8 -- Directories containing source files. -- hs-source-dirs: