Commit 2e5d79c9 authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Workaorund of front end bug

parent 749c835b
......@@ -38,7 +38,7 @@ module Pretty (
) where
import Dequeue as Q
import Dequeue
infixl 1 <>, <+>, <$>, </>, <$$>, <//>
......@@ -241,7 +241,7 @@ oneGroup (Line s ts) w p e outGrpPre =
outLine h c r ms@(m:_) =
if h then s ++ c (r-lens) ms else '\n' : replicate m ' ' ++ c (w-m) ms
oneGroup (Open ts) w p e outGrpPre =
multiGroup ts w p e outGrpPre Q.empty p (\_ c -> c)
multiGroup ts w p e outGrpPre Dequeue.empty p (\_ c -> c)
oneGroup (Close ts) w p e outGrpPre = outGrpPre (p<=e) (noGroup ts w p)
oneGroup (OpenNest f ts) w p e outGrpPre =
oneGroup ts w p e (\h c -> outGrpPre h (\r ms -> c r (f ms r w)))
......
......@@ -4,53 +4,53 @@
--- All the operations on sets are generic, i.e., one has to provide
--- an explicit order predicate ("<CODE>cmp</CODE>" below) on elements.
---
--- @author Johannes Koj, Michael Hanus, Bernd Braßel
--- @author Johannes Koj, Michael Hanus, Bernd Braßel
--- @version May 2003
----------------------------------------------------------------------------
module SetRBT where
import qualified RedBlackTree as RBT
import qualified RedBlackTree
import Maybe (isJust)
----------------------------------------------------------------------------
-- the main interface:
type SetRBT a = RBT.RedBlackTree a
type SetRBT a = RedBlackTree.RedBlackTree a
--- Returns an empty set, i.e., an empty red-black tree
--- augmented with an order predicate.
emptySetRBT = RBT.empty (==) (==)
emptySetRBT = RedBlackTree.empty (==) (==)
--- Returns true if an element is contained in a (red-black tree) set.
--- @param e - an element to be checked for containment
--- @param s - a set (represented as a red-black tree)
--- @return True if e is contained in s
elemRBT :: a -> SetRBT a -> Bool
elemRBT e = isJust . (RBT.lookup e)
elemRBT e = isJust . (RedBlackTree.lookup e)
--- Inserts an element into a set if it is not already there.
insertRBT :: a -> SetRBT a -> SetRBT a
insertRBT = RBT.update
insertRBT = RedBlackTree.update
--- Inserts an element into a multiset.
--- Thus, the same element can have several occurrences in the multiset.
insertMultiRBT :: a -> SetRBT a -> SetRBT a
insertMultiRBT e = RBT.setInsertEquivalence (==) .
RBT.update e .
RBT.setInsertEquivalence (\ _ _ -> False)
insertMultiRBT e = RedBlackTree.setInsertEquivalence (==) .
RedBlackTree.update e .
RedBlackTree.setInsertEquivalence (\ _ _ -> False)
--- delete an element from a set.
--- Deletes only a single element from a multi set
deleteRBT :: a -> SetRBT a -> SetRBT a
deleteRBT = RBT.delete
deleteRBT = RedBlackTree.delete
--- Transforms a (red-black tree) set into an ordered list of its elements.
setRBT2list :: SetRBT a -> [a]
setRBT2list = RBT.tree2list
setRBT2list = RedBlackTree.tree2list
--- Computes the union of two (red-black tree) sets.
--- This is done by inserting all elements of the first set into the
......@@ -63,7 +63,7 @@ unionRBT s1 s2 = foldr insertRBT s2 (setRBT2list s1)
--- contained in the second set into a new set, which order
--- is taken from the first set.
intersectRBT :: SetRBT a -> SetRBT a -> SetRBT a
intersectRBT s1 s2 = foldr insertRBT (RBT.newTreeLike s1)
intersectRBT s1 s2 = foldr insertRBT (RedBlackTree.newTreeLike s1)
(filter (\e->elemRBT e s2) (setRBT2list s1))
......@@ -71,5 +71,5 @@ intersectRBT s1 s2 = foldr insertRBT (RBT.newTreeLike s1)
--- The first argument is the order for the elements.
sortRBT :: (a->a->Bool) -> [a] -> [a]
sortRBT = RBT.sort
sortRBT = RedBlackTree.sort
......@@ -21,7 +21,7 @@ module StyledText (
import Char
import Pretty
import AnsiCodes as Ansi
import AnsiCodes
-- import GUI
--import HTML
......@@ -163,11 +163,11 @@ printStyledText = putStrLn . toAnsiString
toAnsiString :: String -> String
toAnsiString
= interpret
[Ansi.bold, Ansi.underline
,Ansi.black, Ansi.blue, Ansi.cyan, Ansi.green, Ansi.magenta, Ansi.red
,Ansi.white, Ansi.yellow
,Ansi.bgBlack, Ansi.bgBlue, Ansi.bgCyan, Ansi.bgGreen, Ansi.bgMagenta
,Ansi.bgRed, Ansi.bgWhite, Ansi.bgYellow]
[bold, underline
,black, blue, cyan, green, magenta, red
,white, yellow
,bgBlack, bgBlue, bgCyan, bgGreen, bgMagenta
,bgRed, bgWhite, bgYellow]
(++) (.) id [(id,id,id)]
......
......@@ -6,28 +6,28 @@
--- an explicit order predicate ("<CODE>cmp</CODE>" below) on elements.
--- Each inner node in the red-black tree contains a key-value association.
---
--- @author Johannes Koj, Michael Hanus, Bernd Braßel
--- @author Johannes Koj, Michael Hanus, Bernd Braßel
--- @version March 2005
----------------------------------------------------------------------------
module TableRBT where
import qualified RedBlackTree as RBT
import qualified RedBlackTree
----------------------------------------------------------------------------
-- the main interface:
type TableRBT key a = RBT.RedBlackTree (key,a)
type TableRBT key a = RedBlackTree.RedBlackTree (key,a)
--- Returns an empty table, i.e., an empty red-black tree.
emptyTableRBT :: (a -> a -> Bool) -> TableRBT a _
emptyTableRBT lt = RBT.empty (\ x y -> fst x==fst y)
emptyTableRBT lt = RedBlackTree.empty (\ x y -> fst x==fst y)
(\ x y -> fst x==fst y)
(\ x y -> lt (fst x) (fst y))
--- tests whether a given table is empty
isEmptyTable :: TableRBT _ _ -> Bool
isEmptyTable = RBT.isEmpty
isEmptyTable = RedBlackTree.isEmpty
--- Looks up an entry in a table.
--- @param k - a key under which a value is stored
......@@ -35,17 +35,17 @@ isEmptyTable = RBT.isEmpty
--- @return (Just v) if v is the value stored with key k,
--- otherwise Nothing is returned.
lookupRBT :: key -> TableRBT key a -> Maybe a
lookupRBT k = maybe Nothing (Just . snd) . RBT.lookup (k,failed)
lookupRBT k = maybe Nothing (Just . snd) . RedBlackTree.lookup (k,failed)
--- Inserts or updates an element in a table.
updateRBT :: key -> a -> TableRBT key a -> TableRBT key a
updateRBT k e = RBT.update (k,e)
updateRBT k e = RedBlackTree.update (k,e)
--- Transforms the nodes of red-black tree into a list.
tableRBT2list :: TableRBT key a -> [(key,a)]
tableRBT2list = RBT.tree2list
tableRBT2list = RedBlackTree.tree2list
deleteRBT :: key -> TableRBT key a -> TableRBT key a
deleteRBT key = RBT.delete (key,failed)
deleteRBT key = RedBlackTree.delete (key,failed)
-- end of TableRBT
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment