Compare commits

...
Author SHA1 Message Date
Taimoor Zaeem a46ac79ea8 nix: exclude protolude from style checks
Currently, our vendored protolude has many failing checks for
style, lint and hsie. Temporarily excluding it. We should
reinstate these checks later.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-04-30 20:33:32 +05:00
Taimoor Zaeem a2faa667f3 chore: build postgrest with vendored protolude
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-04-30 19:56:33 +05:00
Taimoor Zaeem 366502729d chore: remove unneeded files and directories from src/protolude
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-04-30 15:38:39 +05:00
Taimoor Zaeem 7c8f79d86f chore: add .git-blame-ignore-revs
Ignore blame for commit that moved protolude files under src/protolude.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-04-30 14:24:21 +05:00
Taimoor Zaeem 827121b72f chore: merge protolude as subdirectory src/protolude 2026-04-30 14:17:07 +05:00
Taimoor Zaeem d4949c633e chore: move protolude files to src/protolude
Later we merge the src/protolude directory with src/PostgREST.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-04-30 14:16:23 +05:00
Adam WespiserandGitHub a4880f0372 bump version 0.3.5 (#152) 2025-05-15 22:15:12 -04:00
daad7c317d Support GHC 9.12 (#151)
* Test 9.6 and 9.8 in CI

* Support GHC 9.10

* Support GHC 9.12

---------

Co-authored-by: Tom Ellis <tom-git@jaguarpaw.co.uk>
2025-05-15 22:13:14 -04:00
Adam WespiserandGitHub 20f2e894c9 0.3.4 release (#148) 2024-02-04 22:23:39 -05:00
Erik de Castro LopoandGitHub 5a98f0c26d Make it build with ghc 9.8 (update deps only) (#146) 2024-02-04 22:19:13 -05:00
4680e62d7b ghc 9.4 PR (w/ Cabal improvement) (#142)
* Release 0.3.3, with support for GHC 9.4

- allow base-4.18 (GHC 9.4)
- allow ghc-prim 0.10
- allow bytestring 0.11.4
- test against GHC 9.4.4

Further CI tweaks:

- cabal: update GHC versions to the latest releases of the respective major version
- cabal: remove non-latest minor versions
- stack: add lts-20 (GHC 9.2.5)
- stack: bring the list of GHC versions up to date

* Update Cabal CI

---------

Co-authored-by: Robert Vollmert <rob@vllmrt.net>
2023-02-15 21:41:08 -05:00
Christoph SchiesslandGitHub cd83ebec00 Updates README to correctly list all supported stack LTS versions (#140)
* Updates README to correctly list all supported stack LTS versions

* Updates README to include LTS 19.14 and higher
2022-08-27 19:59:13 -04:00
Adam WespiserandGitHub e40b7351ec 0.3.2 Release (#127) (#138) 2022-06-12 13:46:49 -04:00
Adam WespiserandGitHub 3e249724fd 0.3.1 Release (#133) 2022-03-12 21:42:32 -05:00
Adam WespiserandGitHub 1b453b6064 Re-export isInfixOf, isSuffixOf from Data.List, Issue #119 (#135) 2022-03-06 11:20:07 -05:00
Adam WespiserandGitHub 3611929f01 Fix Hackage Formatting (#134) 2022-02-28 23:34:03 -05:00
f8cf1375d5 Add HasCallStack to unsafe* functions (#129)
Co-authored-by: Adam Wespiser <adamwespiser@gmail.com>
2022-02-21 14:38:19 -05:00
Adam WespiserandGitHub ee4d94feab Support ghc-9.0.1 (#131) 2022-02-20 20:19:01 -05:00
4e11d80eb7 Allow transformers-compat 0.7 (#125)
Tested to build fine.

Co-authored-by: Adam Wespiser <adamwespiser@gmail.com>
2021-12-01 00:33:59 -05:00
84d228a3b5 gcdInt' and gcdWord' are defined only with integer-gmp (#123)
Co-authored-by: Adam Wespiser <adam.wespiser@simspace.com>
2021-11-20 16:03:29 -05:00
Adam WespiserandGitHub f162c21d1b Update github actions, add new lts to tests (#124) 2021-11-17 09:17:40 -05:00
Stephen DiehlandGitHub e613ed4dd2 Merge pull request #120 from martijnbastiaan/readMaybeEither
Banish `String` on `readMaybe` and `readEither`
2021-01-04 18:30:54 +00:00
Martijn Bastiaan 36ce510547 Banish String on readMaybe and readEither 2020-12-05 20:06:45 +01:00
sdiehl 22e2cecaee 8.10.1 support to CI 2020-07-15 14:40:41 +01:00
Stephen DiehlandGitHub 0a92513108 Merge pull request #118 from protolude/strconv
Migrate show to use Conv.StringConv
2020-05-04 16:08:54 +01:00
sdiehl 9309ca3107 Migrate show to use Conv.StringConv 2020-04-25 11:58:41 +01:00
sdiehl 8ff8b7ae49 Update bounds in README 2020-03-27 12:40:31 +00:00
sdiehl 68f668951f Bump base & ghc-prim bounds for 8.10.1 2020-03-27 09:12:59 +00:00
sdiehl 7e081500f3 Supports lts 15.x 2020-03-21 13:20:57 +00:00
Stephen DiehlandGitHub 2666f1e830 0.3 Release (#115)
* Add total ConvertText alternative to Conv

* Explain ConvertText's meaning

* Rename convertText to toS for compatibility

* 0.3.0 Refactor (#111)

* Begin work on 0.3 refactor

* Remove old docs folder

* Fix dodgy exports

* 4.8 constraint for null and length

* Guards for Semigroup export for base<4.9

* Fix Data.Bits exports

* Guards for typeable exports

* Remove unused pragmas

* Update hlint.yaml

* Use liftM because of pre-AMP quirkk

* Data.Char exports

* Rework Exception exports

* Fix bounds

* Adding Monad.Fail shim

* Fix displayException export

* Explicit GHC.Prim import for ancient ghc

* Explicit raise# for base-4.7

* Flush legacy testing infrastructure

* Update git location

* Update README

* Add Partial module

* Add concurrency exports

* Explicit GHC.Float exports

* Bounds for threadWaitReadSTM, threadWaitWriteSTM, forkOSWithUnmask

* Fix for weird undocumented underflowError weirdness

* forkOSWithUnask for base>4.8

* Fix GHC.Real exports pre base-4.7

* Fix withMVarMasked for base-4.7

* Update nix derivation

* Update derivation

* Update derivation

* Explicit functor exports

* <$ export

* Overwrite binary

* Fix some missing exports

* Update Changelog

* Minor export fixes base<4.9

* Explicit exports

* Export handler

* Generate export lists for multiple versions (#114)

* Generate export lists for #112

* Make export lists format OccName uniformly

* Make compile on ancient GHC

* Use Foldable.concat

* Hacks to make ghc-7.6 API happy

* liftIO shim

* Fix sortOn warning

* Update ChangeLog

* Update base bounds

* Export conventions

* Update Haddocks

* Document GHC magic
2020-01-24 11:06:09 +00:00
sdiehl 03f73d8cde Name nix workflow 2020-01-04 23:12:42 +00:00
sdiehl af6cabe185 Added Nix CI 2020-01-04 23:02:48 +00:00
sdiehl e7a8e99f3f Fix install path for cabal. 2020-01-04 19:07:36 +00:00
sdiehl 0fda50b372 Cache cabal builds 2020-01-04 19:04:42 +00:00
sdiehl 76ad00a018 Run cabal update. 2020-01-04 18:49:38 +00:00
sdiehl e9da6f635e Add HLint action. 2020-01-04 18:48:01 +00:00
sdiehl e02ac85388 Fix Stack build names 2020-01-04 17:57:19 +00:00
sdiehl 3dd5152aba Build Stack CI on PRs 2020-01-04 17:55:55 +00:00
sdiehl 0ea2c5146a Seperate Stack and Cabal scripts 2020-01-04 17:54:59 +00:00
sdiehl 612726f87e Fix YAML for workflow 2020-01-04 17:29:28 +00:00
sdiehl 4d1f8dc86b Add Stack CI script 2020-01-04 17:28:27 +00:00
sdiehl 1277dfd941 Test all supported GHC versions 2020-01-04 17:19:50 +00:00
sdiehl a645953330 Fix GHC version 2020-01-04 16:26:15 +00:00
sdiehl fa0f1dc0fa Build on pull requeests 2020-01-04 16:23:51 +00:00
sdiehl 5e1b1ea982 Update build status badges 2020-01-04 16:18:33 +00:00
sdiehl f39de46d9f Don't install 2020-01-04 15:58:57 +00:00
sdiehl 95ccde5a2d Use cabal-new-build 2020-01-04 15:54:10 +00:00
Stephen DiehlandGitHub b8fa8a0729 Create haskell.yml 2020-01-04 15:39:54 +00:00
sdiehl ae9dd77749 Support all lts-14 resolvers 2019-11-22 08:06:09 +00:00
sdiehl 66d6d3506f Add lockfiles for resolvers 2019-11-02 18:46:01 +00:00
Stephen Diehl 357c0fdbed Update readme for 8.8.1 support 2019-10-10 11:49:44 +01:00
Stephen Diehl a93c7e6343 Support lts-14.* and GHC 8.8.1 2019-10-10 10:37:27 +01:00
Pi3randStephen Diehl 65c61c1d63 Fix #107: support ghc-8.8 (#108)
* Fix #107: support ghc-8.8

* Add travis build for ghc 8.8.1
2019-10-08 11:43:18 +02:00
Ary BorenszweigandStephen Diehl 2770a143d0 Update link to exported functions (#106)
The file `Symbols.md` doesn't exist anymore in the repository.

In the meantime Haddock fixed a long standing bug that allows Hackage to display all exported symbols now so we can now link to it.
2019-07-23 06:28:56 +01:00
Stephen Diehl c649da1944 Update LTS 13 resolvers 2019-06-20 11:29:01 +01:00
Stephen Diehl 9d450cd9ff Fixity declaration for <<*>>, fixes #103 2019-04-15 10:04:25 +01:00
Thomas ScholtesandStephen Diehl 7491e92f2a 'Protolude.Error.error' produces call stacks (#102)
Calling `Protolude.Error.error` will now include the call stack in the
`ErrorCall` that is raised. Before this was not the case because we used
the wrong implicit variable.
2019-04-10 15:38:14 +01:00
VilemandStephen Diehl 3add75ac4d Add lines, words, unlines, unwords (#101)
These operations (over `String` instead of `Text`) are part of Prelude.
2019-04-06 14:30:53 +01:00
Stephen Diehl 278b6c59e6 Bump licenses for 2019 2019-04-02 15:02:33 +01:00
Stephen Diehl ff8ed02b81 Support LTS-13.x resolvers 2019-03-28 16:58:36 +00:00
Alex PankoffandStephen Diehl cfa026a068 Remove note about error function from README (#100) 2019-03-18 10:38:04 +00:00
Greg SteuckandStephen Diehl a69d4ec1dd Typo (#98) 2019-01-24 13:30:54 +00:00
Stephen Diehl b45c3e6e73 New resolvers 2018-12-06 16:41:46 +00:00
Stephen Diehl b1f7eb5899 All LTS 1.2x resolvers 2018-11-21 12:39:16 +00:00
Stephen Diehl 8bf457d6b7 Remove symbols.md file 2018-11-08 14:12:58 +00:00
Stephen Diehl 8c3c133342 Fix for TypeInType before 8.6 2018-10-02 10:37:58 +01:00
Stephen Diehl ced5fd366e Minor version bump 2018-10-02 10:30:43 +01:00
Andre Van Der MerweandStephen Diehl 8c88bc7d64 GHC 8.6.1 support (#95)
* GHC 8.6.1 support

 - Bounds changes for base, containers and stm
 - stack lts 12.* tests
 - works with stack 8.6.1 nightly
    stack build --resolver nightly --haddock --test --bench --no-run-benchmarks
 - works with cabal new-build

* GHCVER-8.6.1
2018-10-01 20:20:06 +01:00
Stephen DiehlandGitHub 5024f3fef9 Add support for GHC 8.6 (#94)
* Add support for GHC 8.6

* Fix STM version bounds on pragma
2018-10-01 17:35:27 +01:00
Stephen Diehl 1b1f82b749 Export groupBy, fixes #91 2018-08-03 13:14:31 +01:00
Tony DayandStephen Diehl f75c99bda8 Some fixes for ghc-8.6 (#93) 2018-07-29 08:04:03 +01:00
Stephen Diehl 7c0e45c844 Support LTS-11 family of resolvers for testing 2018-06-15 10:29:42 +01:00
David HewsonandStephen Diehl ace10b648c <&> docs fix (#88)
`@<&>@`  appears as `&` on the page, which seems wrong
2018-06-10 09:20:15 +01:00
Michael SnoymanandStephen Diehl 8a8eb8c728 Add extra-source-files (#87) 2018-05-28 11:21:12 +01:00
Stephen Diehl 3bd6f07f9b Remove error function from symbol list 2018-05-08 09:39:55 +01:00
Stephen Diehl d6a710e40e Expose fromLeft and fromRight 2018-04-16 14:42:53 +01:00
Stephen Diehl 675837c232 Fix Data.Functor export list 2018-03-26 13:05:57 +01:00
Stephen Diehl 243a309bc1 On Base 4.11 use the provided <&>, fixes #53 2018-03-26 11:33:46 +01:00
Stephen Diehl 60943c0596 Drop safe dependency 2018-03-26 11:18:42 +01:00
Stephen DiehlandGitHub a8d1363581 Rework Safe Module (#83)
* Initial fork on minimal safe submodule

* Add new Safe module

Signed-off-by: Stephen Diehl <stephen.m.diehl@gmail.com>

* Refactor Safe module
2018-03-22 13:31:29 +00:00
Tony DayandStephen Diehl 57912017fe Bump upper bound for base & ghc84 bumps (#82) 2018-03-19 10:11:35 +00:00
Stephen Diehl f542a361a4 Bump upper bound of protolude transformers-compat 2018-03-01 14:21:01 +00:00
venandStephen Diehl 70fca4ab9c Fix symbols.md rendering (#80) 2018-02-08 13:55:00 +00:00
Stephen Diehl 81dcc985fc Bump minor version 2018-02-05 14:52:51 +00:00
Stephen Diehl 9a61a70a19 Looser lower-bound on Data.Kind export for GHC 8.0.x for #79 2018-02-05 14:33:12 +00:00
Stephen Diehl 8c9d0f4666 Bump upper bound for async 2.2.1 2018-02-05 10:20:40 +00:00
Stephen Diehl fd7fc5fb8e Update changelog 2018-01-12 11:11:09 +00:00
Stephen Diehl 65a0518008 Update changelog 2018-01-08 17:05:20 +00:00
Stephen Diehl 7f29497262 Minor version bump 2018-01-08 16:29:18 +00:00
Stephen Diehl 6d2a32f0dd Add transformers-compat for ancients MTL/Transformer versions 2018-01-08 16:28:14 +00:00
Stephen Diehl 74f185e22f Update stack build scripts 2018-01-07 13:03:56 +00:00
Stephen Diehl 8db43f6bff Bump upper bounds for safe 2018-01-07 09:04:20 +00:00
Ian JeffriesandStephen Diehl 4694fee383 Fix spelling. (#77) 2017-12-27 10:29:52 +00:00
Moritz KieferandStephen Diehl 2d8d1f3357 Reexport scanl' (#74)
This is useful for the same reasons that foldl' is useful
2017-12-18 19:03:45 +00:00
ProfpatschandStephen Diehl d462550f07 add mapExcept(T) and withExcept(T) (#76)
Since we already export functions like `withState` and the names don’t clash
with anything, we export these transformation functions as well.
Every function from Control.Monad.Except is now exported, the user doesn’t need
to import it for common error handling tasks.
2017-12-18 13:04:43 +00:00
Pi3randStephen Diehl c9a2d176d1 Add throwE & catchE (#73)
* Add throwE & catchE

My understanding is that `throwError` & `catchError` are deprecated (maybe we should remove them?)

* Update Protolude.hs

* Update Protolude.hs
2017-11-30 13:31:19 +00:00
TimothyandStephen Diehl 8eb1633dd8 Add warnings for partial functions (#70) 2017-10-24 14:27:18 +01:00
Stephen Diehl 2c44add128 Merge branch '4e6-ghc-822rc1' 2017-10-05 13:20:58 +01:00
Stephen Diehl 62393669dc update the travis file for 8.2.2 2017-10-05 13:20:47 +01:00
Dmitry Bushev abf2fbc369 Support GHC-8.2.2
When compiling with GHC 8.2.2-rc1:

```
src/Error.hs:25:17: error:
    Variable ‘r’ used as both a kind and a type
    Did you intend to use TypeInType?
   |
25 | error :: forall (r :: RuntimeRep) . forall (a :: TYPE r) . HasCallStack => Text -> a
   |                 ^^^^^^^^^^^^^^^^^
```

`TypeInType` should be enabled, see GHC issue 14121
https://ghc.haskell.org/trac/ghc/ticket/14121
2017-10-05 14:29:35 +03:00
Pi3randStephen Diehl 72085dec92 Add putErrLn to match putStrLn (#67)
* Add `putErrLn` to match `putStrLn`

Fix #66

* Add putErr for the most usual inference case

* Rename `putErr` into `putErrText`

In order to allow further specializations in the future if necessary.
2017-10-04 08:53:19 +01:00
Tony DayandStephen Diehl 923194c5b2 ghc-8.2 HasField, Type & * (#65) 2017-09-15 13:43:41 +01:00
Stephen Diehl 5964f545cf fix bifunctor import for base 4.8 2017-08-22 19:55:51 +01:00
Stephen DiehlandGitHub 8387808d6e Fix README with relative links 2017-08-22 19:26:57 +01:00
Stephen Diehl 2cd38fcb03 remove hidden modules 2017-08-22 19:25:27 +01:00
Stephen Diehl 9533e739ff use hierarchical namespace for all modules 2017-08-22 19:23:46 +01:00
Stephen Diehl 6c9b60700e expose debug module 2017-08-17 10:05:02 +01:00
Michael BurgeandStephen Diehl 7908bad846 Debug trace functions now output to stderr (#62) 2017-08-05 14:22:21 +01:00
Tony DayandStephen Diehl bfc7306ed7 Added RealFloat (#61) 2017-07-28 13:06:13 +01:00
Stephen Diehl 63d561de0c bump docs upper bounds for base for GHC 8.2 2017-07-25 13:03:07 +01:00
Pi3randStephen Diehl 3175e6c1eb Update protolude.cabal (#60)
Increase upperbound of safe.

This allows the master git version to build using the latest stackage`lts-8.23`
2017-07-24 17:54:42 +01:00
Stephen Diehl eccb07f726 polymorphic return type for die 2017-07-17 16:33:12 +01:00
Stephen Diehl 459d82012b Merge branch 'cocreature-ghc-8.2' 2017-07-05 14:42:40 +01:00
Stephen Diehl 5717b9a42c description and synopsis lines for latest cabal 2017-07-05 14:42:30 +01:00
Moritz Kiefer d7bc982142 Bump base upper bound for GHC 8.2 2017-07-05 08:02:57 +02:00
ProfpatschandStephen Diehl d30d6a39ab add (<&>), fixes issue #53 (#56) 2017-06-14 07:33:23 +02:00
Stephen DiehlandGitHub 46220a1a4a Added HasCallStack constraint for trace functions (#55)
* added HasCallStack constraint for trace functions, for issue #39

* unpack string on 7.6
2017-05-31 10:13:08 +01:00
Stephen Diehl c2570f77e6 better named either helper function, fixes #54 2017-05-20 19:03:29 +01:00
Stephen Diehl b4d33c3c96 include until from GHC.Base 2017-05-06 13:39:48 +01:00
Stephen Diehl 8c676e28de expose all pointers 2017-05-03 10:48:48 +01:00
Stephen Diehl a2c66fc236 update changelog 2017-05-03 10:44:31 +01:00
Stephen Diehl 456a063e35 update changelog 2017-05-03 10:37:39 +01:00
Stephen Diehl 269c81b1d2 make die take Text argument, fixes #51 2017-05-03 10:29:55 +01:00
Moritz KieferandStephen Diehl 307ecd7d6a Add hPutStr and hPutStrLn (#52) 2017-05-03 10:01:19 +01:00
Stephen Diehl 41710698ee note about unzip exposure 2017-03-24 10:14:49 +00:00
Stephen Diehl 8b9197ff01 ghc 8.0.2 supported 2017-03-17 13:09:12 +00:00
Stephen Diehl 89d4a49c7e export constructors for GHC.Generics sum/product 2017-03-17 13:07:24 +00:00
Stephen Diehl ca5087201b adds unzip, fixes issue #45 2017-03-12 15:54:30 +00:00
Stephen Diehl 8ad2522cda add strictness functions documentation 2017-03-11 09:59:58 +00:00
Stephen Diehl 5866877d3f reformat base exports of typelits 2017-03-11 09:54:30 +00:00
Pi3randStephen Diehl 92905843a4 Update CHANGES (#42) 2017-03-09 22:48:04 +00:00
Pi3randStephen Diehl a324e26d54 Update safe upper bound for ghc >=7.8.0 (#43) 2017-03-09 22:47:29 +00:00
Pi3randStephen Diehl 79bbc2de6e Add short-circuiting version of '<||>' and '<&&>' (#41) 2017-03-05 14:05:05 +00:00
Pi3randStephen Diehl 721374d42c Add (<&&>),(<||>) (#40) 2017-02-28 14:59:05 +00:00
Stephen Diehl 0ab61665ee liftIO1 and liftIO2 for issue #38 2017-02-11 14:52:56 +00:00
Stephen Diehl 6ac3e01da0 fix safe bounds for breakage on GHC 7.0.1 build 2017-02-11 13:47:31 +00:00
Alexander KjeldaasandStephen Diehl fd3d667cde Typo? (#37) 2017-02-07 14:12:47 +00:00
Stephen Diehl f9b5a5cbf4 export Floating 2017-01-21 14:53:04 +00:00
Carl BaatzandStephen Diehl 12cd9fae46 String is not exported. (#36) 2017-01-13 07:26:34 +00:00
Stephen Diehl 531a07ccfc test all stack resolvers 2017-01-03 15:50:05 +00:00
Stephen Diehl e72d06929e Hold off on exporting TypeInType machinery 2017-01-03 14:13:25 +00:00
Stephen Diehl 39d56792ce Fix up PBase exports, expose Generics metadata 2017-01-02 13:28:21 +00:00
Stephen Diehl 3994639b2b Mask supporting modules 2017-01-02 12:06:37 +00:00
Stephen Diehl 03f5746e96 Rework implicit exports to be explicit. 2017-01-02 11:46:11 +00:00
Stephen Diehl 070ac54067 Fix byteswap functions under GHC 7.6 2017-01-02 10:59:05 +00:00
Stephen Diehl e452604224 Fix Void and Proxy under GHC 7.6 2017-01-02 10:53:01 +00:00
Stephen Diehl e836d3f690 stack test harness 2017-01-02 10:45:43 +00:00
Ian JeffriesandStephen Diehl 51fdf38c71 Rename msg to fatalErrorMessage. (#34)
This is to free up `msg` as a variable name.
2017-01-01 18:45:08 -05:00
Stephen Diehl d0e81532af Use Data.Function (&) if base>4.8, fixes #33 2017-01-01 23:43:43 +00:00
Stephen Diehl 4a2ea2735b Merge branch 'docs'
Conflicts:
	CHANGES.md
2017-01-01 20:24:57 +00:00
Stephen Diehl 6d3940b4e5 new difflog 2017-01-01 20:24:32 +00:00
Stephen Diehl 254dafcb12 basic examples 2016-12-29 19:46:57 +00:00
Stephen Diehl 33e412b59b bump license 2016-12-26 17:49:43 +00:00
Stephen Diehl 5ce97cd0e9 expand list processing functions 2016-12-15 15:38:15 +00:00
Stephen Diehl 1140df0f91 stub out rest of toc 2016-12-15 15:06:15 +00:00
Stephen Diehl ed6fa9c8ea refine monaderror section 2016-12-14 17:16:20 +00:00
Stephen Diehl 1f2ed3e4cb fix lower bounds 2016-12-13 12:31:47 +00:00
Stephen Diehl cc0565112f monoid and fold rearranging 2016-12-13 09:14:39 +00:00
Stephen Diehl 0fb7730b0c expand semigroup 2016-12-12 16:30:52 +00:00
Stephen Diehl d6d1004070 monoid module 2016-12-12 16:21:49 +00:00
Stephen Diehl c7eeb5349e fix exports for functor module 2016-12-12 16:10:49 +00:00
Stephen Diehl 257a38f68f functor module 2016-12-12 13:09:18 +00:00
Stephen Diehl 66958def93 export encoding error handlers 2016-12-12 11:14:42 +00:00
Stephen Diehl c692eb03fb only export byteswap functions for ghc >7.6 2016-12-12 11:04:52 +00:00
Stephen Diehl a33669ca6d maybe functions 2016-12-12 11:03:34 +00:00
Stephen Diehl 6cb17bb94b utility functions 2016-12-10 16:01:47 +00:00
Stephen Diehl 00c2fce11a console functions 2016-12-10 14:51:33 +00:00
Stephen Diehl 8995aa71f3 bits and files 2016-12-10 13:28:32 +00:00
Stephen Diehl b32c80d0bb basic hierarchy in place 2016-12-10 12:46:48 +00:00
Stephen Diehl c28fa6b00c debug module 2016-12-08 13:12:42 +00:00
Stephen Diehl e041d6de8a added makefile 2016-12-08 12:23:56 +00:00
Stephen Diehl 7cdf6f1cc8 markdown source processor 2016-12-08 12:23:15 +00:00
Stephen Diehl fb6a942954 export generic list functions 2016-12-08 09:55:27 +00:00
Stephen Diehl ca74e2901d document structure 2016-12-08 09:47:06 +00:00
Stephen Diehl 60ca33fecb begin conversion to rst 2016-12-08 09:36:00 +00:00
Stephen Diehl fb6f00b90b clearer directions 2016-12-08 09:03:22 +00:00
Stephen Diehl dac4888f61 ignore ghc 8.0 only pragma 2016-12-06 13:57:48 +00:00
Stephen Diehl 50faedad80 added ghc 8.0.1 test 2016-12-06 09:39:23 +00:00
Stephen Diehl d5db73dbbf conditional safe version bounds for ghc 2016-12-06 09:06:47 +00:00
Stephen Diehl 6da0d42e8d updated changelog 2016-12-04 08:46:11 +00:00
Stephen Diehl 7060f55fdf export typelits symbols from base 2016-12-03 14:31:42 +00:00
Stephen Diehl 2b729aaadc Type level literals 2016-12-03 14:17:49 +00:00
Stephen Diehl fa482cfd46 bump version to 0.1.11 2016-11-15 16:18:43 +00:00
Stephen Diehl 3972d847e6 constrain safe upper bound for backwards compat with ghc 7.6 2016-11-15 15:14:16 +00:00
Stephen Diehl 82e0b04e4d use default monoid (<>) instead of semigroup 2016-11-15 14:57:16 +00:00
Stephen Diehl 7560af0955 relax lower async bound 2016-11-08 01:40:20 +00:00
Stephen Diehl 5b6bc27cbe constrainted bytestring print functions 2016-10-28 19:04:58 +01:00
Stephen Diehl aeacdd9630 include hashable 2016-10-28 16:41:28 +01:00
Stephen Diehl 250cfe2b7f version bump 2016-10-27 10:12:29 +01:00
Stephen Diehl c43a282322 Merge branch 'master' of github.com:sdiehl/protolude 2016-10-27 10:07:23 +01:00
Stephen Diehl d090411207 bump version 2016-10-27 10:05:52 +01:00
Stephen DiehlandGitHub 077198f1a5 Merge pull request #27 from cocreature/fixproduct
Fix product implementation
2016-10-18 15:59:15 +01:00
Moritz Kiefer bccd31e327 Fix product implementation 2016-10-18 15:13:01 +02:00
Stephen Diehl cf2fb7cd3a Note about strictness 2016-10-16 20:13:13 +01:00
Stephen DiehlandGitHub f95489b8f2 Merge pull request #26 from cocreature/sumproduct
Export strict versions of sum and product
2016-10-16 20:11:59 +01:00
Moritz Kiefer 961f71b971 Export strict versions of sum and product 2016-10-14 22:06:44 +02:00
Stephen Diehl 547aca5af4 fix nested functor composition 2016-10-14 17:21:57 +01:00
Stephen Diehl 860f74b3c2 Use explicit 'bool' import. 2016-10-14 14:06:57 +01:00
Stephen Diehl a86046b654 guarded and guardedA added to root. 2016-10-14 11:03:37 +01:00
Stephen Diehl c061df8f06 Applicative combinators. 2016-10-14 10:56:37 +01:00
Stephen Diehl a2e97dc936 Update FAQ. 2016-10-12 11:05:39 +01:00
Stephen Diehl e3e2857424 Changelog for 0.1.8. 2016-10-10 12:50:31 +01:00
Stephen Diehl 4f96a523da AMP fallout compatability fix. 2016-10-10 12:36:09 +01:00
Stephen Diehl 9e4f374811 Bump version. 2016-10-10 11:15:12 +01:00
Stephen Diehl 7a0e274b20 note and hush for #22 2016-10-10 11:13:26 +01:00
Stephen Diehl 2010cec78e Mask yield, fixes #23 2016-10-10 11:05:40 +01:00
Stephen Diehl 0346b366ee Remove Handler export, fixes #25. 2016-10-10 11:02:24 +01:00
Stephen Diehl ee06770742 `pass` function, fixes #25 . 2016-10-10 11:00:42 +01:00
Stephen Diehl a678ca3b60 Remove head test from travis. 2016-09-14 16:33:02 +01:00
Stephen Diehl 36b56ad3a2 for function for #19 2016-09-14 09:47:47 +01:00
Stephen Diehl e14e1e3613 Change log for 0.1.7. 2016-08-15 08:43:55 -04:00
Stephen Diehl d17fc9aab3 traceShow and traceShowId for #16 2016-08-13 16:14:15 -04:00
Stephen Diehl 5bf3b7f812 Full outline. 2016-07-29 12:28:29 -04:00
Stephen Diehl 5de8f47138 Stubs. 2016-07-29 12:07:32 -04:00
Stephen Diehl 4437583e3f Fix links. 2016-07-29 11:36:38 -04:00
Stephen Diehl 76f3f9f17c monad docs 2016-07-29 11:33:32 -04:00
Stephen Diehl 1cb0630529 New symbol documentation. 2016-07-21 14:49:09 -04:00
Stephen Diehl 7aa8b6646e Expose `state and `reader` functions. 2016-07-05 07:22:46 -04:00
Stephen Diehl 245dd5190e Explicitly lift throwIO and throwTo. 2016-07-02 20:11:20 -04:00
Stephen Diehl 2f619f3ebd Link to pretty printer library. 2016-07-02 17:57:44 -04:00
Stephen Diehl b658b4c8ef Note explicit String types. 2016-07-02 17:32:11 -04:00
Stephen Diehl b621258ce7 Better example text for panic. 2016-07-02 17:31:00 -04:00
Stephen Diehl 827c0ef87b Formatting for FAQ. 2016-07-02 17:27:40 -04:00
Stephen Diehl 6b6f8967ac Note about exception handling. 2016-07-02 14:00:26 -04:00
Stephen Diehl 21be7f2908 Fix 0.1.6 changelog. 2016-07-02 13:50:31 -04:00
Stephen Diehl f0fd11791c Add unsnoc function. 2016-07-01 11:25:10 -04:00
Stephen Diehl f6586ba8b4 Change safety language flags. 2016-06-30 23:02:39 -04:00
Stephen Diehl 63d5ed625d Encoding functions in scope by default. 2016-06-30 22:56:00 -04:00
Stephen Diehl c2ca1677c8 Control.Exception as qualified import. 2016-06-30 18:49:28 -04:00
Stephen Diehl b8479ebcb5 Move throw to Unsafe exports. 2016-06-30 18:48:55 -04:00
Stephen Diehl 89fdc587e0 Single SrcLoc export. 2016-06-30 18:28:21 -04:00
Stephen Diehl cf1fa981ef Remove showCallStack. 2016-06-30 18:14:30 -04:00
Stephen Diehl cef28ed3a0 Remove throw and assert exports. 2016-06-30 17:59:09 -04:00
Stephen Diehl 205643ea14 Callstack for GHC 8.x. 2016-06-30 17:45:39 -04:00
Stephen Diehl fa58c5452a Added changelog. 2016-06-30 11:14:47 -04:00
Stephen Diehl 22c0e743f9 Added changelog. 2016-06-30 11:09:58 -04:00
Stephen Diehl f4178f0472 FAQ section. 2016-06-30 11:04:51 -04:00
Stephen Diehl e2b886bb64 MOre specializers. 2016-06-30 10:59:15 -04:00
Stephen Diehl a7bc40452f Fix up bound documentation. 2016-06-30 10:49:13 -04:00
Stephen Diehl 0aa40b8b21 Don't support alternative Base. 2016-06-30 10:41:55 -04:00
Stephen Diehl dce9f0c9d5 github table formatting 2016-06-17 09:51:34 -04:00
Stephen Diehl b6805513f6 Dependencies note. 2016-06-17 09:49:49 -04:00
Stephen Diehl e0cace8a4d Symbols list. 2016-06-11 16:19:03 -04:00
Stephen Diehl 8d794da86c Remove printf. 2016-06-09 21:18:10 -04:00
Stephen Diehl 78b16ebcfa IO handle functions. 2016-06-09 20:18:55 -04:00
Stephen Diehl 173b86de45 Read actions for Strict text in scope by default. 2016-06-08 23:02:57 -04:00
Stephen Diehl 30d0bbca93 Debug functions to use Text. 2016-06-08 20:08:21 -04:00
Stephen Diehl a9c8d300a5 Remove string-conv dependency. 2016-06-08 19:47:08 -04:00
Stephen Diehl 6edc320b69 DeriveTyepable pragma. 2016-06-08 19:45:33 -04:00
Stephen Diehl 6ae19be4b7 Explicit Typeable for older GHC. 2016-06-08 19:38:45 -04:00
Stephen Diehl 6df421ad72 Panic module. 2016-06-08 19:32:03 -04:00
Stephen Diehl 1e690a9e78 bump version 2016-06-08 19:15:03 -04:00
Stephen Diehl f05079bf98 Add 8.0.1 support to Travis. 2016-06-08 19:05:43 -04:00
Stephen Diehl d39e014533 unsafeFromJust 2016-06-06 08:50:12 -04:00
Stephen Diehl 75f5f4d88f pull Conv into core 2016-05-09 14:22:13 -04:00
Stephen Diehl a70f6e2d84 bump version 2016-05-07 09:43:20 -04:00
Stephen Diehl 561ee5077e fix traceShow fixes #10 2016-04-27 15:27:42 -04:00
Stephen Diehl a9cc28f3b1 remove partial functions 2016-04-21 18:50:01 -04:00
Stephen Diehl 0b3090973e pulling semiring in module 2016-04-19 09:32:59 -04:00
Stephen Diehl fba329438f bump version 2016-04-19 09:13:06 -04:00
Stephen Diehl c0b161602d export generics 2016-04-18 18:09:50 -04:00
Stephen Diehl 2c83d2dbf6 data.records still in flux upstream 2016-04-18 14:02:58 -04:00
Stephen Diehl 5c8186f618 handle semigroup monoid 8.0 compat 2016-04-18 13:50:18 -04:00
Stephen Diehl aecd72fa5c ghc 8.0 record and typeintype prelude objects 2016-04-18 13:39:36 -04:00
Stephen Diehl 8756b6507b unbreak functor/monad issue in old ghc vers 2016-04-18 11:17:02 -04:00
Stephen Diehl 4b3caa5c18 bring 7.10 type-level equality into scope 2016-04-18 11:09:03 -04:00
Stephen Diehl da7da2fe75 mask fail function 2016-04-18 10:51:02 -04:00
Stephen Diehl e442b31203 polymorphic show func 2016-04-18 10:35:34 -04:00
Stephen Diehl ed6d680c70 bump version 2016-04-16 11:08:30 -04:00
Stephen Diehl ea709c2945 Squashed commit of the following:
commit 416dc35d5a6ead5ce62063b56539d899e91bfd36
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Thu Apr 14 14:00:23 2016 -0400

    fix readme formatting

commit 8bf3029d01
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 18:39:39 2016 -0400

    design points in readme

commit 76bc617db9
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 17:09:10 2016 -0400

    functor include

commit cbaa117b8a
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 16:39:47 2016 -0400

    brenden's list function

commit ef52c8d507
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 16:36:42 2016 -0400

    gracefully handle 7.10 modules if present

commit f6fca1059d
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 16:28:37 2016 -0400

    not worth backporting void

commit 26d679e257
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 16:12:55 2016 -0400

    explicit base types, IsString export, Proxy

commit a14ad9bdd6
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 15:20:15 2016 -0400

    all non-partial list functions
2016-04-14 14:02:20 -04:00
Stephen Diehl e7debe1a2c Merge pull request #7 from sdiehl/list-extras
all non-partial list functions
2016-04-13 18:56:58 -04:00
Stephen Diehl 8bf3029d01 design points in readme 2016-04-13 18:39:39 -04:00
Stephen Diehl 76bc617db9 functor include 2016-04-13 17:09:10 -04:00
Stephen Diehl cbaa117b8a brenden's list function 2016-04-13 16:39:47 -04:00
Stephen Diehl ef52c8d507 gracefully handle 7.10 modules if present 2016-04-13 16:36:42 -04:00
Stephen Diehl f6fca1059d not worth backporting void 2016-04-13 16:28:37 -04:00
Stephen Diehl 26d679e257 explicit base types, IsString export, Proxy 2016-04-13 16:12:55 -04:00
Stephen Diehl a14ad9bdd6 all non-partial list functions 2016-04-13 15:20:15 -04:00
Stephen Diehl 5388b8cd4b Squashed commit of the following:
commit a6f62265f345c8b7a7226515171752586b0d66e5
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 13:41:05 2016 -0400

    bump version

commit 1a809623cd1484ce215612e6b3ecef15015bc602
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 13:26:11 2016 -0400

    masking for ghc 8.0 specific type

commit 54bafb0bb80c8450863eac53a1f3a20a21c8b0c9
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 12:55:08 2016 -0400

    bump ghc-prim for GHC 8.0 compat

commit 8808d5f37369107b3e5961255089a8a9e02bf3d5
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 12:53:39 2016 -0400

    expose base State transformers

commit 05c32a4542aa66f715aea3855e140f74e97d4852
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 12:46:00 2016 -0400

    adds compiler-independent base module
2016-04-13 13:51:47 -04:00
Stephen Diehl 99427e741c Merge pull request #5 from mitchellwrosen/master
Fix some re-exports
2016-04-13 11:42:26 -04:00
Mitchell Rosen 33d029c1b0 Fix some re-exports 2016-04-13 11:03:23 -04:00
Stephen Diehl 949d62cc12 qualified import of ByteString fixes #4 2016-04-12 09:43:59 -04:00
Stephen Diehl ef5b47b4f7 expose seq and asTypeOf 2016-04-09 20:43:26 -04:00
Stephen Diehl 26c148510e expose rest of safe functions 2016-04-09 20:17:55 -04:00
Stephen Diehl 1a6ce9436f include either module 2016-04-09 20:02:11 -04:00
Stephen Diehl 1f0a5a9576 backport bifunctor 2016-04-09 19:57:02 -04:00
Stephen Diehl 806939605a better readme 2016-04-09 19:35:23 -04:00
Stephen Diehl bd5f8f1b23 fix backwards compart for ($!) 2016-04-09 19:25:55 -04:00
Stephen Diehl 2c47ec7262 selectively expose more of ghc.base 2016-04-09 15:53:25 -04:00
Stephen Diehl cff538114d fix data.functor exports 2016-04-09 15:34:30 -04:00
Stephen Diehl 1c8fc29c4a bring flip into scope 2016-04-09 15:18:30 -04:00
Stephen Diehl 22fda7cedc added enum class 2016-04-09 15:16:56 -04:00
Stephen Diehl b3674708d4 functor module 2016-04-09 15:14:21 -04:00
Stephen Diehl 7a62c5d489 functor module 2016-04-09 15:13:13 -04:00
Stephen Diehl 959cd272f7 fix typo in fun name 2016-04-09 14:56:55 -04:00
Stephen Diehl 8cd2b4ffd3 build status 2016-04-09 14:50:45 -04:00
Stephen Diehl d5bdaf0c88 use in module traceM 2016-04-09 14:49:16 -04:00
Stephen Diehl 8f6e97633c backwards compat for traceM 2016-04-09 14:25:20 -04:00
Stephen Diehl 4bd0ed3e83 modern ghc only 2016-04-09 13:20:05 -04:00
Stephen Diehl 6ede03c8ce travis build 2016-04-09 13:07:45 -04:00
Stephen Diehl dd6a97adfa hackage package 2016-04-08 11:25:58 -04:00
Stephen Diehl ccf89378f8 fix import formatting 2016-04-07 17:33:20 -04:00
Stephen Diehl 8417d2a031 fix gitignore 2016-04-07 17:14:57 -04:00
Stephen Diehl 28dad7fca1 fix warnings 2016-04-07 17:14:42 -04:00
Stephen Diehl e94c364d65 readme 2016-04-07 15:34:56 -04:00
Stephen Diehl 29b854cf98 initial commit 2016-04-07 15:22:44 -04:00
25 changed files with 2422 additions and 8 deletions
+2
View File
@@ -0,0 +1,2 @@
# Ignore blame for commit that moved protolude files under src/protolude
d4949c633e8172d0e4dd8f5c991eaaae6b48fbb0
+5 -3
View File
@@ -29,7 +29,8 @@ let
# Format Haskell files
# --vimgrep fixes a bug in ag: https://github.com/ggreer/the_silver_searcher/issues/753
${silver-searcher}/bin/ag -l --vimgrep -g '\.l?hs$' . \
# TODO: fix style issues in src/protolude and include it
${silver-searcher}/bin/ag -l --vimgrep -g '\.l?hs$' --ignore-dir=src/protolude . \
| xargs ${stylish-haskell}/bin/stylish-haskell -i
# Format Python files
@@ -89,11 +90,12 @@ let
${ruff}/bin/ruff check .
echo "Checking consistency of import aliases in Haskell code..."
${hsie} check-aliases main src
${hsie} check-aliases main src/PostgREST
echo "Linting Haskell files..."
# --vimgrep fixes a bug in ag: https://github.com/ggreer/the_silver_searcher/issues/753
${silver-searcher}/bin/ag -l --vimgrep -g '\.l?hs$' . \
# TODO: fix lint issues in src/protolude and include it
${silver-searcher}/bin/ag -l --vimgrep -g '\.l?hs$' --ignore-dir=src/protolude . \
| xargs ${hlint}/bin/hlint --hint=${hlintConfig}
'';
+53 -5
View File
@@ -136,7 +136,7 @@ library
, parsec >= 3.1.11 && < 3.2
, postgresql-libpq >= 0.10
, prometheus-client >= 1.1.1 && < 1.2.0
, protolude >= 0.3.1 && < 0.4
, protolude
, regex-tdfa >= 1.2.2 && < 1.4
, retry >= 0.7.4 && < 0.10
, scientific >= 0.3.4 && < 0.4
@@ -180,6 +180,54 @@ library
build-depends:
unix
library protolude
visibility: private
default-language: Haskell2010
default-extensions: NoImplicitPrelude
FlexibleContexts
MultiParamTypeClasses
OverloadedStrings
hs-source-dirs: src/protolude
exposed-modules: Protolude
Protolude.Applicative
Protolude.Base
Protolude.Bifunctor
Protolude.Bool
Protolude.CallStack
Protolude.Conv
Protolude.ConvertText
Protolude.Debug
Protolude.Either
Protolude.Error
Protolude.Exceptions
Protolude.Functor
Protolude.List
Protolude.Monad
Protolude.Panic
Protolude.Partial
Protolude.Safe
Protolude.Semiring
Protolude.Show
Protolude.Unsafe
build-depends: array >= 0.4 && < 0.6
, async >= 2.0 && < 2.3
, base >= 4.6 && < 4.22
, bytestring >= 0.10.8 && < 0.13
, containers >= 0.5.7 && < 0.8
, deepseq >= 1.3 && < 1.6
, ghc-prim >= 0.3 && < 0.14
, hashable >= 1.2 && < 1.6
, mtl >= 2.1 && < 2.4
, mtl-compat >= 0.2 && < 0.3
, stm >= 2.5 && < 3
, text >= 1.2.2 && < 2.2
, transformers >= 0.2 && < 0.7
, transformers-compat >= 0.4 && < 0.8
-- Protolude has some partial functions, so
-- it is fine to disable that specific warning
ghc-options: -Werror -Wall -fwarn-identities -Wno-x-partial
-fno-spec-constr -optP-Wno-nonportable-include-path
executable postgrest
default-language: Haskell2010
default-extensions: OverloadedStrings
@@ -189,7 +237,7 @@ executable postgrest
build-depends: base >= 4.9 && < 4.22
, containers >= 0.5.7 && < 0.8
, postgrest
, protolude >= 0.3.1 && < 0.4
, protolude
ghc-options: -threaded -rtsopts "-with-rtsopts=-N -I0 -qg"
-O2 -Werror -Wall -fwarn-identities
-fno-spec-constr -optP-Wno-nonportable-include-path
@@ -285,7 +333,7 @@ test-suite spec
, postgrest
, process >= 1.4.2 && < 1.7
, prometheus-client >= 1.1.1 && < 1.2.0
, protolude >= 0.3.1 && < 0.4
, protolude
, regex-tdfa >= 1.2.2 && < 1.4
, scientific >= 0.3.4 && < 0.4
, text >= 1.2.2 && < 2.2
@@ -324,7 +372,7 @@ test-suite observability
, jose-jwt >= 0.9.6 && < 0.11
, postgrest
, prometheus-client >= 1.1.1 && < 1.2.0
, protolude >= 0.3.1 && < 0.4
, protolude
, text >= 1.2.2 && < 2.2
, wai >= 3.2.1 && < 3.3
ghc-options: -threaded -O0 -Werror -Wall -fwarn-identities
@@ -344,6 +392,6 @@ test-suite doctests
, doctest >= 0.8
, postgrest
, pretty-simple
, protolude >= 0.3.1 && < 0.4
, protolude
ghc-options: -threaded -O0 -Werror -Wall -fwarn-identities
-fno-spec-constr -optP-Wno-nonportable-include-path
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2016-2020, Stephen Diehl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
File diff suppressed because it is too large Load Diff
+38
View File
@@ -0,0 +1,38 @@
{-# LANGUAGE Safe #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Applicative
( orAlt,
orEmpty,
eitherA,
purer,
liftAA2,
(<<*>>),
)
where
import Control.Applicative
import Data.Bool (Bool)
import Data.Either (Either (Left, Right))
import Data.Function ((.))
import Data.Monoid (Monoid (mempty))
orAlt :: (Alternative f, Monoid a) => f a -> f a
orAlt f = f <|> pure mempty
orEmpty :: Alternative f => Bool -> a -> f a
orEmpty b a = if b then pure a else empty
eitherA :: (Alternative f) => f a -> f b -> f (Either a b)
eitherA a b = (Left <$> a) <|> (Right <$> b)
purer :: (Applicative f, Applicative g) => a -> f (g a)
purer = pure . pure
liftAA2 :: (Applicative f, Applicative g) => (a -> b -> c) -> f (g a) -> f (g b) -> f (g c)
liftAA2 = liftA2 . liftA2
infixl 4 <<*>>
(<<*>>) :: (Applicative f, Applicative g) => f (g (a -> b)) -> f (g a) -> f (g b)
(<<*>>) = liftA2 (<*>)
+225
View File
@@ -0,0 +1,225 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ExplicitNamespaces #-}
module Protolude.Base (
module Base,
($!),
) where
-- Glorious Glasgow Haskell Compiler
#if defined(__GLASGOW_HASKELL__) && ( __GLASGOW_HASKELL__ >= 600 )
-- Base GHC types
import GHC.Num as Base (
Num(
(+),
(-),
(*),
negate,
abs,
signum,
fromInteger
)
, Integer
, subtract
)
import GHC.Enum as Base (
Bounded(minBound, maxBound)
, Enum(
succ,
pred,
toEnum,
fromEnum,
enumFrom,
enumFromThen,
enumFromTo,
enumFromThenTo
)
, boundedEnumFrom
, boundedEnumFromThen
)
import GHC.Real as Base (
(%)
, (/)
, Fractional
, Integral
, Ratio
, Rational
, Real
, RealFrac
, (^)
, (^%^)
, (^^)
, (^^%^^)
, ceiling
, denominator
, div
, divMod
#if MIN_VERSION_base(4,7,0)
, divZeroError
#endif
, even
, floor
, fromIntegral
, fromRational
, gcd
#if MIN_VERSION_base(4,9,0) && !MIN_VERSION_base(4,15,0)
#if defined(MIN_VERSION_integer_gmp)
, gcdInt'
, gcdWord'
#endif
#endif
, infinity
, integralEnumFrom
, integralEnumFromThen
, integralEnumFromThenTo
, integralEnumFromTo
, lcm
, mod
, notANumber
, numerator
, numericEnumFrom
, numericEnumFromThen
, numericEnumFromThenTo
, numericEnumFromTo
, odd
#if MIN_VERSION_base(4,7,0)
, overflowError
#endif
, properFraction
, quot
, quotRem
, ratioPrec
, ratioPrec1
#if MIN_VERSION_base(4,7,0)
, ratioZeroDenominatorError
#endif
, realToFrac
, recip
, reduce
, rem
, round
, showSigned
, toInteger
, toRational
, truncate
#if MIN_VERSION_base(4,12,0)
, underflowError
#endif
)
import GHC.Float as Base (
Float(F#)
, Double(D#)
, Floating (..)
, RealFloat(..)
, showFloat
, showSignedFloat
)
import GHC.Show as Base (
Show(showsPrec, show, showList)
)
import GHC.Exts as Base (
Constraint
, Ptr
, FunPtr
)
import GHC.Base as Base (
(++)
, seq
, asTypeOf
, ord
, maxInt
, minInt
, until
)
-- Exported for lifting into new functions.
import System.IO as Base (
print
, putStr
, putStrLn
)
import GHC.Types as Base (
Bool
, Char
, Int
, Word
, Ordering
, IO
#if ( __GLASGOW_HASKELL__ >= 710 )
, Coercible
#endif
)
#if ( __GLASGOW_HASKELL__ >= 710 )
import GHC.StaticPtr as Base (StaticPtr)
#endif
#if ( __GLASGOW_HASKELL__ >= 800 )
import GHC.OverloadedLabels as Base (
IsLabel(fromLabel)
)
import GHC.ExecutionStack as Base (
Location(Location, srcLoc, objectName, functionName)
, SrcLoc(SrcLoc, sourceColumn, sourceLine, sourceColumn)
, getStackTrace
, showStackTrace
)
import GHC.Stack as Base (
CallStack
, type HasCallStack
, callStack
, prettySrcLoc
, currentCallStack
, getCallStack
, prettyCallStack
, withFrozenCallStack
)
#endif
#if ( __GLASGOW_HASKELL__ >= 710 )
import GHC.TypeLits as Base (
Symbol
, SomeSymbol(SomeSymbol)
, Nat
, SomeNat(SomeNat)
, CmpNat
, KnownSymbol
, KnownNat
, natVal
, someNatVal
, symbolVal
, someSymbolVal
)
#endif
#if ( __GLASGOW_HASKELL__ >= 802 )
import GHC.Records as Base (
HasField(getField)
)
#endif
#if ( __GLASGOW_HASKELL__ >= 800 )
import Data.Kind as Base (
type Type
#if ( __GLASGOW_HASKELL__ < 805 )
, type (*)
#endif
, type Type
)
#endif
-- Default Prelude defines this at the toplevel module, so we do as well.
infixr 0 $!
($!) :: (a -> b) -> a -> b
f $! x = let !vx = x in f vx
#endif
+51
View File
@@ -0,0 +1,51 @@
{-# LANGUAGE Safe #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Bifunctor
( Bifunctor,
bimap,
first,
second,
)
where
import Control.Applicative (Const (Const))
import Data.Either (Either (Left, Right))
import Data.Function ((.), id)
class Bifunctor p where
{-# MINIMAL bimap | first, second #-}
bimap :: (a -> b) -> (c -> d) -> p a c -> p b d
bimap f g = first f . second g
first :: (a -> b) -> p a c -> p b c
first f = bimap f id
second :: (b -> c) -> p a b -> p a c
second = bimap id
instance Bifunctor (,) where
bimap f g ~(a, b) = (f a, g b)
instance Bifunctor ((,,) x1) where
bimap f g ~(x1, a, b) = (x1, f a, g b)
instance Bifunctor ((,,,) x1 x2) where
bimap f g ~(x1, x2, a, b) = (x1, x2, f a, g b)
instance Bifunctor ((,,,,) x1 x2 x3) where
bimap f g ~(x1, x2, x3, a, b) = (x1, x2, x3, f a, g b)
instance Bifunctor ((,,,,,) x1 x2 x3 x4) where
bimap f g ~(x1, x2, x3, x4, a, b) = (x1, x2, x3, x4, f a, g b)
instance Bifunctor ((,,,,,,) x1 x2 x3 x4 x5) where
bimap f g ~(x1, x2, x3, x4, x5, a, b) = (x1, x2, x3, x4, x5, f a, g b)
instance Bifunctor Either where
bimap f _ (Left a) = Left (f a)
bimap _ g (Right b) = Right (g b)
instance Bifunctor Const where
bimap f _ (Const a) = Const (f a)
+64
View File
@@ -0,0 +1,64 @@
{-# LANGUAGE Safe #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Bool (
whenM
, unlessM
, ifM
, guardM
, bool
, (&&^)
, (||^)
, (<&&>)
, (<||>)
) where
import Data.Bool (Bool(True, False), (&&), (||))
import Data.Function (flip)
import Control.Applicative(Applicative, liftA2)
import Control.Monad (Monad, MonadPlus, return, when, unless, guard, (>>=), (=<<))
bool :: a -> a -> Bool -> a
bool f t p = if p then t else f
whenM :: Monad m => m Bool -> m () -> m ()
whenM p m =
p >>= flip when m
unlessM :: Monad m => m Bool -> m () -> m ()
unlessM p m =
p >>= flip unless m
ifM :: Monad m => m Bool -> m a -> m a -> m a
ifM p x y = p >>= \b -> if b then x else y
guardM :: MonadPlus m => m Bool -> m ()
guardM f = guard =<< f
-- | The '||' operator lifted to a monad. If the first
-- argument evaluates to 'True' the second argument will not
-- be evaluated.
infixr 2 ||^ -- same as (||)
(||^) :: Monad m => m Bool -> m Bool -> m Bool
(||^) a b = ifM a (return True) b
infixr 2 <||>
-- | '||' lifted to an Applicative.
-- Unlike '||^' the operator is __not__ short-circuiting.
(<||>) :: Applicative a => a Bool -> a Bool -> a Bool
(<||>) = liftA2 (||)
{-# INLINE (<||>) #-}
-- | The '&&' operator lifted to a monad. If the first
-- argument evaluates to 'False' the second argument will not
-- be evaluated.
infixr 3 &&^ -- same as (&&)
(&&^) :: Monad m => m Bool -> m Bool -> m Bool
(&&^) a b = ifM a b (return False)
infixr 3 <&&>
-- | '&&' lifted to an Applicative.
-- Unlike '&&^' the operator is __not__ short-circuiting.
(<&&>) :: Applicative a => a Bool -> a Bool -> a Bool
(<&&>) = liftA2 (&&)
{-# INLINE (<&&>) #-}
+18
View File
@@ -0,0 +1,18 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE ConstraintKinds #-}
module Protolude.CallStack
( HasCallStack
) where
#if MIN_VERSION_base(4,9,0)
import GHC.Stack (HasCallStack)
#elif MIN_VERSION_base(4,8,1)
import qualified GHC.Stack
type HasCallStack = (?callStack :: GHC.Stack.CallStack)
#else
import GHC.Exts (Constraint)
type HasCallStack = (() :: Constraint)
#endif
+78
View File
@@ -0,0 +1,78 @@
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
-- | An alternative to 'Protolude.ConvertText' that includes
-- partial conversions. Not re-exported by 'Protolude'.
module Protolude.Conv (
StringConv
, strConv
, toS
, toSL
, Leniency (Lenient, Strict)
) where
import Data.ByteString.Char8 as B
import Data.ByteString.Lazy.Char8 as LB
import Data.Text as T
import Data.Text.Encoding as T
import Data.Text.Encoding.Error as T
import Data.Text.Lazy as LT
import Data.Text.Lazy.Encoding as LT
import Protolude.Base
import Data.Eq (Eq)
import Data.Ord (Ord)
import Data.Function ((.), id)
import Data.String (String)
import Control.Applicative (pure)
data Leniency = Lenient | Strict
deriving (Eq,Show,Ord,Enum,Bounded)
class StringConv a b where
strConv :: Leniency -> a -> b
toS :: StringConv a b => a -> b
toS = strConv Strict
toSL :: StringConv a b => a -> b
toSL = strConv Lenient
instance StringConv String String where strConv _ = id
instance StringConv String B.ByteString where strConv _ = B.pack
instance StringConv String LB.ByteString where strConv _ = LB.pack
instance StringConv String T.Text where strConv _ = T.pack
instance StringConv String LT.Text where strConv _ = LT.pack
instance StringConv B.ByteString String where strConv _ = B.unpack
instance StringConv B.ByteString B.ByteString where strConv _ = id
instance StringConv B.ByteString LB.ByteString where strConv _ = LB.fromChunks . pure
instance StringConv B.ByteString T.Text where strConv = decodeUtf8T
instance StringConv B.ByteString LT.Text where strConv l = strConv l . LB.fromChunks . pure
instance StringConv LB.ByteString String where strConv _ = LB.unpack
instance StringConv LB.ByteString B.ByteString where strConv _ = B.concat . LB.toChunks
instance StringConv LB.ByteString LB.ByteString where strConv _ = id
instance StringConv LB.ByteString T.Text where strConv l = decodeUtf8T l . strConv l
instance StringConv LB.ByteString LT.Text where strConv = decodeUtf8LT
instance StringConv T.Text String where strConv _ = T.unpack
instance StringConv T.Text B.ByteString where strConv _ = T.encodeUtf8
instance StringConv T.Text LB.ByteString where strConv l = strConv l . T.encodeUtf8
instance StringConv T.Text LT.Text where strConv _ = LT.fromStrict
instance StringConv T.Text T.Text where strConv _ = id
instance StringConv LT.Text String where strConv _ = LT.unpack
instance StringConv LT.Text T.Text where strConv _ = LT.toStrict
instance StringConv LT.Text LT.Text where strConv _ = id
instance StringConv LT.Text LB.ByteString where strConv _ = LT.encodeUtf8
instance StringConv LT.Text B.ByteString where strConv l = strConv l . LT.encodeUtf8
decodeUtf8T :: Leniency -> B.ByteString -> T.Text
decodeUtf8T Lenient = T.decodeUtf8With T.lenientDecode
decodeUtf8T Strict = T.decodeUtf8With T.strictDecode
decodeUtf8LT :: Leniency -> LB.ByteString -> LT.Text
decodeUtf8LT Lenient = LT.decodeUtf8With T.lenientDecode
decodeUtf8LT Strict = LT.decodeUtf8With T.strictDecode
+50
View File
@@ -0,0 +1,50 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Safe #-}
-- | Non-partial text conversion typeclass and functions.
-- For an alternative with partial conversions import 'Protolude.Conv'.
module Protolude.ConvertText (
ConvertText (toS)
, toUtf8
, toUtf8Lazy
) where
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as LB
import qualified Data.Text as T
import qualified Data.Text.Lazy as LT
import Data.Function (id, (.))
import Data.String (String)
import Data.Text.Encoding (encodeUtf8)
-- | Convert from one Unicode textual type to another. Not for serialization/deserialization,
-- so doesn't have instances for bytestrings.
class ConvertText a b where
toS :: a -> b
instance ConvertText String String where toS = id
instance ConvertText String T.Text where toS = T.pack
instance ConvertText String LT.Text where toS = LT.pack
instance ConvertText T.Text String where toS = T.unpack
instance ConvertText T.Text LT.Text where toS = LT.fromStrict
instance ConvertText T.Text T.Text where toS = id
instance ConvertText LT.Text String where toS = LT.unpack
instance ConvertText LT.Text T.Text where toS = LT.toStrict
instance ConvertText LT.Text LT.Text where toS = id
instance ConvertText LB.ByteString B.ByteString where toS = LB.toStrict
instance ConvertText LB.ByteString LB.ByteString where toS = id
instance ConvertText B.ByteString B.ByteString where toS = id
instance ConvertText B.ByteString LB.ByteString where toS = LB.fromStrict
toUtf8 :: ConvertText a T.Text => a -> B.ByteString
toUtf8 =
encodeUtf8 . toS
toUtf8Lazy :: ConvertText a T.Text => a -> LB.ByteString
toUtf8Lazy =
LB.fromStrict . encodeUtf8 . toS
+69
View File
@@ -0,0 +1,69 @@
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
module Protolude.Debug (
undefined,
trace,
traceM,
traceId,
traceIO,
traceShow,
traceShowId,
traceShowM,
notImplemented,
witness,
) where
import Data.Text (Text, unpack)
import Control.Monad (Monad, return)
import qualified Protolude.Base as P
import Protolude.Error (error)
import Protolude.Show (Print, hPutStrLn)
import System.IO(stderr)
import System.IO.Unsafe (unsafePerformIO)
{-# WARNING trace "'trace' remains in code" #-}
trace :: Print b => b -> a -> a
trace string expr = unsafePerformIO (do
hPutStrLn stderr string
return expr)
{-# WARNING traceIO "'traceIO' remains in code" #-}
traceIO :: Print b => b -> a -> P.IO a
traceIO string expr = do
hPutStrLn stderr string
return expr
{-# WARNING traceShow "'traceShow' remains in code" #-}
traceShow :: P.Show a => a -> b -> b
traceShow a b = trace (P.show a) b
{-# WARNING traceShowId "'traceShowId' remains in code" #-}
traceShowId :: P.Show a => a -> a
traceShowId a = trace (P.show a) a
{-# WARNING traceShowM "'traceShowM' remains in code" #-}
traceShowM :: (P.Show a, Monad m) => a -> m ()
traceShowM a = trace (P.show a) (return ())
{-# WARNING traceM "'traceM' remains in code" #-}
traceM :: (Monad m) => Text -> m ()
traceM s = trace (unpack s) (return ())
{-# WARNING traceId "'traceId' remains in code" #-}
traceId :: Text -> Text
traceId s = trace s s
{-# WARNING notImplemented "'notImplemented' remains in code" #-}
notImplemented :: a
notImplemented = error "Not implemented"
{-# WARNING undefined "'undefined' remains in code" #-}
undefined :: a
undefined = error "Prelude.undefined"
witness :: a
witness = error "Type witness should not be evaluated"
+51
View File
@@ -0,0 +1,51 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE Safe #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Either (
maybeToLeft
, maybeToRight
, leftToMaybe
, rightToMaybe
, maybeEmpty
, maybeToEither
, fromLeft
, fromRight
) where
import Data.Function (const)
import Data.Monoid (Monoid, mempty)
import Data.Maybe (Maybe(Nothing, Just), maybe)
import Data.Either (Either(Left, Right), either)
#if MIN_VERSION_base(4,10,0)
import Data.Either (fromLeft, fromRight)
#else
-- | Return the contents of a 'Right'-value or a default value otherwise.
fromLeft :: a -> Either a b -> a
fromLeft _ (Left a) = a
fromLeft a _ = a
-- | Return the contents of a 'Right'-value or a default value otherwise.
fromRight :: b -> Either a b -> b
fromRight _ (Right b) = b
fromRight b _ = b
#endif
leftToMaybe :: Either l r -> Maybe l
leftToMaybe = either Just (const Nothing)
rightToMaybe :: Either l r -> Maybe r
rightToMaybe = either (const Nothing) Just
maybeToRight :: l -> Maybe r -> Either l r
maybeToRight l = maybe (Left l) Right
maybeToLeft :: r -> Maybe l -> Either l r
maybeToLeft r = maybe (Right r) Left
maybeEmpty :: Monoid b => (a -> b) -> Maybe a -> b
maybeEmpty = maybe mempty
maybeToEither :: e -> Maybe a -> Either e a
maybeToEither e Nothing = Left e
maybeToEither _ (Just a) = Right a
+52
View File
@@ -0,0 +1,52 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE ExistentialQuantification #-}
#if ( __GLASGOW_HASKELL__ >= 800 )
{-# LANGUAGE DataKinds #-}
#endif
#if MIN_VERSION_base(4,9,0)
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
#endif
module Protolude.Error
( error
) where
import Data.Text (Text, unpack)
#if MIN_VERSION_base(4,9,0)
-- Full stack trace.
import GHC.Prim (TYPE, raise#)
import GHC.Types (RuntimeRep)
import Protolude.CallStack (HasCallStack)
import GHC.Exception (errorCallWithCallStackException)
{-# WARNING error "'error' remains in code" #-}
error :: forall (r :: RuntimeRep) . forall (a :: TYPE r) . HasCallStack => Text -> a
error s = raise# (errorCallWithCallStackException (unpack s) ?callStack)
#elif MIN_VERSION_base(4,7,0)
-- Basic Call Stack with callsite.
import GHC.Prim (raise#)
import GHC.Exception (errorCallException)
{-# WARNING error "'error' remains in code" #-}
error :: Text -> a
error s = raise# (errorCallException (unpack s))
#else
-- No exception tracing.
import GHC.Types
import GHC.Exception
{-# WARNING error "'error' remains in code" #-}
error :: Text -> a
error s = throw (ErrorCall (unpack s))
#endif
+35
View File
@@ -0,0 +1,35 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Exceptions (
hush,
note,
tryIO,
) where
import Protolude.Base (IO)
import Data.Function ((.))
import Control.Monad.Trans (liftIO)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Except (ExceptT(ExceptT), MonadError, throwError)
import Control.Exception as Exception
import Control.Applicative
import Data.Maybe (Maybe, maybe)
import Data.Either (Either(Left,Right))
hush :: Alternative m => Either e a -> m a
hush (Left _) = empty
hush (Right x) = pure x
-- To suppress redundant applicative constraint warning on GHC 8.0
#if ( __GLASGOW_HASKELL__ >= 800 )
note :: (MonadError e m) => e -> Maybe a -> m a
note err = maybe (throwError err) pure
#else
note :: (MonadError e m, Applicative m) => e -> Maybe a -> m a
note err = maybe (throwError err) pure
#endif
tryIO :: MonadIO m => IO a -> ExceptT IOException m a
tryIO = ExceptT . liftIO . Exception.try
+62
View File
@@ -0,0 +1,62 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE Safe #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Functor (
Functor(fmap),
($>),
(<$),
(<$>),
(<<$>>),
(<&>),
void,
foreach,
) where
import Data.Function ((.), flip)
#if MIN_VERSION_base(4,11,0)
import Data.Functor ((<&>))
#endif
#if MIN_VERSION_base(4,7,0)
import Data.Functor (
Functor(fmap)
, (<$)
, ($>)
, (<$>)
, void
)
#else
import Data.Functor (
Functor(fmap)
, (<$)
, (<$>)
)
infixl 4 $>
($>) :: Functor f => f a -> b -> f b
($>) = flip (<$)
void :: Functor f => f a -> f ()
void x = () <$ x
#endif
infixl 4 <<$>>
(<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
(<<$>>) = fmap . fmap
foreach :: Functor f => f a -> (a -> b) -> f b
foreach = flip fmap
#if !MIN_VERSION_base(4,11,0)
-- | Infix version of foreach.
--
-- '<&>' is to '<$>' what '&' is to '$'.
infixl 1 <&>
(<&>) :: Functor f => f a -> (a -> b) -> f b
(<&>) = foreach
#endif
+52
View File
@@ -0,0 +1,52 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Safe #-}
module Protolude.List
( head,
ordNub,
sortOn,
list,
product,
sum,
groupBy,
)
where
import Control.Applicative (pure)
import Data.Foldable (Foldable, foldl', foldr)
import Data.Function ((.))
import Data.Functor (fmap)
import Data.List (groupBy, sortBy)
import Data.Maybe (Maybe (Nothing))
import Data.Ord (Ord, comparing)
import qualified Data.Set as Set
import Prelude ((*), (+), Num)
head :: (Foldable f) => f a -> Maybe a
head = foldr (\x _ -> pure x) Nothing
sortOn :: (Ord o) => (a -> o) -> [a] -> [a]
sortOn = sortBy . comparing
-- O(n * log n)
ordNub :: (Ord a) => [a] -> [a]
ordNub l = go Set.empty l
where
go _ [] = []
go s (x : xs) =
if x `Set.member` s
then go s xs
else x : go (Set.insert x s) xs
list :: [b] -> (a -> b) -> [a] -> [b]
list def f xs = case xs of
[] -> def
_ -> fmap f xs
{-# INLINE product #-}
product :: (Foldable f, Num a) => f a -> a
product = foldl' (*) 1
{-# INLINE sum #-}
sum :: (Foldable f, Num a) => f a -> a
sum = foldl' (+) 0
+69
View File
@@ -0,0 +1,69 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Monad (
Monad((>>=), return)
, MonadPlus(mzero, mplus)
, (=<<)
, (>=>)
, (<=<)
, (>>)
, forever
, join
, mfilter
, filterM
, mapAndUnzipM
, zipWithM
, zipWithM_
, foldM
, foldM_
, replicateM
, replicateM_
, concatMapM
, guard
, when
, unless
, liftM
, liftM2
, liftM3
, liftM4
, liftM5
, liftM'
, liftM2'
, ap
, (<$!>)
) where
import Protolude.Base (seq)
import Data.List (concat)
import Control.Monad
concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]
concatMapM f xs = liftM concat (mapM f xs)
liftM' :: Monad m => (a -> b) -> m a -> m b
liftM' = (<$!>)
{-# INLINE liftM' #-}
liftM2' :: (Monad m) => (a -> b -> c) -> m a -> m b -> m c
liftM2' f a b = do
x <- a
y <- b
let z = f x y
z `seq` return z
{-# INLINE liftM2' #-}
#if !MIN_VERSION_base(4,8,0)
(<$!>) :: Monad m => (a -> b) -> m a -> m b
f <$!> m = do
x <- m
let z = f x
z `seq` return z
{-# INLINE (<$!>) #-}
#endif
+26
View File
@@ -0,0 +1,26 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
#if MIN_VERSION_base(4,9,0)
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
#endif
module Protolude.Panic (
FatalError(FatalError, fatalErrorMessage),
panic,
) where
import Protolude.Base (Show)
import Protolude.CallStack (HasCallStack)
import Data.Text (Text)
import Control.Exception as X
-- | Uncatchable exceptions thrown and never caught.
newtype FatalError = FatalError { fatalErrorMessage :: Text }
deriving (Show)
instance Exception FatalError
panic :: HasCallStack => Text -> a
panic a = throw (FatalError a)
+26
View File
@@ -0,0 +1,26 @@
module Protolude.Partial
( head,
init,
tail,
last,
foldl,
foldr,
foldl',
foldr',
foldr1,
foldl1,
cycle,
maximum,
minimum,
(!!),
sum,
product,
fromJust,
read,
)
where
import Data.Foldable (foldl, foldl', foldl1, foldr, foldr', foldr1, product, sum)
import Data.List ((!!), cycle, head, init, last, maximum, minimum, tail)
import Data.Maybe (fromJust)
import Text.Read (read)
+137
View File
@@ -0,0 +1,137 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE Safe #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Safe (
headMay
, headDef
, initMay
, initDef
, initSafe
, tailMay
, tailDef
, tailSafe
, lastDef
, lastMay
, foldr1May
, foldl1May
, foldl1May'
, maximumMay
, minimumMay
, maximumDef
, minimumDef
, atMay
, atDef
) where
import Data.Ord (Ord, (<))
import Data.Int (Int)
import Data.Char (Char)
import Data.Bool (Bool, otherwise)
import Data.Maybe (Maybe(Nothing, Just), fromMaybe)
import Data.Either (Either(Left, Right))
import Data.Function ((.))
import Data.List (null, head, last, tail, init, maximum, minimum, foldr1, foldl1, foldl1', (++))
import Prelude ((-))
import GHC.Show (show)
liftMay :: (a -> Bool) -> (a -> b) -> (a -> Maybe b)
liftMay test f val = if test val then Nothing else Just (f val)
-------------------------------------------------------------------------------
-- Head
-------------------------------------------------------------------------------
headMay :: [a] -> Maybe a
headMay = liftMay null head
headDef :: a -> [a] -> a
headDef def = fromMaybe def . headMay
-------------------------------------------------------------------------------
-- Init
-------------------------------------------------------------------------------
initMay :: [a] -> Maybe [a]
initMay = liftMay null init
initDef :: [a] -> [a] -> [a]
initDef def = fromMaybe def . initMay
initSafe :: [a] -> [a]
initSafe = initDef []
-------------------------------------------------------------------------------
-- Tail
-------------------------------------------------------------------------------
tailMay :: [a] -> Maybe [a]
tailMay = liftMay null tail
tailDef :: [a] -> [a] -> [a]
tailDef def = fromMaybe def . tailMay
tailSafe :: [a] -> [a]
tailSafe = tailDef []
-------------------------------------------------------------------------------
-- Last
-------------------------------------------------------------------------------
lastMay :: [a] -> Maybe a
lastMay = liftMay null last
lastDef :: a -> [a] -> a
lastDef def = fromMaybe def . lastMay
-------------------------------------------------------------------------------
-- Maximum
-------------------------------------------------------------------------------
minimumMay, maximumMay :: Ord a => [a] -> Maybe a
minimumMay = liftMay null minimum
maximumMay = liftMay null maximum
minimumDef, maximumDef :: Ord a => a -> [a] -> a
minimumDef def = fromMaybe def . minimumMay
maximumDef def = fromMaybe def . maximumMay
-------------------------------------------------------------------------------
-- Foldr
-------------------------------------------------------------------------------
foldr1May, foldl1May, foldl1May' :: (a -> a -> a) -> [a] -> Maybe a
foldr1May = liftMay null . foldr1
-------------------------------------------------------------------------------
-- Foldl
-------------------------------------------------------------------------------
foldl1May = liftMay null . foldl1
foldl1May' = liftMay null . foldl1'
-------------------------------------------------------------------------------
-- At
-------------------------------------------------------------------------------
at_ :: [a] -> Int -> Either [Char] a
at_ ys o
| o < 0 = Left ("index must not be negative, index=" ++ show o)
| otherwise = f o ys
where
f 0 (x:_) = Right x
f i (_:xs) = f (i-1) xs
f i [] = Left ("index too large, index=" ++ show o ++ ", length=" ++ show (o-i))
atMay :: [a] -> Int -> Maybe a
atMay xs i = case xs `at_` i of
Left _ -> Nothing
Right val -> Just val
atDef :: a -> [a] -> Int -> a
atDef def xs i = case xs `at_` i of
Left _ -> def
Right val -> val
+22
View File
@@ -0,0 +1,22 @@
{-# LANGUAGE Safe #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Semiring
( Semiring,
one,
(<.>),
zero,
)
where
import Data.Monoid
-- | Alias for 'mempty'
zero :: Monoid m => m
zero = mempty
class Monoid m => Semiring m where
{-# MINIMAL one, (<.>) #-}
one :: m
(<.>) :: m -> m -> m
+83
View File
@@ -0,0 +1,83 @@
{-# LANGUAGE ExtendedDefaultRules #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Show
( Print,
hPutStr,
putStr,
hPutStrLn,
putStrLn,
putErrLn,
putText,
putErrText,
putLText,
putByteString,
putLByteString,
)
where
import Control.Monad.IO.Class (MonadIO, liftIO)
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BL
import Data.Function ((.))
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.IO as TL
import qualified Protolude.Base as Base
import qualified System.IO as Base
import System.IO (Handle, stderr, stdout)
class Print a where
hPutStr :: MonadIO m => Handle -> a -> m ()
putStr :: MonadIO m => a -> m ()
putStr = hPutStr stdout
hPutStrLn :: MonadIO m => Handle -> a -> m ()
putStrLn :: MonadIO m => a -> m ()
putStrLn = hPutStrLn stdout
putErrLn :: MonadIO m => a -> m ()
putErrLn = hPutStrLn stderr
instance Print T.Text where
hPutStr = \h -> liftIO . T.hPutStr h
hPutStrLn = \h -> liftIO . T.hPutStrLn h
instance Print TL.Text where
hPutStr = \h -> liftIO . TL.hPutStr h
hPutStrLn = \h -> liftIO . TL.hPutStrLn h
instance Print BS.ByteString where
hPutStr = \h -> liftIO . BS.hPutStr h
hPutStrLn = \h -> liftIO . BS.hPutStrLn h
instance Print BL.ByteString where
hPutStr = \h -> liftIO . BL.hPutStr h
hPutStrLn = \h -> liftIO . BL.hPutStrLn h
instance Print [Base.Char] where
hPutStr = \h -> liftIO . Base.hPutStr h
hPutStrLn = \h -> liftIO . Base.hPutStrLn h
-- For forcing type inference
putText :: MonadIO m => T.Text -> m ()
putText = putStrLn
{-# SPECIALIZE putText :: T.Text -> Base.IO () #-}
putLText :: MonadIO m => TL.Text -> m ()
putLText = putStrLn
{-# SPECIALIZE putLText :: TL.Text -> Base.IO () #-}
putByteString :: MonadIO m => BS.ByteString -> m ()
putByteString = putStrLn
{-# SPECIALIZE putByteString :: BS.ByteString -> Base.IO () #-}
putLByteString :: MonadIO m => BL.ByteString -> m ()
putLByteString = putStrLn
{-# SPECIALIZE putLByteString :: BL.ByteString -> Base.IO () #-}
putErrText :: MonadIO m => T.Text -> m ()
putErrText = putErrLn
{-# SPECIALIZE putErrText :: T.Text -> Base.IO () #-}
+75
View File
@@ -0,0 +1,75 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Protolude.Unsafe (
unsafeHead,
unsafeTail,
unsafeInit,
unsafeLast,
unsafeFromJust,
unsafeIndex,
unsafeThrow,
unsafeRead,
) where
import Protolude.Base (Int)
#if ( __GLASGOW_HASKELL__ >= 800 )
import Protolude.Base (HasCallStack)
#endif
import Data.Char (Char)
import Text.Read (Read, read)
import qualified Data.List as List
import qualified Data.Maybe as Maybe
import qualified Control.Exception as Exc
unsafeThrow :: Exc.Exception e => e -> a
unsafeThrow = Exc.throw
#if ( __GLASGOW_HASKELL__ >= 800 )
unsafeHead :: HasCallStack => [a] -> a
unsafeHead = List.head
unsafeTail :: HasCallStack => [a] -> [a]
unsafeTail = List.tail
unsafeInit :: HasCallStack => [a] -> [a]
unsafeInit = List.init
unsafeLast :: HasCallStack => [a] -> a
unsafeLast = List.last
unsafeFromJust :: HasCallStack => Maybe.Maybe a -> a
unsafeFromJust = Maybe.fromJust
unsafeIndex :: HasCallStack => [a] -> Int -> a
unsafeIndex = (List.!!)
unsafeRead :: (HasCallStack, Read a) => [Char] -> a
unsafeRead = Text.Read.read
#endif
#if ( __GLASGOW_HASKELL__ < 800 )
unsafeHead :: [a] -> a
unsafeHead = List.head
unsafeTail :: [a] -> [a]
unsafeTail = List.tail
unsafeInit :: [a] -> [a]
unsafeInit = List.init
unsafeLast :: [a] -> a
unsafeLast = List.last
unsafeFromJust :: Maybe.Maybe a -> a
unsafeFromJust = Maybe.fromJust
unsafeIndex :: [a] -> Int -> a
unsafeIndex = (List.!!)
unsafeRead :: Read a => [Char] -> a
unsafeRead = Text.Read.read
#endif