Commit Graph

1205 Commits

Author SHA1 Message Date
adithyaov
18becf54c1 Move Memory/Malloc.hs to the Internal directory and expose it
Move it to Internal.Foreign.Malloc
2020-08-29 01:25:47 +05:30
adithyaov
9ccf93168b Provide a flag to use the C malloc instead of the default GHC malloc 2020-08-29 01:25:47 +05:30
Harendra Kumar
02f7ce0714 Fix since annotations of exception routines 2020-08-28 08:10:00 +05:30
Harendra Kumar
6d88edd6d3 Fix atomicity issue when clearing finalizer
In gbracket.
2020-08-27 00:19:31 +05:30
Harendra Kumar
a54a1ae9d2 Fix atomicity issue when running a finalizer
The clearing of finalizer from GC hook and running the finalizing action must
be atomic wrt async exceptions.
2020-08-27 00:19:31 +05:30
Harendra Kumar
bd7c518b6a Refactor the finalizer routines
For better modularity and clarity.
2020-08-27 00:19:31 +05:30
pranaysashank
1e5192145b Rename Internal.Mutable.Prim.Var to Internal.Data.IORef.Prim.
- Rename function fromPrimVar to fromPrimIORef.
2020-08-26 13:41:27 +05:30
Pranay Sashank
971da77528 Refactor gbracket, Add ghandle to retry the stream on exception. 2020-08-25 16:09:58 +05:30
pranaysashank
c8c161c34b Rename module Internal.Prelude to Internal.Data.Stream.IsStream. 2020-08-24 00:29:25 +05:30
pranaysashank
bf3780f65a Add encodeUtf8Lax. 2020-08-23 12:24:31 +05:30
Pranay Sashank
960def155f Make the finalizer based exception handling routines the default.
- Change the handlers for both streams and unfolds.
2020-08-23 11:50:59 +05:30
Harendra Kumar
1944ba0f17 Remove the Zipper module 2020-08-23 02:08:34 +05:30
Harendra Kumar
9e38d4a84e Simplify ParserK by using backtracking of ParserD
Remove the use of Zipper type, we now directly communicate with the parser
driver using the ParserD interface to backtrack in the input buffer.
2020-08-23 02:08:34 +05:30
Pranay Sashank
0a8d13d746 Make polymorphic semigroup ops wSerial, etc same fixity as <>.
- Update Changelog to reflect the change.
2020-08-22 13:03:25 +05:30
Harendra Kumar
944f57dcf4 Add some chunked file read APIs
* readChunks
* readChunksWithBufferOf
* readWithBufferOf
2020-08-21 02:54:21 +05:30
Harendra Kumar
83071813f5 Improve error handling in decodeUtf8 2020-08-21 02:32:42 +05:30
Harendra Kumar
1639cfde98 Use monadic action to get the initial state
In ReaderT/StateT evaluation.
2020-08-19 19:41:08 +05:30
Harendra Kumar
d162e6d7ce Rename, update docs of array casting routines 2020-08-15 20:26:23 +05:30
Harendra Kumar
cc072be34d Rename, update docs of array creation from ptr
Rename fromString to fromCString to avoid confusion. fromString sounds like it
creates an array of Char from a list of Char. CString is more precise
definition of a nul terminated byte string.

Also, add fromPtr to create an array from a pointer type.
2020-08-15 20:26:16 +05:30
adithyaov
ead1601148 Replace Data.Strict with Data.*.Strict
"Streamly.Internal.Data.Strict" is replaced by:
Streamly.Internal.Data.Tuple.Strict
Streamly.Internal.Data.Maybe.Strict
Streamly.Internal.Data.Either.Strict

This commit also has some formatting changes to imports.
2020-08-14 20:25:52 +05:30
Harendra Kumar
ecef82f2aa Remove redundant import 2020-08-14 18:37:22 +05:30
Harendra Kumar
6b856286fa Add word64host 2020-08-14 18:37:22 +05:30
Harendra Kumar
a98d897359 Add routines to cast the array into other types 2020-08-14 18:37:22 +05:30
Harendra Kumar
0f5404dfc6 Add Word16 LE, Word32 and Word64 parsers 2020-08-14 16:29:58 +05:30
Harendra Kumar
8a3828ad7d Add parsers for decoding binary encoded data 2020-08-14 16:29:58 +05:30
Harendra Kumar
cc7df3cc7b Add maybe and either parsers 2020-08-14 16:29:58 +05:30
adithyaov
2b4bd4c6ee Re-export fromAddr# and fromString# from Memory.Array 2020-08-14 16:28:40 +05:30
adithyaov
21a2045b8a Move fromAddr# and fromString# to the immutable Memory.Array module 2020-08-14 16:28:40 +05:30
pranaysashank
d93ac86607 Drop support for GHC 7.10.3. 2020-08-12 11:24:34 +05:30
Harendra Kumar
9851d18f9d Fix hlint hints 2020-08-02 16:26:46 +05:30
Harendra Kumar
cd7869d219 Fix a backtrack buffer bug in toParserK
We were leaving extraneous data in the backtrack buffer because of
wrongly using "splitAt" where we should have used "take". We should
leave the backtrack buffer empty in the Done case.
2020-08-02 16:26:46 +05:30
Harendra Kumar
ec97cec4d2 Fix the backtrack buffer management for fromParserK
This commit results in worse performance because now we are double
buffering once in ParserD and once in ParserK. This can potentially be
fixed but would require bigger changes to unify the backtracking buffer
management for ParserD and ParserK.
2020-08-02 16:26:46 +05:30
Harendra Kumar
8a37cd8b9d Remove the stream component from the Zipper
Earlier we had the whole input stream in the Zipper and when running
ParserK we could consume from the stream as we needed.  Now we drive
ParserK just like ParserD one element at a time in a loop. The stream
consumption now happens in this outer loop instead of inside parserK.

This makes the "parse" function in ParserK simpler and ParserD and
ParserK are more or less similarly driven.
2020-08-02 16:26:46 +05:30
Harendra Kumar
d80d5e0a3b Implement fromParserK
We need to pause and continue the continuations to be able to run the parser in
steps which is required by the ParserD representation.
2020-08-02 16:26:46 +05:30
adithyaov
4d0631a0c6 Add Data.Array.Prim.Pinned and Data.Array.Prim
Respect the new module structure for Internal files
2020-07-21 09:13:31 +05:30
adithyaov
12c672ef1d Split the current Array into Array and Mutable.Array
* Add unsafeFreezeWithShrink
* Cleanup + Reformat code + Respect hlint
2020-07-20 19:06:35 +05:30
Shruti Umat
26f9f9aac8 Add tests for groupsBy
Fix doc of groupsBy

Fix documentation of tests and helper functions
2020-07-18 15:51:48 +05:30
Harendra Kumar
b524d99d53 Add signatures for some unimplemented combinators 2020-07-18 04:12:01 +05:30
Harendra Kumar
9b511beeb5 Add skeleton for some unimplemented parsers 2020-07-17 21:29:44 +05:30
Harendra Kumar
c590e9105e Update documentation of sliceSepBy 2020-07-16 23:32:17 +05:30
Harendra Kumar
81339c8f8b Fix comments 2020-07-13 23:58:02 +05:30
pranaysashank
03f05ed340 Fix a bug in ParserK.yield. 2020-07-13 18:05:00 +05:30
Ahmed Zaheer Dadarkar
9d653d06d3 Updated type signature of concatMapWith to remove explicit forall.
- Do the same with `bindWith`, `concatMapBy`, `concatMapIterateWith`,
  `concatMapTreeWith`.
- `concatMapLoopWith`,`concatMapTreeYieldLeavesWith` are not updated
  in the same way as they necessarily need the combining function to be
  polymorphic.
- Update Changelog to reflect this change.
2020-07-13 18:05:00 +05:30
pranaysashank
f38b672e44 Add tests for take, takeEQ, takeGE with n <= 0.
- Delete `lookAheadFail` test because the test doesn't make sense
  i.e. It doesn't have to fail when the stream length exceeds n in `take
  n`.
2020-07-11 18:20:32 +05:30
pranaysashank
30823452a4 Fix take, takeEQ, takeGE, sliceSepByMax.
- `take`, `takeEQ`, `takeGE` now work when the count is <0.
- `sliceSepByMax` behaviour is now more in line with what the
  documentaton says in `Streamly.Internal.Data.Parser`.
2020-07-11 18:20:32 +05:30
Sanchayan Maity
1100c23999 Clean up hlint warnings
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2020-07-11 17:53:59 +05:30
pranaysashank
e0a95b59ca Add MonadFail instance for Parser. 2020-07-10 19:57:57 +05:30
Harendra Kumar
095513166d Enable TypeFamilies extension with NoMonoLocalBinds
MonoLocalBinds enabled by TypeFamilies causes performance regressions
see #567, however we can enable TypeFamilies without it.
2020-07-09 18:40:34 +05:30
Harendra Kumar
89b9e233ba Fix inspection tests 2020-07-09 17:40:27 +05:30
Harendra Kumar
287c3a3dc5 Make minor cosmetic review changes for #571 2020-07-07 14:17:44 +05:30
pranaysashank
202f674462 Change the signature of foldlM' to use a monadic seed.
- Also change usages of foldlM' in tests and benchmarks.
2020-07-07 14:17:44 +05:30
Harendra Kumar
a18f1b57b2 Add more details to the documentation of parallel 2020-07-06 16:47:24 +05:30
Shlok Datye
6cc0e92d76 Add unfold0 2020-07-03 15:57:33 +05:30
adithyaov
8178cf650b Minor haddock change to hide internal (XXX) comment 2020-07-02 18:13:11 +05:30
pranaysashank
bb12399558 Remove per file extensions from rest of the library modules. 2020-07-01 17:29:21 +05:30
Harendra Kumar
1367bd647d Disallow some language extensions from default use
* UndecidableInstances -- Don't want to use unless indicated
* TypeFamilies         -- Causes large regressions and improvements
* UnboxedTuples        -- interferes with (#.)
2020-07-01 17:29:21 +05:30
Pranay Sashank
6190f1bd02 Use default-extensions inplace of extensions on each file. 2020-07-01 17:29:16 +05:30
Harendra Kumar
68cfc3f9be Reduce usage of -Wno-orphans 2020-06-28 22:55:15 +05:30
adithyaov
70fb992171 Fix primitive version bounds for when primitive is >= 0.7.1
Fix duplicate NFData instance
2020-06-28 01:56:49 +05:30
Harendra Kumar
6bf8b4abd9 Rename the parser Step constructors
Yield => Partial
Skip => Continue
Stop => Done

The new names are hopefully more intuitive. They also decouple the names from
the corresponding stream constructors so that there is no confusion about
mixing the two intuitions.

fixes #559
2020-06-24 21:07:08 +05:30
Harendra Kumar
60d322812b Combine Yield and YieldB constructors
Yield 0: now means a partial result is available
Yield n: means a partial result is available, and we need to backtrack by n
elements.
2020-06-24 21:06:56 +05:30
Harendra Kumar
55d49bd50c Optimize Functor/Applicative/Monad etc for serial
Some of the benchmarks were order of magnitude off due to missing INLINE for
type class operations. Now, all of them are in reasonable limits. Benchmarks
affected for serial streams:

* Functor, Applicative, Monad, transformers

We need to do a similar exercise for other types of streams and for
folds/parsers as well.
2020-06-23 13:41:41 +05:30
Harendra Kumar
b4cef11d19 Add iterative benchmarks for Functor/transformers
* Also factor out the existing iteration utilities and use the same everywhere
2020-06-23 13:01:25 +05:30
Harendra Kumar
1cccb00101 Use foldrSShared instead of foldrS for Async
Because of not sharing the SVar foldrS performs poorly for Async streams and
has quadratic complexity.
2020-06-21 11:28:59 +05:30
Harendra Kumar
acf31cef50 Import from transformers instead of mtl
Just so that we know where all we are actually using mtl.
2020-06-20 18:56:03 +05:30
Sanchayan Maity
b5cf9dd9a7 Streamly: Internal: Data: Clean up hlint warnings
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2020-06-06 01:37:07 +05:30
Harendra Kumar
b90107f15b Fix build for older versions of GHC 2020-06-03 23:30:04 +05:30
Pranay Sashank
959fcc7eec Fix Parser.eqBy. 2020-06-02 19:23:22 +05:30
Pranay Sashank
12ca6eeba5 Fix sliceSepByMax. 2020-06-02 18:03:43 +05:30
Harendra Kumar
df6d8e0b04 Make changes to unfolds from stream
* Add fromStreamK
* fromStream: signature change, use fromStreamK as fromStreamD has very bad
  performance characterstics.
* Add INLINEs to fromStream
* Remove fromStream1 and fromStream2 as they can be expressed trivially in
  terms of fromStream and lmap.
2020-06-02 11:20:38 +05:30
Harendra Kumar
01fa925af3 rename mconcatTo to sconcat 2020-05-31 01:46:01 +05:30
Harendra Kumar
ef9a671c67 Create arrays from Addr# (unboxed string literals) 2020-05-29 23:48:34 +05:30
Harendra Kumar
3e22f1bae0 flush sessions when classifySessionsOf ends
Earlier the sessions that were incomplete and in the hash were dropped when the
stream ended.
2020-05-29 17:08:39 +05:30
Harendra Kumar
b52ed84a33 Make classifySessionsOf terminate
It was running forever as the timer stream never terminated.
2020-05-28 19:14:56 +05:30
Harendra Kumar
602539f613 Add/change some time/interspersing combinators
Add: intersperseSuffix_, delay, timeIndexed
Change the APIs: times, absTimes, relTimes, timestamped

The new APIs have a default clock granularity of 10 ms.
2020-05-28 16:26:59 +05:30
Harendra Kumar
e511962625 Fix conversion of MicroSecond64 and MilliSecond64 2020-05-28 10:07:41 +05:30
Harendra Kumar
7013f3a5e4 Fix delayPost, add more interspersing combinators
delayPost was actually behaving like delayPre, fixed it.
Added: trace_, intersperseM_, interspersePrefix_, delayPre
2020-05-27 19:26:26 +05:30
Harendra Kumar
7f9d4a4210 Add some time related combinators
add: times, relTimes, timestamped
unimplemented skeletons: durations, ticks, timeout

Changes to the original currentTime combinator: remove delay from the first
event, cap the granularity to 1 ms to guarantee reasonable cpu usage.
2020-05-27 12:21:54 +05:30
Pranay Sashank
9e6d245a3e Remove extraneous file Streamly.Examples 2020-05-18 10:48:45 +05:30
Ahmed Zaheer Dadarkar
64e8b3801a updated definition of parseK to use throwM instead of error 2020-05-16 14:30:56 +05:30
Harendra Kumar
df553b1d5b fix hlint warnings
and remove fixed files from .hlint.ignore
2020-05-15 10:18:59 +05:30
Sanchayan Maity
c9eff7e271 Cleanup hlint warnings
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2020-05-15 10:11:06 +05:30
Harendra Kumar
e84612f179 Add connect and connectFrom 2020-05-12 05:55:15 +05:30
Harendra Kumar
96aa91d2a4 Close the socket on exception
in "accept" and "connections"
otherwise it will be closed only on garbage collection.
2020-05-12 05:55:15 +05:30
Harendra Kumar
d0b558e521 close socket on exception (in connect) 2020-05-12 05:55:15 +05:30
Harendra Kumar
40d1e6423d Fix a bug in YieldB case 2020-05-11 21:25:24 +05:30
Harendra Kumar
2c9feb48ef Add YieldB (yield and backtrack) constructor
This fixes an issue in many/some/manyTill combinators.
2020-05-11 21:25:24 +05:30
Harendra Kumar
633c55eb31 rename splitParse/parseMany, concatParse/parseIterate 2020-05-11 21:18:09 +05:30
Harendra Kumar
1889b4eef6 update fold documentation 2020-05-11 21:17:32 +05:30
Harendra Kumar
684d2786eb Add concatParse to chain parsers on a stream
Add mconcatTo, update fold docs
Add fold docs/snippets using Monoids.
Add benchmark for sum using foldMap
Add concatParse benchmark
Add splitParseTill, update docs
2020-05-11 20:54:22 +05:30
Shruti_Umat
0911988b4e explain mapM, sequence functions 2020-05-04 12:06:31 +05:30
Shruti_Umat
3957ceed99 fix output explanation of wAsyncly
typo fix in StreamD coding style
2020-05-04 12:06:31 +05:30
Harendra Kumar
7af52d33b7 remove duplicate code 2020-04-24 04:29:12 +05:30
Harendra Kumar
9d4e6a2036 Fix exception handling
Check for ParseError exception instead of SomeException
Fix some comments.
2020-04-24 04:15:27 +05:30
Harendra Kumar
899cab5cd4 Make License Identifier SPDX compliant 2020-04-24 03:57:46 +05:30
Harendra Kumar
d7866f732d INLINE some/many implement *>/<*
Benchmarks that improved:

ParserK(cpuTime)
Benchmark                   default(0)(μs) default(1) - default(0)(%)
--------------------------- -------------- --------------------------
o-n-heap/parserK/sequenceA_       11183.17                     -32.75
o-n-heap/parserK/manyAlt          41514.00                     -40.82
o-n-heap/parserK/someAlt          68026.25                     -61.77
2020-04-24 02:59:40 +05:30
Harendra Kumar
dde9041833 Use parserK by default and rewrite to ParserD 2020-04-24 00:30:01 +05:30
Harendra Kumar
a03e2872a6 rename Parser module to ParserD
The top level module "Parser" will be using both ParserK and ParserD.
2020-04-24 00:30:01 +05:30
Harendra Kumar
12fef4390f Add a CPS style parser implementation
CPS performs much better for parsing operations like "sequence" and
"choice" on large containers. Given that applicative "sequence" does
not scale, I guess the Monad instance as well won't scale for direct
implementation.
2020-04-24 00:30:01 +05:30
Pranay Sashank
828a564781 Add GHC 8.10.1 build to CI.
- Disable inspection testing for `fromStreamVar`.
- Fix overlapping pattern matches warning in test/Main.hs.
2020-04-22 14:32:30 +05:30