protolude: A small prelude.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

A sensible set of defaults for writing custom Preludes.


[Skip to Readme]

Properties

Versions 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.1.10, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4
Change log ChangeLog.md
Dependencies array (>=0.4 && <0.6), async (>=2.0 && <2.3), base (>=4.6 && <4.15), bytestring (>=0.10 && <0.11), containers (>=0.5 && <0.7), deepseq (>=1.3 && <1.5), directory, fail (>=4.9 && <4.10), filepath, ghc, ghc-paths, ghc-prim (>=0.3 && <0.7), hashable (>=1.2 && <1.4), mtl (>=2.1 && <2.3), mtl-compat (>=0.2 && <0.3), process, protolude, stm (>=2.4 && <2.6), text (>=1.2 && <1.3), transformers (>=0.2 && <0.6), transformers-compat (>=0.4 && <0.7) [details]
License MIT
Copyright 2016-2020 Stephen Diehl
Author Stephen Diehl
Maintainer stephen.m.diehl@gmail.com
Category Prelude
Home page https://github.com/sdiehl/protolude
Bug tracker https://github.com/sdiehl/protolude/issues
Source repo head: git clone git@github.com:protolude/protolude.git
Uploaded by sdiehl at 2020-04-15T15:22:09Z

Modules

[Index] [Quick Jump]

Flags

Manual Flags

NameDescriptionDefault
dev

Build development tools

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for protolude-0.3.0

[back to package description]

Protolude

Build Status Build Status Build Status Build Status Hackage

A sensible starting Prelude for building custom Preludes.

Design points:

Supports:

Stack LTS:

Usage

To try out standalone prelude at the interactive shell, from the Protolude project directory run.

$ stack repl
> import Protolude

Swapping out the old Prelude

Disable the built-in prelude at the top of your file:

{-# LANGUAGE NoImplicitPrelude #-}

Or directly in your project cabal file:

default-extensions: NoImplicitPrelude

Then in your modules:

import Protolude

Dependencies

Protolude tries to be light on dependencies and only pulls in essential libraries that are universally common across most real-world projects. Lower and upper bounds are fully specified and compatible with both vanilla Cabal and tracks Stack LTS resolver.

Dependencies Lower (>=) Upper (<)
array 0.4 0.6
async 2.0 2.3
base 4.6 4.15
bytestring 0.10 0.11
containers 0.5 0.7
deepseq 1.3 1.5
ghc-prim 0.3 0.7
hashable 1.2 1.4
mtl 2.1 2.3
stm 2.4 2.6
text 1.2 1.3
transformers 0.4 0.6
fail 4.9 4.10

Structure

Protolude's main modules are the following:

FAQs

Because the print functions are polymorphic the type of the print functions may require annotations if the type is not fully specified by inference. To force a specific type at the call site use either

putText :: MonadIO m => T.Text -> m ()
putLText :: MonadIO m => TL.Text -> m ()

Generally speaking writing manual instances of Show is a Haskell antipattern because it produces law-violating instances of Show. You probably want to use a pretty printer library for custom printing.

If backwards compatibility is needed then the base library can be imported manually.

import GHC.Show (Show(..))

Automatic deriving of Show for your types is still supported since the class is in scope by default.

This is by design. For fatal uncatchable errors use the provided panic function if you intend the program to immediately abort.

panic "Thus I die. Thus, thus, thus. Now I am dead"

If inside of IO simply use throwIO for exception handling, or if in pure business logic use well-typed checked exceptions of the ExceptT variety.

It has been renamed to identity to reserve the id identifier for the more common use case of business logic.

You if you need partial functions for backwards compatibility you can use the Protolude.Partial module and mask the safe definitions as needed.

import Protolude hiding (head)
import Protolude.Partial (head)

Development Tools

GHC Magic

To build the exports management tool use:

$ cabal new-build exports --flag dev
$ cabal run exports

This tool uses GHC's internal compile symbol table to generate a list of exports and keep the export list of protolude stable across different versions of GHC and base.

Continious Integration

There is a massive test suite that tests all versions of GHC 7.6 - GHC HEAD alongside all Stack resolvers to ensure no regressions. Any pull requests or patch has to pass the 40 integrity checks before being considered. Any pull request must keep the export list consistent across GHC and Base version and not have any accidental symbol dropping or drift without updating the export golden tests.

License

Released under the MIT License. Copyright (c) 2016-2020, Stephen Diehl