Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into wip/no-extend-narro…
Browse files Browse the repository at this point in the history
…w-primop-names
  • Loading branch information
Ericson2314 committed Dec 12, 2020
2 parents 3ed977d + 1b275ff commit 454cb82
Show file tree
Hide file tree
Showing 72 changed files with 540 additions and 387 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
/GNUmakefile
/.ghc.environment.*
/cabal.project.local
/cabal.test.project.local

# Test data repo ignored. Please see instruction in tests-and-benchmarks.markdown
/tests/text-test-data/
160 changes: 102 additions & 58 deletions .travis.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions benchmarks/LICENSE
1 change: 1 addition & 0 deletions benchmarks/cbits
File renamed without changes.
1 change: 1 addition & 0 deletions benchmarks/include
2 changes: 1 addition & 1 deletion benchmarks/python/cut.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import utils, sys, codecs

Expand Down
13 changes: 6 additions & 7 deletions benchmarks/python/multilang.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import math
import sys
Expand All @@ -12,23 +12,22 @@ def timer(f, count=100):
a = 1e300
def g():
return
for i in xrange(3):
for i in range(3):
start = time.time()
for j in xrange(count):
for j in range(count):
g()
a = min(a, (time.time() - start) / count)

b = 1e300
for i in xrange(3):
for i in range(3):
start = time.time()
for j in xrange(count):
for j in range(count):
f()
b = min(b, (time.time() - start) / count)

return round(b - a, int(round(math.log(count, 10) - math.log(b - a, 10))))

contents = open('../../tests/text-test-data/yiwiki.xml', 'r').read()
contents = contents.decode('utf-8')

benchmarks = (
find_first,
Expand All @@ -47,4 +46,4 @@ def g():
for b in bms:
sys.stdout.write(b.__name__ + ' ')
sys.stdout.flush()
print b()
print(b())
2 changes: 1 addition & 1 deletion benchmarks/python/sort.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import utils, sys, codecs

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/python/strip_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import utils, sys

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/python/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import sys, time

Expand Down
1 change: 1 addition & 0 deletions benchmarks/src
19 changes: 13 additions & 6 deletions benchmarks/text-benchmarks.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ cabal-version: 1.12
name: text-benchmarks
version: 0.0.0.0
synopsis: Benchmarks for the text package
description: Benchmarks for the text package
description: Benchmarks for the text package.
homepage: https://bitbucket.org/bos/text
license: BSD2
license-file: ../LICENSE
license-file: LICENSE
author: Jasper Van der Jeugt <[email protected]>,
Bryan O'Sullivan <[email protected]>,
Tom Harper <[email protected]>,
Duncan Coutts <[email protected]>
maintainer: [email protected]
category: Text
build-type: Simple
tested-with: GHC==8.10.2, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4,
GHC==8.2.2, GHC==8.0.2, GHC==7.10.3

extra-source-files:
include/*.h

flag bytestring-builder
description: Depend on the bytestring-builder package for backwards compatibility.
Expand Down Expand Up @@ -54,7 +59,7 @@ executable text-benchmarks
build-depends: bytestring >= 0.10.4

-- modules for benchmark proper
c-sources: cbits/time_iconv.c
c-sources: cbits-bench/time_iconv.c
hs-source-dirs: haskell
main-is: Benchmarks.hs
other-modules:
Expand All @@ -81,9 +86,9 @@ executable text-benchmarks

-- Source code for IUT (implementation under test)
-- "borrowed" from parent folder
include-dirs: ../include
c-sources: ../cbits/cbits.c
hs-source-dirs: ..
include-dirs: include
c-sources: cbits/cbits.c
hs-source-dirs: src
other-modules:
Data.Text
Data.Text.Array
Expand All @@ -96,6 +101,7 @@ executable text-benchmarks
Data.Text.Internal.Builder.Functions
Data.Text.Internal.Builder.Int.Digits
Data.Text.Internal.Builder.RealFloat.Functions
Data.Text.Internal.ByteStringCompat
Data.Text.Internal.Encoding.Fusion
Data.Text.Internal.Encoding.Fusion.Common
Data.Text.Internal.Encoding.Utf16
Expand Down Expand Up @@ -132,6 +138,7 @@ executable text-benchmarks

default-language: Haskell2010
default-extensions: NondecreasingIndentation
other-extensions: DeriveAnyClass


executable text-multilang
Expand Down
8 changes: 8 additions & 0 deletions cabal.haskell-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
benchmarks: >=7.4
jobs-selection: any
doctest: True
doctest-options: -fobject-code -DINTEGER_GMP
branches: master

installed: +all -text -parsec
install-dependencies: False
5 changes: 4 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- See http://cabal.readthedocs.io/en/latest/nix-local-build-overview.html
packages: ., benchmarks, th-tests
packages: .
packages: tests
packages: th-tests
packages: benchmarks
tests: True
5 changes: 5 additions & 0 deletions cabal.tests.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- this project doesn't have local 'text' package,
-- so tests build faster.

packages: tests
tests: True
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 1.2.4.1

* Support `template-haskell-2.17.0.0`
* Support `bytestring-0.11`
* Add `take . drop` related RULE

### 1.2.4.0

* Add TH `Lift` instances for `Data.Text.Text` and `Data.Text.Lazy.Text` (gh-232)
Expand Down
30 changes: 30 additions & 0 deletions scripts/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

set -ex

runtest() {
HC=$1
shift

# EDIT last line to pass arguments

cabal run text-tests:test:tests \
--project-file=cabal.tests.project \
--builddir="dist-newstyle/$HC" \
--with-compiler="$HC" \
-- "$@"
}

runtest ghc-8.10.2 "$@"
runtest ghc-8.8.4 "$@"
runtest ghc-8.6.5 "$@"
runtest ghc-8.4.4 "$@"
runtest ghc-8.2.2 "$@"
runtest ghc-8.0.2 "$@"

runtest ghc-7.10.3 "$@"
runtest ghc-7.8.4 "$@"
runtest ghc-7.6.3 "$@"
runtest ghc-7.4.2 "$@"
runtest ghc-7.2.2 "$@"
runtest ghc-7.0.4 "$@"
13 changes: 13 additions & 0 deletions Data/Text.hs → src/Data/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ import qualified Language.Haskell.TH.Syntax as TH
import Text.Printf (PrintfArg, formatArg, formatString)
#endif

-- $setup
-- >>> import Data.Text
-- >>> import qualified Data.Text as T
-- >>> :seti -XOverloadedStrings

-- $character_definition
--
-- This package uses the term /character/ to denote Unicode /code points/.
Expand Down Expand Up @@ -1224,6 +1229,8 @@ drop n t@(Text arr off len)
drop n t = unstream (S.drop n (stream t))
"TEXT drop -> unfused" [1] forall n t.
unstream (S.drop n (stream t)) = drop n t
"TEXT take . drop -> unfused" [1] forall len off t.
unstream (S.take len (S.drop off (stream t))) = take len (drop off t)
#-}

-- | /O(n)/ 'dropEnd' @n@ @t@ returns the prefix remaining after
Expand Down Expand Up @@ -1352,13 +1359,19 @@ splitAt n t@(Text arr off len)
-- a pair whose first element is the longest prefix (possibly empty)
-- of @t@ of elements that satisfy @p@, and whose second is the
-- remainder of the list.
--
-- >>> T.span (=='0') "000AB"
-- ("000","AB")
span :: (Char -> Bool) -> Text -> (Text, Text)
span p t = case span_ p t of
(# hd,tl #) -> (hd,tl)
{-# INLINE span #-}

-- | /O(n)/ 'break' is like 'span', but the prefix returned is
-- over elements that fail the predicate @p@.
--
-- >>> T.break (=='c') "180cm"
-- ("180","cm")
break :: (Char -> Bool) -> Text -> (Text, Text)
break p = span (not . p)
{-# INLINE break #-}
Expand Down
File renamed without changes.
Loading

0 comments on commit 454cb82

Please sign in to comment.