pire-0.2.5

Copyright(c) Andreas Reuleaux 2015-2018
LicenseBSD2
MaintainerAndreas Reuleaux <rx@a-rx.info>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

OldRange

Description

calculate token ranges (ie. exact position information), based upon Trifecta Delta's and LineColunn numbers.

Synopsis

Documentation

class Decorated t Source #

Instances
Decorated (t', Delta) Source # 
Instance details

Defined in OldRange

class InRange x where Source #

Minimal complete definition

inRange

Methods

inRange :: Pos -> x -> Bool Source #

Instances
InRange DetailedRange Source # 
Instance details

Defined in OldRange

InRange Range Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Range -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange [(Maybe (Token SemiColonTy t), Match t t)] Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> [(Maybe (Token SemiColonTy t), Match t t)] -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange [(Eps, Pattern t)] Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> [(Eps, Pattern t)] -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange [(ConstructorDef t t, Maybe (Token SemiColonTy t))] Source # 
Instance details

Defined in OldRange

(Decorated t, HasRange t, HasDetailedRange t) => InRange [(Match t t, Maybe (Token SemiColonTy t))] Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> [(Match t t, Maybe (Token SemiColonTy t))] -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange [(Pattern t, Eps)] Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> [(Pattern t, Eps)] -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange [ModuleImport t] Source #

\[ModuleImport\]

>>> range $ [ModuleImport_ {_importtok = ImportTok ("import",Lines 6 0 0 0) (Ws ("   ",Lines 6 6 0 0)), _importnm = Nm_ ("Nat",Lines 6 9 0 0) (Ws ("\n",Lines 6 12 0 0))},ModuleImport_ {_importtok = ImportTok ("import",Lines 7 0 0 0) (Ws (" ",Lines 7 6 0 0)), _importnm = Nm_ ("Sample",Lines 7 7 0 0) (Ws ("\n\n",Lines 7 13 0 0))}]
Range (Pos 6 0) (Pos 8 0)
>>> drange $ [ModuleImport_ {_importtok = ImportTok ("import",Lines 6 0 0 0) (Ws ("   ",Lines 6 6 0 0)), _importnm = Nm_ ("Nat",Lines 6 9 0 0) (Ws ("\n",Lines 6 12 0 0))},ModuleImport_ {_importtok = ImportTok ("import",Lines 7 0 0 0) (Ws (" ",Lines 7 6 0 0)), _importnm = Nm_ ("Sample",Lines 7 7 0 0) (Ws ("\n\n",Lines 7 13 0 0))}]
DetailedRange [Pos 6 0,Pos 6 1,Pos 6 2,Pos 6 3,Pos 6 4,Pos 6 5,Pos 6 6,Pos 6 7,Pos 6 8,Pos 6 9,Pos 6 10,Pos 6 11,Pos 6 12,Pos 7 0,Pos 7 1,Pos 7 2,Pos 7 3,Pos 7 4,Pos 7 5,Pos 7 6,Pos 7 7,Pos 7 8,Pos 7 9,Pos 7 10,Pos 7 11,Pos 7 12,Pos 7 13,Pos 8 0]
Instance details

Defined in OldRange

Methods

inRange :: Pos -> [ModuleImport t] -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange [Decl t t] Source #

ranges of lists of decls, examples/tests!

Instance details

Defined in OldRange

Methods

inRange :: Pos -> [Decl t t] -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange [Arg t t] Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> [Arg t t] -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange [Match t t] Source #
  • - -- >>> nat (silence $ runExceptT $ getModules_ ["samples"] "Nat")>= return . last . fromRight'
  • - -- >>> let Case_ casetok exp of' mayopen matches mayclose annot = fromExp $ fromRight' $ (ezipper $ Mod $ decorateM $ wrap nat) >>= toDecl 2 >>= right >>= body >>= focus
  • - -- >>> range (snd $ matches !! 0)
  • - -- Range (Pos 17 2) (Pos 18 1)
  • - -- >>> range (matches !! 0)
  • - -- Range (Pos 17 2) (Pos 18 1)
  • - -- >>> (Pos 17 10) inRange (snd $ matches !! 0)
  • - -- True
  • - -- >>> (Pos 17 10) inRange (matches !! 0)
  • - -- True
Instance details

Defined in OldRange

Methods

inRange :: Pos -> [Match t t] -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange [Expr t t] Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> [Expr t t] -> Bool Source #

InRange t => InRange (Maybe t) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Maybe t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Ws t) Source #

Ws

>>> range $ Ws ("   ",Lines 6 6 0 0)
Range (Pos 6 6) (Pos 6 8)
>>> drange $ Ws ("   ",Lines 6 6 0 0)
DetailedRange [Pos 6 6,Pos 6 7,Pos 6 8]
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Ws t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Nm t) Source #
>>> range $ Nm_ ("g",Lines 15 0 0 0) (Ws (" ",Lines 15 1 0 0))
Range (Pos 15 0) (Pos 15 1)
>>> drange $ Nm_ ("g",Lines 15 0 0 0) (Ws (" ",Lines 15 1 0 0))
DetailedRange [Pos 15 0,Pos 15 1]
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Nm t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (ModuleImport t) Source #

ModuleImport

>>> range $ ModuleImport_ {_importtok = ImportTok ("import",Lines 6 0 0 0) (Ws ("   ",Lines 6 6 0 0)), _importnm = Nm_ ("Nat",Lines 6 9 0 0) (Ws ("\n",Lines 6 12 0 0))}
Range (Pos 6 0) (Pos 6 12)
>>> drange $ ModuleImport_ {_importtok = ImportTok ("import",Lines 6 0 0 0) (Ws ("   ",Lines 6 6 0 0)), _importnm = Nm_ ("Nat",Lines 6 9 0 0) (Ws ("\n",Lines 6 12 0 0))}
DetailedRange [Pos 6 0,Pos 6 1,Pos 6 2,Pos 6 3,Pos 6 4,Pos 6 5,Pos 6 6,Pos 6 7,Pos 6 8,Pos 6 9,Pos 6 10,Pos 6 11,Pos 6 12]
Instance details

Defined in OldRange

Methods

inRange :: Pos -> ModuleImport t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Pattern t) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Pattern t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Maybe (Token SemiColonTy t), Match t t) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> (Maybe (Token SemiColonTy t), Match t t) -> Bool Source #

InRange (String, Delta) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> (String, Delta) -> Bool Source #

InRange (Text, Delta) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> (Text, Delta) -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Eps, Pattern t) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> (Eps, Pattern t) -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (ConstructorDef t t, Maybe (Token SemiColonTy t)) Source # 
Instance details

Defined in OldRange

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Match t t, Maybe (Token SemiColonTy t)) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> (Match t t, Maybe (Token SemiColonTy t)) -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Pattern t, Eps) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> (Pattern t, Eps) -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Token ty t) Source #

ImportTok

>>> range $ ImportTok ("import",Lines 6 0 0 0) (Ws ("   ",Lines 6 6 0 0))
Range (Pos 6 0) (Pos 6 8)
>>> drange $ ImportTok ("import",Lines 6 0 0 0) (Ws ("   ",Lines 6 6 0 0))
DetailedRange [Pos 6 0,Pos 6 1,Pos 6 2,Pos 6 3,Pos 6 4,Pos 6 5,Pos 6 6,Pos 6 7,Pos 6 8]

Equal

>>> range $ Equal ("=",Lines 11 2 0 0) (Ws (" ",Lines 11 3 0 0))
Range (Pos 11 2) (Pos 11 3)
>>> drange $ Equal ("=",Lines 11 2 0 0) (Ws (" ",Lines 11 3 0 0))
DetailedRange [Pos 11 2,Pos 11 3]

LamTok

>>> range $ LamTok ("\\",Lines 9 4 0 0) (Ws ("  ",Lines 9 5 0 0))
Range (Pos 9 4) (Pos 9 6)
>>> drange $ LamTok ("\\",Lines 9 4 0 0) (Ws ("  ",Lines 9 5 0 0))
DetailedRange [Pos 9 4,Pos 9 5,Pos 9 6]

Dot

>>> range $ (Dot (".",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
Range (Pos 9 7) (Pos 9 8)
>>> drange $ (Dot (".",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
DetailedRange [Pos 9 7,Pos 9 8]

ParenOpen

>>> range $ (ParenOpen ("(",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
Range (Pos 9 7) (Pos 9 8)
>>> drange $ (ParenOpen ("(",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
DetailedRange [Pos 9 7,Pos 9 8]

ParenClose

>>> range $ (ParenClose (")",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
Range (Pos 9 7) (Pos 9 8)
>>> drange $ (ParenClose (")",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
DetailedRange [Pos 9 7,Pos 9 8]

BracketOpen

>>> range $ (BracketOpen ("[",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
Range (Pos 9 7) (Pos 9 8)
>>> drange $ (BracketOpen ("[",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
DetailedRange [Pos 9 7,Pos 9 8]

BracketClose

>>> range $ (BracketClose ("[",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
Range (Pos 9 7) (Pos 9 8)
>>> drange $ (BracketClose ("[",Lines 9 7 0 0) (Ws (" ",Lines 9 8 0 0)))
DetailedRange [Pos 9 7,Pos 9 8]

missing still: doctests/examples for VBar, Comma, Of, PcaseTok, CaseTok, SubsTok, By

Instance details

Defined in OldRange

Methods

inRange :: Pos -> Token ty t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Decl t t) Source #

ranges of decls, examples/tests!

Instance details

Defined in OldRange

Methods

inRange :: Pos -> Decl t t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (ConstructorDef t t) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> ConstructorDef t t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Telescope t t) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Telescope t t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Arg t t) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Arg t t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Match t t) Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Match t t -> Bool Source #

(Decorated t, HasRange t, HasDetailedRange t) => InRange (Expr t t) Source #

ranges of exprs

>>> range $ decorate (wrap $ parse expr_ "f   ") beginning
Range (Pos 0 0) (Pos 0 3)
>>> range $ decorate (wrap $ parse expr_ "f a b  ") beginning
Range (Pos 0 0) (Pos 0 6)
>>> range $ decorate (wrap $ parse expr_ "\\ x . f a b{-ws-}") beginning
Range (Pos 0 0) (Pos 0 16)
>>> drange $ (decorate (wrap $ parse expr_ "f a b{-ws-}") beginning)
DetailedRange [Pos 0 0,Pos 0 1,Pos 0 2,Pos 0 3,Pos 0 4,Pos 0 5,Pos 0 6,Pos 0 7,Pos 0 8,Pos 0 9,Pos 0 10]
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Expr t t -> Bool Source #

class HasDetailedRange t where Source #

Minimal complete definition

drange

Methods

drange :: t -> DetailedRange Source #

"detailed range"

Instances
(Decorated t, HasDetailedRange t) => HasDetailedRange [(Maybe (Token SemiColonTy t), Match t t)] Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange [(Eps, Pattern t)] Source # 
Instance details

Defined in OldRange

Methods

drange :: [(Eps, Pattern t)] -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange [(ConstructorDef t t, Maybe (Token SemiColonTy t))] Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange [(Match t t, Maybe (Token SemiColonTy t))] Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange [(Pattern t, Eps)] Source # 
Instance details

Defined in OldRange

Methods

drange :: [(Pattern t, Eps)] -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange [ModuleImport t] Source #

cf inRange below

Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange [Decl t t] Source # 
Instance details

Defined in OldRange

Methods

drange :: [Decl t t] -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange [Arg t t] Source # 
Instance details

Defined in OldRange

Methods

drange :: [Arg t t] -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange [Match t t] Source # 
Instance details

Defined in OldRange

Methods

drange :: [Match t t] -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange [Expr t t] Source # 
Instance details

Defined in OldRange

Methods

drange :: [Expr t t] -> DetailedRange Source #

HasDetailedRange t => HasDetailedRange (Maybe t) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (Ws t) Source # 
Instance details

Defined in OldRange

Methods

drange :: Ws t -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange (Nm t) Source # 
Instance details

Defined in OldRange

Methods

drange :: Nm t -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange (ModuleImport t) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (Pattern t) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (Maybe (Token SemiColonTy t), Match t t) Source # 
Instance details

Defined in OldRange

HasDetailedRange (String, Delta) Source # 
Instance details

Defined in OldRange

HasDetailedRange (Text, Delta) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (Eps, Pattern t) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (ConstructorDef t t, Maybe (Token SemiColonTy t)) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (Match t t, Maybe (Token SemiColonTy t)) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (Pattern t, Eps) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (Token ty t) Source # 
Instance details

Defined in OldRange

Methods

drange :: Token ty t -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange (Decl t t) Source # 
Instance details

Defined in OldRange

Methods

drange :: Decl t t -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange (ConstructorDef t t) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (Telescope t t) Source # 
Instance details

Defined in OldRange

(Decorated t, HasDetailedRange t) => HasDetailedRange (Arg t t) Source # 
Instance details

Defined in OldRange

Methods

drange :: Arg t t -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange (Match t t) Source # 
Instance details

Defined in OldRange

Methods

drange :: Match t t -> DetailedRange Source #

(Decorated t, HasDetailedRange t) => HasDetailedRange (Expr t t) Source #

cf inRange below

Instance details

Defined in OldRange

Methods

drange :: Expr t t -> DetailedRange Source #

class HasRange t where Source #

range of a token (ie. of the text parts within the token), but also more generally: of any piece of the syntax tree: exprs, decls

Minimal complete definition

range

Methods

range :: t -> Range Source #

Instances
(Decorated t, HasRange t) => HasRange [(Maybe (Token SemiColonTy t), Match t t)] Source # 
Instance details

Defined in OldRange

Methods

range :: [(Maybe (Token SemiColonTy t), Match t t)] -> Range Source #

(Decorated t, HasRange t) => HasRange [(Eps, Pattern t)] Source # 
Instance details

Defined in OldRange

Methods

range :: [(Eps, Pattern t)] -> Range Source #

(Decorated t, HasRange t) => HasRange [(ConstructorDef t t, Maybe (Token SemiColonTy t))] Source # 
Instance details

Defined in OldRange

(Decorated t, HasRange t) => HasRange [(Match t t, Maybe (Token SemiColonTy t))] Source # 
Instance details

Defined in OldRange

Methods

range :: [(Match t t, Maybe (Token SemiColonTy t))] -> Range Source #

(Decorated t, HasRange t) => HasRange [(Pattern t, Eps)] Source # 
Instance details

Defined in OldRange

Methods

range :: [(Pattern t, Eps)] -> Range Source #

(Decorated t, HasRange t) => HasRange [ModuleImport t] Source #

cf inRange below

Instance details

Defined in OldRange

Methods

range :: [ModuleImport t] -> Range Source #

(Decorated t, HasRange t) => HasRange [Decl t t] Source # 
Instance details

Defined in OldRange

Methods

range :: [Decl t t] -> Range Source #

(Decorated t, HasRange t) => HasRange [Arg t t] Source # 
Instance details

Defined in OldRange

Methods

range :: [Arg t t] -> Range Source #

(Decorated t, HasRange t) => HasRange [Match t t] Source # 
Instance details

Defined in OldRange

Methods

range :: [Match t t] -> Range Source #

(Decorated t, HasRange t) => HasRange [Expr t t] Source # 
Instance details

Defined in OldRange

Methods

range :: [Expr t t] -> Range Source #

HasRange t => HasRange (Maybe t) Source # 
Instance details

Defined in OldRange

Methods

range :: Maybe t -> Range Source #

(Decorated t, HasRange t) => HasRange (Ws t) Source # 
Instance details

Defined in OldRange

Methods

range :: Ws t -> Range Source #

(Decorated t, HasRange t) => HasRange (Nm t) Source # 
Instance details

Defined in OldRange

Methods

range :: Nm t -> Range Source #

(Decorated t, HasRange t) => HasRange (ModuleImport t) Source # 
Instance details

Defined in OldRange

(Decorated t, HasRange t) => HasRange (Pattern t) Source # 
Instance details

Defined in OldRange

Methods

range :: Pattern t -> Range Source #

(Decorated t, HasRange t) => HasRange (Maybe (Token SemiColonTy t), Match t t) Source # 
Instance details

Defined in OldRange

Methods

range :: (Maybe (Token SemiColonTy t), Match t t) -> Range Source #

HasRange (String, Delta) Source # 
Instance details

Defined in OldRange

Methods

range :: (String, Delta) -> Range Source #

HasRange (Text, Delta) Source # 
Instance details

Defined in OldRange

Methods

range :: (Text, Delta) -> Range Source #

(Decorated t, HasRange t) => HasRange (Eps, Pattern t) Source # 
Instance details

Defined in OldRange

Methods

range :: (Eps, Pattern t) -> Range Source #

(Decorated t, HasRange t) => HasRange (ConstructorDef t t, Maybe (Token SemiColonTy t)) Source # 
Instance details

Defined in OldRange

(Decorated t, HasRange t) => HasRange (Match t t, Maybe (Token SemiColonTy t)) Source # 
Instance details

Defined in OldRange

Methods

range :: (Match t t, Maybe (Token SemiColonTy t)) -> Range Source #

(Decorated t, HasRange t) => HasRange (Pattern t, Eps) Source # 
Instance details

Defined in OldRange

Methods

range :: (Pattern t, Eps) -> Range Source #

(Decorated t, HasRange t) => HasRange (Token ty t) Source # 
Instance details

Defined in OldRange

Methods

range :: Token ty t -> Range Source #

(Decorated t, HasRange t) => HasRange (Decl t t) Source # 
Instance details

Defined in OldRange

Methods

range :: Decl t t -> Range Source #

(Decorated t, HasRange t) => HasRange (ConstructorDef t t) Source # 
Instance details

Defined in OldRange

Methods

range :: ConstructorDef t t -> Range Source #

(Decorated t, HasRange t) => HasRange (Telescope t t) Source # 
Instance details

Defined in OldRange

Methods

range :: Telescope t t -> Range Source #

(Decorated t, HasRange t) => HasRange (Arg t t) Source # 
Instance details

Defined in OldRange

Methods

range :: Arg t t -> Range Source #

(Decorated t, HasRange t) => HasRange (Match t t) Source # 
Instance details

Defined in OldRange

Methods

range :: Match t t -> Range Source #

(Decorated t, HasRange t) => HasRange (Expr t t) Source #

cf inRange below

Instance details

Defined in OldRange

Methods

range :: Expr t t -> Range Source #

data Range Source #

(Pos 8 100) inRange ("hello n n n", Range (Pos 7 0) (To 9 2)) ? No: there is no 100th char in line 8 (the understanding is, that lines are not just infinitely long, that way we get more precise position info)

7 "hello  n"
8 " n"
9 "  n"
>>> let range = rangeS "hello  \n \n  \n" (Pos 7 0)
>>> range
Range (Pos 7 0) (Pos 9 2)
>>> let detailed = detailedRangeS "hello  \n \n  \n" (Pos 7 0)
>>> detailed
DetailedRange [Pos 7 0,Pos 7 1,Pos 7 2,Pos 7 3,Pos 7 4,Pos 7 5,Pos 7 6,Pos 7 7,Pos 8 0,Pos 8 1,Pos 9 0,Pos 9 1,Pos 9 2]
>>> (Pos 8 100) `inRange` (detailedRangeS "hello  \n \n  \n" (Pos 7 0))
False

but (Pos 8 2) deserves more attention: it seems: yes, but details inspection reveals: no

>>> (Pos 8 100) `inRange` range
True
>>> (Pos 8 100) `inRange` detailed
False
>>> detailedRangeS " " (Pos 4 6)
DetailedRange [Pos 4 6]
>>> (Pos 4 6) `inRange` (detailedRangeS " " (Pos 4 6))
True
>>> (Pos 4 7) `inRange` (detailedRangeS " " (Pos 4 6))
False
>>> (detailedRangeS "\n\n" (Pos 4 17))
DetailedRange [Pos 4 17,Pos 5 0]
>>> (Pos 4 17) `inRange` (detailedRangeS "\n\n" (Pos 4 17))
True
>>> rangeS         "hello  \n \n  \n" (Pos 7 0)
Range (Pos 7 0) (Pos 9 2)
>>> detailedRangeS "hello  \n \n  \n" (Pos 7 0)
DetailedRange [Pos 7 0,Pos 7 1,Pos 7 2,Pos 7 3,Pos 7 4,Pos 7 5,Pos 7 6,Pos 7 7,Pos 8 0,Pos 8 1,Pos 9 0,Pos 9 1,Pos 9 2]
>>> (Pos 7 2)   `inRange` (detailedRangeS "hello  \n \n  \n" (Pos 7 0))
True
>>> rangeS "hello  \n \n  \n" (Pos 4 6)
Range (Pos 4 6) (Pos 6 2)
>>> detailedRangeS "hello  \n \n  \n" (Pos 4 6)
DetailedRange [Pos 4 6,Pos 4 7,Pos 4 8,Pos 4 9,Pos 4 10,Pos 4 11,Pos 4 12,Pos 4 13,Pos 5 0,Pos 5 1,Pos 6 0,Pos 6 1,Pos 6 2]
>>> (Pos 4 6) `inRange` (detailedRangeS "hello  \n \n  \n" (Pos 4 6))
True
>>> detailedRangeS "hello  \n \n  \n" (Pos 7 0)
DetailedRange [Pos 7 0,Pos 7 1,Pos 7 2,Pos 7 3,Pos 7 4,Pos 7 5,Pos 7 6,Pos 7 7,Pos 8 0,Pos 8 1,Pos 9 0,Pos 9 1,Pos 9 2]
>>> (Pos 7 0) `inRange` (detailedRangeS "hello  \n \n  \n" (Pos 7 0))
True
>>> (Pos 7 8) `inRange` (detailedRangeS "hello  \n \n  \n" (Pos 7 0))
False
>>> (Pos 8 1) `inRange` (detailedRangeS "hello  \n \n  \n" (Pos 7 0))
True
>>> (Pos 8 100) `inRange` (detailedRangeS "hello  \n \n  \n" (Pos 7 0))
False

Constructors

Range Pos Pos 
NoRange 
Instances
Show Range Source # 
Instance details

Defined in OldRange

Methods

showsPrec :: Int -> Range -> ShowS #

show :: Range -> String #

showList :: [Range] -> ShowS #

Semigroup Range Source # 
Instance details

Defined in OldRange

Methods

(<>) :: Range -> Range -> Range #

sconcat :: NonEmpty Range -> Range #

stimes :: Integral b => b -> Range -> Range #

Monoid Range Source # 
Instance details

Defined in OldRange

Methods

mempty :: Range #

mappend :: Range -> Range -> Range #

mconcat :: [Range] -> Range #

InRange Range Source # 
Instance details

Defined in OldRange

Methods

inRange :: Pos -> Range -> Bool Source #

foo :: [Pos] -> String -> Pos -> [Pos] Source #

>>> foo [] "hi\n  " (Pos 4 16)
[Pos 4 16,Pos 4 17,Pos 4 18,Pos 5 0,Pos 5 1]

fooT :: [Pos] -> Text -> Pos -> [Pos] Source #

detailedRangeS :: [Char] -> Pos -> DetailedRange Source #

helpers take a Pos (not a Delta)