temochka / enclojure / Enclojure.Located

Some values have known locations in the evaluated source code. This module provides functions for working with them.

Types


type Located a
    = Located Location a

Represents a value a with location information.


type Location
    = Known Offsets
    | Unknown

Represents the location of a value in the source code. Known offsets or unknown.


type alias Offsets =
{ start : ( Basics.Int
, Basics.Int )
, end : ( Basics.Int
, Basics.Int ) 
}

Represents the offsets of the start and the end of a value in the source code.

Working with located values

at : ( Basics.Int, Basics.Int ) -> ( Basics.Int, Basics.Int ) -> a -> Located a

Wraps a in a location at given offsets

getValue : Located a -> a

Extracts the located value

map : (a -> b) -> Located a -> Located b

Applies a function to the located value

sameAs : Located a -> b -> Located b

Assigns location information from a to b

unknown : a -> Located a

Wraps a in an unknown location

Extracting location information

getLocation : Located a -> Location

Extract the location of a located value

getOffsets : Located a -> Maybe Offsets

Extract the offsets of the located value (if known)