packages feed

tkhs 0.2.1 → 0.2.2

raw patch · 5 files changed

+43/−11 lines, 5 filesdep −pointedlistdep ~parsec

Dependencies removed: pointedlist

Dependency ranges changed: parsec

Files

src/Main.hs view
@@ -6,7 +6,7 @@ import System.Environment import System.IO.UTF8 as U import Data.Char-import qualified Data.List.PointedList as Zipper+import qualified Zipper import Data.Maybe  main :: IO ()
src/Parser.hs view
@@ -4,16 +4,16 @@  import Tkhs -import Text.Parsec hiding (newline, (<|>))+import Text.ParserCombinators.Parsec hiding (newline) import Control.Monad.Identity-import Control.Applicative hiding (many)+import Control.Applicative hiding (many, (<|>))  import Prelude hiding (lines)  parseSlides :: String -> Either ParseError [Slide] parseSlides str = parse (many1 slide) "" str -type PC a = ParsecT String () Identity a+type PC a = Parser a  t_sig, f_sig, any_sig :: PC () t_sig = char '-' >> newline >> return ()
src/Tkhs.hs view
@@ -16,8 +16,8 @@  import Vty hiding (style) -import qualified Data.List.PointedList as Zipper-import Data.List.PointedList (PointedList)+import qualified Zipper+import Zipper (Zipper) import Control.Applicative hiding ((<|>)) import Control.Monad.State import Control.Monad.Reader@@ -26,8 +26,6 @@ import System.IO import System.Exit import Text.PrettyPrint hiding (render)--type Zipper a = PointedList a  data Slide = T [String] | F [String] type SlideSet = Zipper Slide
+ src/Zipper.hs view
@@ -0,0 +1,34 @@+module Zipper where++import Control.Applicative+import Data.Traversable+import Data.Foldable+import Data.Monoid++data Zipper a = Zipper { prevs :: [a], current :: a, nexts :: [a] }+                deriving (Eq,Show)++focus :: Zipper a -> a+focus = current++next, previous :: Zipper a -> Maybe (Zipper a)+next     (Zipper _ _ [])      = Nothing+next     (Zipper ps c (n:ns)) = Just $ Zipper (c:ps) n ns+previous (Zipper [] _ _)      = Nothing+previous (Zipper (p:ps) c ns) = Just $ Zipper ps p (c:ns)++fromList :: [a] -> Maybe (Zipper a)+fromList [] = Nothing+fromList (a:as) = Just $ Zipper [] a as++instance Functor Zipper where+  fmap f (Zipper ps c ns) = Zipper (fmap f ps) (f c) (fmap f ns)++instance Traversable Zipper where+  traverse f (Zipper ps c ns) =   Zipper+                              <$> (reverse <$> traverse f (reverse ps))+                              <*> f c+                              <*> (traverse f ns)++instance Foldable Zipper where+  foldMap f (Zipper ps c ns) = foldMap f ps `mappend` f c `mappend` foldMap f ns
tkhs.cabal view
@@ -1,5 +1,5 @@ name:                tkhs-version:             0.2.1+version:             0.2.2 synopsis:            Simple Presentation Utility description:         If you want to give your presentation in a terminal,                      or if PowerPoint would be overkill, you may find tkhs useful.@@ -24,15 +24,15 @@   main-is:           Main.hs   ghc-options:       -Wall   build-depends:     base == 4.*-                   , pointedlist                    , mtl                    , vty == 4.*-                   , parsec == 3.*+                   , parsec == 2.*                    , pretty                    , utf8-string   other-modules:     Vty                      Tkhs                      Parser+                     Zipper   if flag(test)     buildable:       False