Fix Location, a type signature issue, clean up warnings. (#5953)

Makes Location a normal type.
This commit is contained in:
James Dunkerley 2023-03-15 18:19:28 +00:00 committed by GitHub
parent e666d797c5
commit 919e9474c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 35 deletions

View File

@ -10,7 +10,7 @@ import project.Data.Range.Range
import project.Data.Text.Case.Case
import project.Data.Text.Case_Sensitivity.Case_Sensitivity
import project.Data.Text.Encoding.Encoding
import project.Data.Text.Location
import project.Data.Text.Location.Location
import project.Data.Text.Matching_Mode.Matching_Mode
import project.Data.Text.Regex.Match.Match
import project.Data.Text.Regex.Regex_Mode.Regex_Mode
@ -1002,10 +1002,12 @@ Text.to_case self case_option=Case.Lower locale=Locale.default = case case_optio
"HELLO".pad 9 "AB" == "HELLOABAB"
"HELLO".pad 8 "AB" == "HELLOABA"
"HELLO".pad 8 "AB" Start == "BABHELLO"
"HELLO".pad 8 "AB" Location.Start == "BABHELLO"
Text.pad : Integer -> Text -> (Location.Start | Location.End) -> Text
Text.pad self length=0 with_pad=' ' at=Location.End =
Text.pad : Integer -> Text -> Location -> Text
Text.pad self length=0 with_pad=' ' at=Location.End = case at of
Location.Both -> Error.throw (Illegal_Argument.Error "`Location.Both` cannot be used with `pad`.")
_ ->
with_pad_length = with_pad.length
if with_pad_length == 0 then Error.throw (Illegal_Argument.Error "`with_pad` must not be an empty string.") else
pad_size = length - self.length
@ -1033,15 +1035,15 @@ Text.pad self length=0 with_pad=' ' at=Location.End =
Trimming whitespace from a string.
" Hello! ".trim == "Hello!"
" Hello! ".trim Start == "Hello! "
" Hello! ".trim End == " Hello!"
" Hello! ".trim Location.Start == "Hello! "
" Hello! ".trim Location.End == " Hello!"
> Example
Trimming a specific set of letters from a string.
"ABC123".trim Start "ABC" == "123"
"ABBA123".trim Start "ABC" == "123"
Text.trim : (Location.Start | Location.End | Location.Both) -> (Text | (Text -> Boolean)) -> Text
"ABC123".trim Location.Start "ABC" == "123"
"ABBA123".trim Location.Start "ABC" == "123"
Text.trim : Location -> (Text | (Text -> Boolean)) -> Text
Text.trim self where=Location.Both what=_.is_whitespace =
predicate = case what of
_ : Text -> what.contains _

View File

@ -1,8 +1,9 @@
type Location
## Indicates the beginning of a text.
type Start
Start
## Indicates the end of a text.
type End
End
## Indicates both the beginning and end of a text.
type Both
Both

View File

@ -89,7 +89,7 @@ import project.Data.Text.Case_Sensitivity.Case_Sensitivity
import project.Data.Text.Encoding.Encoding
import project.Data.Text.Extensions
import project.Data.Text.Line_Ending_Style.Line_Ending_Style
import project.Data.Text.Location
import project.Data.Text.Location.Location
import project.Data.Text.Matching_Mode.Matching_Mode
import project.Data.Text.Regex
import project.Data.Text.Regex.Regex_Mode.Regex_Mode
@ -141,7 +141,7 @@ export project.Data.Text.Case_Sensitivity.Case_Sensitivity
export project.Data.Text.Encoding.Encoding
export project.Data.Text.Extensions
export project.Data.Text.Line_Ending_Style.Line_Ending_Style
export project.Data.Text.Location
export project.Data.Text.Location.Location
export project.Data.Text.Matching_Mode.Matching_Mode
export project.Data.Text.Regex
export project.Data.Text.Regex.Regex_Mode.Regex_Mode

View File

@ -307,6 +307,6 @@ Row.to_default_visualization_data self =
## UNSTABLE
ADVANCED
Returns the data requested to render a lazy view of the default visualisation.
Table.to_lazy_visualization_data : Vector Integer -> Vector Integer -> Vector Integer -> Text
Table.to_lazy_visualization_data : Vector Integer -> Vector Integer -> Vector Integer -> Integer -> Text
Table.to_lazy_visualization_data self table_cell_position text_window_position text_window_size chunk_size =
Table_Visualisation.get_lazy_visualisation_data self table_cell_position text_window_position text_window_size chunk_size

View File

@ -3,7 +3,7 @@ from Standard.Base import all
from Standard.Base.Data.Text.Extensions import slice_text
from Standard.Visualization.Text import get_chunk_from_line
import Standard.Base.Error.Common.Not_Found
from Standard.Table import Table
import Standard.Table as Table_Module
## PRIVATE
@ -40,7 +40,7 @@ type Table_Update
coordinate as origin and the extent of the window in text chunks and lines. The size of
a chunk (the characters in it) is defined by `chunk_width`. The output is formatted as a message
that can be sent to the IDE's lazy text visualisation.
get_lazy_visualisation_data : Vector Integer -> Vector Integer -> Vector Integer -> Text
get_lazy_visualisation_data : Table_Module.Table -> Vector Integer -> Vector Integer -> Vector Integer -> Integer -> Text
get_lazy_visualisation_data table table_cell_position text_window_position text_window_size chunk_size =
update = compute_table_update table table_cell_position text_window_position text_window_size chunk_size
update.to_json

View File

@ -24,8 +24,13 @@ type No_Ord
Value number
type No_Ord_Comparator
compare x y = Nothing
hash x = 0
compare x y =
_ = [x, y]
Nothing
hash x =
_ = x
0
Comparable.from (_:No_Ord) = No_Ord_Comparator

View File

@ -21,8 +21,13 @@ type No_Ord
Value number
type No_Ord_Comparator
compare x y = Nothing
hash x = 0
compare x y =
_ = [x, y]
Nothing
hash x =
_ = x
0
Comparable.from (_:No_Ord) = No_Ord_Comparator