haskell / haskell/text

Add a function `slice start end = take (end − start) . drop start`?

Open
#576 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
421
Forks
163
PR merge metrics
No merged PRs in 30d

Description

Many languages offer a feature that lets you take a substring by indices real quick. It is handy. Here is an example from JavaScript:

```
> "Hello World".slice (6, 11)
'World'
```

One frequent use case is when you have a parse tree annotated with locations and you want to recover the literal source of a given syntactic element. With `slice`, this is done at once.

Can we add such a function to `text`? Maybe it can have a more efficient implementation than `take … . drop …`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.