packages feed

chatty 0.2.0.1 → 0.3.1.4

raw patch · 18 files changed

+578/−113 lines, 18 files

Files

System/Chatty/Commands.hs view
@@ -1,5 +1,26 @@ {-# LANGUAGE FlexibleInstances #-} +{-+  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/>.+-}+ -- | Provides in-haskell implementations for some standard functions module System.Chatty.Commands where 
System/Chatty/Misc.hs view
@@ -1,3 +1,24 @@+{-+  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/>.+-}+ -- | Provides typeclasses for clocks and randomizer environments module System.Chatty.Misc where @@ -11,7 +32,7 @@   mutctime :: m UTCTime   -- | Get timestamp, guaranteed to grow   mgetstamp :: m NominalDiffTime-  mgetstamp = fmap (diffUTCTime (UTCTime (fromGregorian 1970 1 1) (secondsToDiffTime 0))) mutctime+  mgetstamp = fmap (flip diffUTCTime (UTCTime (fromGregorian 1970 1 1) (secondsToDiffTime 0))) mutctime  instance MonadClock IO where   mutctime = getCurrentTime
System/Chatty/Spawn.hs view
@@ -1,3 +1,25 @@+{-+  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/>.+-}++-- | Provides a typeclass for process spawning. module System.Chatty.Spawn where  import Text.Chatty.Finalizer
System/Chatty/Spawn/Builtins.hs view
@@ -1,3 +1,24 @@+{-+  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/>.+-}+ -- | Provides builtins for some common commands. module System.Chatty.Spawn.Builtins (withBuiltins) where 
System/Chatty/Spawn/Overlay.hs view
@@ -1,3 +1,24 @@+{-+  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/>.+-}+ -- | Provides a MonadSpawn overlay that may catch specific spawn calls and handle them itself. module System.Chatty.Spawn.Overlay where 
Text/Chatty/Expansion.hs view
@@ -1,104 +1,53 @@-{-# LANGUAGE ExistentialQuantification, RankNTypes, Rank2Types #-}---- | Provides generic string expansion and a variable expander-module Text.Chatty.Expansion where--import Data.List-import Control.Arrow-import Control.Monad-import Control.Monad.IO.Class-import Control.Monad.Trans.Class-import System.Environment hiding (getEnv)-import System.Posix.Env (getEnv, setEnv)---import System.SetEnv---- | Some environment variable-data EnvVar = NotSet                       -- ^ Not set.-            | Literal String               -- ^ An embeddable string.-            | forall a.Show a => Scalar a  -- ^ Something we can show.-            | Array [EnvVar]               -- ^ Array of that--instance Show EnvVar where-  show (Scalar s) = show s-  show (Literal s) = s-  show (Array ps) = unwords $ map show ps-  show NotSet = ""---- | Environment storage and variable expander.-newtype ExpanderT m a = Expander {-    runExpanderT :: [(String,EnvVar)] -> m (a,[(String,EnvVar)])-  }--instance Monad m => Monad (ExpanderT m) where-  return a = Expander $ \vs -> return (a,vs)-  (Expander e) >>= f = Expander $ \vs -> do (a,vs') <- e vs; runExpanderT (f a) vs'--instance MonadTrans ExpanderT where-  lift m = Expander $ \vs -> do a <- m; return (a,vs)--instance MonadIO m => MonadIO (ExpanderT m) where-  liftIO = lift . liftIO--instance Monad m => Functor (ExpanderT m) where-  fmap f a = Expander $ \vs -> do (a',vs') <- runExpanderT a vs; return (f a',vs')+{-+  This module is part of Chatty.+  Copyleft (c) 2014 Marvin Cohrs --- | Run this function inside a blank environment.-localEnvironment :: Functor m => ExpanderT m a -> m a-localEnvironment m = fmap fst $ runExpanderT m []+  All wrongs reversed. Sharing is an act of love, not crime.+  Please share Antisplice with everyone you like. --- | Run this function in a locally modifiable, but not exported environment-forkEnvironment :: (Functor m,Monad m,MonadIO m) => ExpanderT m a -> m a-forkEnvironment m = do-  es <- liftIO getEnvironment-  fmap fst $ runExpanderT m $ fmap (second Literal) es+  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. --- | Export this local environment.-exportAll :: (Monad m,MonadIO m) => ExpanderT m ()-exportAll = Expander $ \vs -> do-  liftIO $ forM_ vs $ \(k,v) -> setEnv k (show v) True-  return ((),vs)+  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. --- | Typeclass for all environment storages.-class Monad ee => ExpanderEnv ee where-  -- | Get environment variable-  mgetv :: String -> ee EnvVar-  -- | Put environment variable-  mputv :: String -> EnvVar -> ee ()+  You should have received a copy of the GNU Affero General Public License+  along with Chatty. If not, see <http://www.gnu.org/licenses/>.+-} -instance Monad m => ExpanderEnv (ExpanderT m) where-  mgetv s = Expander $ \vs -> return $-    case filter ((==s).fst) vs of-      [] -> (NotSet,vs)-      ((_,v):_) -> (v,vs)-  mputv k v = Expander $ \vs -> return ((),(k,v):filter ((/=k).fst) vs)+-- | Provides generic string expansion+module Text.Chatty.Expansion where -instance ExpanderEnv IO where-  mgetv = fmap (\v -> case v of Nothing -> NotSet; Just v' -> Literal v') . getEnv-  mputv k v = setEnv k (show v) True+import Control.Monad+import Control.Monad.IO.Class+import Control.Monad.Trans.Class  -- | Typeclass for all string-expanding monads. class Monad e => MonadExpand e where   -- | Expand the given string.   expand :: String -> e String -instance MonadExpand IO where-  expand = expandVars+newtype NullExpanderT m a = NullExpander { runNullExpanderT :: m a } -instance Monad m => MonadExpand (ExpanderT m) where-  expand = expandVars+instance Monad m => Monad (NullExpanderT m) where+  return = NullExpander . return+  (NullExpander ne) >>= f = NullExpander $ do ne' <- ne; runNullExpanderT (f ne') --- | Expand $variables.-expandVars :: (Monad m,Functor m,ExpanderEnv m) => String -> m String-expandVars [] = return []-expandVars ('$':ss) =-  let nm = takeWhile isAnum ss-      rm = dropWhile isAnum ss-  in do-    v <- fmap show $ mgetv nm-    r <- expandVars rm-    return (v++r)-expandVars (s:ss) = do ss' <- expandVars ss; return (s:ss')+instance MonadTrans NullExpanderT where+  lift = NullExpander --- | Is alphanumeric?-isAnum = (`elem` (['a'..'z']++['A'..'Z']++"_"++['0'..'9']))+instance Functor m => Functor (NullExpanderT m) where+  fmap f (NullExpander ne) = NullExpander $ fmap f ne +instance MonadIO m => MonadIO (NullExpanderT m) where+  liftIO = lift . liftIO++instance Monad m => MonadExpand (NullExpanderT m) where+  expand = return++withExpansion :: Monad m => NullExpanderT m a -> m a+withExpansion = runNullExpanderT
+ Text/Chatty/Expansion/History.hs view
@@ -0,0 +1,80 @@+{-+  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 Text.Chatty.Expansion.History where++import Prelude hiding (id,(.))+import Control.Arrow+import Control.Category (id,(.))+import Control.Monad+import Control.Monad.IO.Class+import Control.Monad.Trans.Class+import Text.Chatty.Expansion++newtype HistoryT m a = History {+    runHistoryT :: [String] -> m (a,[String])+  }++instance Monad m => Monad (HistoryT m) where+  return a = History $ \s -> return (a,s)+  (History h) >>= f = History $ \s -> do (a,s') <- h s; runHistoryT (f a) s'++instance MonadTrans HistoryT where+  lift m = History $ \s -> do a <- m; return (a,s)++instance MonadIO m => MonadIO (HistoryT m) where+  liftIO = lift . liftIO++instance Monad m => Functor (HistoryT m) where+  fmap f a = History $ \s -> do (a',s') <- runHistoryT a s; return (f a',s')++class Monad he => HistoryEnv he where+  mcounth :: he Int+  mgeth :: Int -> he String+  mputh :: String -> he ()++instance Monad m => HistoryEnv (HistoryT m) where+  mcounth = History $ runKleisli (arr length &&& id)+  mgeth i+    | i <= 0 = let j = -i in History $ runKleisli (arr (!!j) &&& id)+    | otherwise = History . runKleisli $ arr ((!!i).reverse &&& id)+  mputh s = History . runKleisli $ arr (const () &&& (s:))++expandHist :: HistoryEnv h => String -> h String+expandHist [] = return []+expandHist ('!':ss) =+  let (nm,rm) = (takeWhile isNum &&& dropWhile isNum) ss+      isNum a = elem a ['0'..'9'] || (a=='-')+  in case nm of+    [] -> do+      ss' <- expandHist ss+      return ('!':ss')+    _ -> do+      hs <- expandHist rm+      h <- mgeth $ read nm+      return (h++hs)+expandHist (s:ss) = do ss' <- expandHist ss; return (s:ss')++instance MonadExpand m => MonadExpand (HistoryT m) where+  expand = lift . expand <=< expandHist++withHistory :: Monad m => HistoryT m a -> m a+withHistory = liftM fst . flip runHistoryT []
+ Text/Chatty/Expansion/Vars.hs view
@@ -0,0 +1,117 @@+{-# LANGUAGE ExistentialQuantification, RankNTypes, Rank2Types #-}++{-+  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 Text.Chatty.Expansion.Vars where++import Control.Arrow+import Control.Monad+import Control.Monad.IO.Class+import Control.Monad.Trans.Class+import System.Environment hiding (getEnv)+import System.Posix.Env (getEnv, setEnv)+import Text.Chatty.Expansion++-- | Some environment variable+data EnvVar = NotSet                       -- ^ Not set.+            | Literal String               -- ^ An embeddable string.+            | forall a.Show a => Scalar a  -- ^ Something we can show.+            | Array [EnvVar]               -- ^ Array of that++instance Show EnvVar where+  show (Scalar s) = show s+  show (Literal s) = s+  show (Array ps) = unwords $ map show ps+  show NotSet = ""+++-- | Environment storage and variable expander.+newtype ExpanderT m a = Expander {+    runExpanderT :: [(String,EnvVar)] -> m (a,[(String,EnvVar)])+  }++instance Monad m => Monad (ExpanderT m) where+  return a = Expander $ \vs -> return (a,vs)+  (Expander e) >>= f = Expander $ \vs -> do (a,vs') <- e vs; runExpanderT (f a) vs'++instance MonadTrans ExpanderT where+  lift m = Expander $ \vs -> do a <- m; return (a,vs)++instance MonadIO m => MonadIO (ExpanderT m) where+  liftIO = lift . liftIO++instance Monad m => Functor (ExpanderT m) where+  fmap f a = Expander $ \vs -> do (a',vs') <- runExpanderT a vs; return (f a',vs')++-- | Run this function inside a blank environment.+localEnvironment :: Functor m => ExpanderT m a -> m a+localEnvironment m = fmap fst $ runExpanderT m []++-- | Run this function in a locally modifiable, but not exported environment+forkEnvironment :: (Functor m,Monad m,MonadIO m) => ExpanderT m a -> m a+forkEnvironment m = do+  es <- liftIO getEnvironment+  fmap fst $ runExpanderT m $ fmap (second Literal) es++-- | Export this local environment.+exportAll :: (Monad m,MonadIO m) => ExpanderT m ()+exportAll = Expander $ \vs -> do+  liftIO $ forM_ vs $ \(k,v) -> setEnv k (show v) True+  return ((),vs)++instance MonadExpand IO where+  expand = expandVars++instance MonadExpand m => MonadExpand (ExpanderT m) where+  expand = lift . expand <=< expandVars++-- | Expand $variables. TODO: ${var}+expandVars :: (Monad m,Functor m,ExpanderEnv m) => String -> m String+expandVars [] = return []+expandVars ('$':ss) =+  let (nm,rm) = (takeWhile isAnum &&& dropWhile isAnum) ss+  in do+    v <- fmap show $ mgetv nm+    r <- expandVars rm+    return (v++r)+expandVars (s:ss) = do ss' <- expandVars ss; return (s:ss')++-- | Is alphanumeric?+isAnum = (`elem` (['a'..'z']++['A'..'Z']++"_"++['0'..'9']))++-- | Typeclass for all environment storages.+class Monad ee => ExpanderEnv ee where+  -- | Get environment variable+  mgetv :: String -> ee EnvVar+  -- | Put environment variable+  mputv :: String -> EnvVar -> ee ()++instance Monad m => ExpanderEnv (ExpanderT m) where+  mgetv s = Expander $ \vs -> return $+    case filter ((==s).fst) vs of+      [] -> (NotSet,vs)+      ((_,v):_) -> (v,vs)+  mputv k v = Expander $ \vs -> return ((),(k,v):filter ((/=k).fst) vs)++instance ExpanderEnv IO where+  mgetv = fmap (\v -> case v of Nothing -> NotSet; Just v' -> Literal v') . getEnv+  mputv k v = setEnv k (show v) True
Text/Chatty/Extended/ANSI.hs view
@@ -1,3 +1,24 @@+{-+  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/>.+-}+ -- | Provides an ExtendedPrinter that handles colours using standardized ANSI codes. module Text.Chatty.Extended.ANSI where 
Text/Chatty/Extended/HTML.hs view
@@ -1,3 +1,24 @@+{-+  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/>.+-}+ -- | Provides an 'ExtendedPrinter' that handles colours using HTML output. module Text.Chatty.Extended.HTML where @@ -40,19 +61,19 @@ maskHtml c = [c]  -- | Convert the given colour to its CSS representation.-hexColour (Dull Green) = "004400"+hexColour (Dull Green) = "007F00" hexColour (Vivid Green) = "00FF00"-hexColour (Dull Red) = "440000"+hexColour (Dull Red) = "7F0000" hexColour (Vivid Red) = "FF0000"-hexColour (Dull Yellow) = "444400"+hexColour (Dull Yellow) = "7F7F00" hexColour (Vivid Yellow) = "FFFF00"-hexColour (Dull Blue) = "000044"+hexColour (Dull Blue) = "00007F" hexColour (Vivid Blue) = "0000FF" hexColour (Dull Black) = "000000"-hexColour (Vivid Black) = "444444"-hexColour (Dull White) = "888888"+hexColour (Vivid Black) = "606060"+hexColour (Dull White) = "909090" hexColour (Vivid White) = "FFFFFF"-hexColour (Dull Cyan) = "004444"+hexColour (Dull Cyan) = "007F7F" hexColour (Vivid Cyan) = "00FFFF"-hexColour (Dull Magenta) = "440044"+hexColour (Dull Magenta) = "7F007F" hexColour (Vivid Magenta) = "FF00FF"
Text/Chatty/Extended/Printer.hs view
@@ -1,3 +1,24 @@+{-+  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/>.+-}+ -- | Provides an extended printer class that supports colours. module Text.Chatty.Extended.Printer where 
Text/Chatty/Finalizer.hs view
@@ -1,3 +1,25 @@+{-+  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/>.+-}++-- | Provides handle-closing. module Text.Chatty.Finalizer where  import Control.Monad
Text/Chatty/Interactor.hs view
@@ -1,5 +1,26 @@ {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies, TemplateHaskell #-} +{-+  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/>.+-}+ -- | Provides a bunch of derived instances for the various typeclasses. module Text.Chatty.Interactor where @@ -7,6 +28,8 @@ import Text.Chatty.Scanner import Text.Chatty.Finalizer import Text.Chatty.Expansion+import Text.Chatty.Expansion.Vars+import Text.Chatty.Expansion.History import Text.Chatty.Extended.HTML import Text.Chatty.Extended.ANSI import System.Chatty.Misc@@ -17,17 +40,19 @@ import Control.Monad.Trans.Class import Control.Monad.Identity -mkInteractor ''RecorderT mkScanner mkFinalizer mkExpander mkSpawn mkRandom mkClock-mkInteractor ''DeafT mkScanner mkFinalizer mkExpander mkSpawn mkRandom mkClock-mkInteractor ''OutRedirT mkScanner mkFinalizer mkExpander mkSpawn mkRandom mkClock-mkInteractor ''HandleCloserT mkScanner mkPrinter mkExpander mkSpawn mkRandom mkClock-mkInteractor ''ExpanderT mkScanner mkPrinter mkFinalizer mkSpawn mkRandom mkClock-mkInteractor ''HereStringT mkPrinter mkExpander mkSpawn mkRandom mkClock-mkInteractor ''QuietT mkPrinter mkExpander mkSpawn mkRandom mkClock-mkInteractor ''InRedirT mkPrinter mkExpander mkSpawn mkRandom mkClock-mkInteractor ''SpawnOverlayT mkPrinter mkScanner mkExpander mkFinalizer mkRandom mkClock-mkInteractor ''HtmlPrinterT mkScanner mkExpander mkFinalizer mkSpawn mkRandom mkClock-mkInteractor ''AnsiPrinterT mkScanner mkExpander mkFinalizer mkSpawn mkRandom mkClock+mkInteractor ''RecorderT mkScanner mkFinalizer mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock+mkInteractor ''DeafT mkScanner mkFinalizer mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock+mkInteractor ''OutRedirT mkScanner mkFinalizer mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock+mkInteractor ''HandleCloserT mkScanner mkPrinter mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock+mkInteractor ''ExpanderT mkScanner mkPrinter mkFinalizer mkSpawn mkRandom mkClock mkHistoryEnv+mkInteractor ''HereStringT mkPrinter mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock+mkInteractor ''QuietT mkPrinter mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock+mkInteractor ''InRedirT mkPrinter mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock+mkInteractor ''SpawnOverlayT mkPrinter mkScanner mkExpander mkExpanderEnv mkHistoryEnv mkFinalizer mkRandom mkClock+mkInteractor ''HtmlPrinterT mkScanner mkExpander mkExpanderEnv mkHistoryEnv mkFinalizer mkSpawn mkRandom mkClock+mkInteractor ''AnsiPrinterT mkScanner mkExpander mkExpanderEnv mkHistoryEnv mkFinalizer mkSpawn mkRandom mkClock+mkInteractor ''NullExpanderT mkScanner mkPrinter mkFinalizer mkSpawn mkRandom mkClock+mkInteractor ''HistoryT  mkScanner mkPrinter mkFinalizer mkSpawn mkRandom mkClock mkExpanderEnv  -- | IgnorantT ignores all output and does not provide any input. type IgnorantT m = QuietT (DeafT m)
Text/Chatty/Interactor/Templates.hs view
@@ -1,12 +1,35 @@ {-# LANGUAGE TemplateHaskell, QuasiQuotes, FlexibleInstances #-} +{-+  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/>.+-}+ -- | Declares serveral templates for comfortable instance derivation-module Text.Chatty.Interactor.Templates (mkScanner, mkPrinter, mkFinalizer, mkExpander,mkInteractor,mkSpawn,mkRandom,mkClock,mkChatty) where+module Text.Chatty.Interactor.Templates (mkScanner, mkPrinter, mkFinalizer, mkExpander,mkExpanderEnv,mkHistoryEnv,mkInteractor,mkSpawn,mkRandom,mkClock,mkChatty) where  import Text.Chatty.Scanner import Text.Chatty.Printer import Text.Chatty.Finalizer import Text.Chatty.Expansion+import Text.Chatty.Expansion.Vars+import Text.Chatty.Expansion.History import System.Chatty.Spawn import Text.Chatty.Extended.Printer import Control.Monad@@ -51,17 +74,33 @@   |]                  where sx = strToType s --- | Automatically derives a MonadExpand and an ExpanderEnv instance for you.+-- | Automatically derives a MonadExpand instance for you. mkExpander :: Name -> Q [Dec] mkExpander s = [d|     instance MonadExpand m => MonadExpand ($sx m) where       expand = lift . expand+  |]+  where sx = strToType s++-- | Automatically derives an ExpanderEnv instance for you+mkExpanderEnv :: Name -> Q [Dec]+mkExpanderEnv s = [d|     instance ExpanderEnv m => ExpanderEnv ($sx m) where       mgetv = lift . mgetv       mputv k v = lift $ mputv k v   |]   where sx = strToType s +-- | Automatically derives a HistoryEnv instance for you+mkHistoryEnv :: Name -> Q [Dec]+mkHistoryEnv s = [d|+    instance HistoryEnv m => HistoryEnv ($sx m) where+      mcounth = lift mcounth+      mgeth = lift . mgeth+      mputh = lift . mputh+  |]+  where sx = strToType s+ -- | Automatically derives a MonadSpawn instance for you. mkSpawn :: Name -> Q [Dec] mkSpawn s = [d|@@ -91,7 +130,7 @@  -- | Automatically derives all chatty typeclasses for you. mkChatty :: Name -> Q [Dec]-mkChatty s = mkInteractor s mkPrinter mkScanner mkFinalizer mkExpander mkSpawn mkRandom mkClock+mkChatty s = mkInteractor s mkPrinter mkScanner mkFinalizer mkExpander mkSpawn mkRandom mkClock mkExpanderEnv mkHistoryEnv  -- | Just a helper class for mkInteractor class InteractorMaker i where
Text/Chatty/Printer.hs view
@@ -1,5 +1,26 @@ {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies #-} +{-+  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/>.+-}+ -- | Provides a typeclass for all monads that may print text. module Text.Chatty.Printer where 
Text/Chatty/Scanner.hs view
@@ -1,5 +1,27 @@ {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies #-} +{-+  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/>.+-}++-- | Provides a typeclass for all monads that may scan text. module Text.Chatty.Scanner where  import Text.Chatty.Finalizer
Text/Chatty/Templates.hs view
@@ -1,5 +1,26 @@ {-# LANGUAGE FlexibleInstances #-} +{-+  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 Text.Chatty.Templates where  import Language.Haskell.TH
chatty.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.2.0.1+version:             0.3.1.4  -- A short (one-line) description of the package. synopsis:            Some monad transformers and typeclasses to simplify I/O on a transformer stack.@@ -48,7 +48,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+  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      -- Modules included in this library but not exported.   -- other-modules: