packages feed

Focus-0.1.1 / src / Data / Scope.hs

module Data.Scope	( Scope(Scope)	, lower	, upper	, contains	, fromTuple	, toTuple	, everywhere	) whereimport Control.Arrow ( (&&&) )import Data.Focus ( Focus, toList, unfocused )import Data.List ( intercalate )data Scope = Scope Focus Focus deriving (Eq, Ord)instance Show Scope where	show (Scope lo hi) = "(" ++ (str lo) ++ "-" ++ (str hi) ++ ")" where		str = intercalate "." . map show . toListlower :: Scope -> Focuslower (Scope lo _) = loupper :: Scope -> Focusupper (Scope _ hi) = hicontains :: Scope -> Focus -> Boolcontains (Scope lo hi) f = f >= lo && f <= hifromTuple :: (Focus, Focus) -> ScopefromTuple (lo, hi) = Scope lo hitoTuple :: Scope -> (Focus, Focus)toTuple = lower &&& uppereverywhere :: Scopeeverywhere = Scope unfocused unfocused