All Projects → protolude → Protolude

protolude / Protolude

Licence: mit
A sensible starting Prelude template.

Programming Languages

haskell
3896 projects

Labels

Projects that are alternatives of or similar to Protolude

SafeObject
IOS崩溃异常的处理,防止数组越界,字典空值处理
Stars: ✭ 84 (-77.42%)
Mutual labels:  safe
rails hotwire base
Rails + Hotwire base app
Stars: ✭ 54 (-85.48%)
Mutual labels:  base
Drona
Drona is a programming framework for building safe robotics systems
Stars: ✭ 26 (-93.01%)
Mutual labels:  safe
gologger
A concurrent, fast queue/service worker based filesystem logging system perfect for servers with concurrent connections
Stars: ✭ 16 (-95.7%)
Mutual labels:  safe
Numbase
Arbitrary number base converter.
Stars: ✭ 22 (-94.09%)
Mutual labels:  base
core
Pisi-2.0 Core repository
Stars: ✭ 19 (-94.89%)
Mutual labels:  base
db-safedelete
Attempts to invoke force delete, if it fails - falls back to soft delete
Stars: ✭ 16 (-95.7%)
Mutual labels:  safe
Yzsbaseactivity
BaseActivity的框架,各种方便使用,欢迎star,给你惊喜
Stars: ✭ 287 (-22.85%)
Mutual labels:  base
safe-marked
Markdown to HTML using marked and DOMPurify. Safe by default.
Stars: ✭ 31 (-91.67%)
Mutual labels:  safe
algorithm-base
一位酷爱做饭的程序员,立志用动画将算法说的通俗易懂。我的面试网站 www.chengxuchu.com
Stars: ✭ 9,824 (+2540.86%)
Mutual labels:  base
elixir-ms
an elixir microservice base/skeleton 💀
Stars: ✭ 39 (-89.52%)
Mutual labels:  base
parquet2
Fastest and safest Rust implementation of parquet. `unsafe` free. Integration-tested against pyarrow
Stars: ✭ 157 (-57.8%)
Mutual labels:  safe
BlueSkyTv
简单的安卓TV 超纯净
Stars: ✭ 17 (-95.43%)
Mutual labels:  base
safe-typeorm
TypeORM helper library enhancing safety in the compilation level
Stars: ✭ 160 (-56.99%)
Mutual labels:  safe
xtra
🎭 A tiny actor framework
Stars: ✭ 111 (-70.16%)
Mutual labels:  safe
ArrayInterface.jl
Designs for new Base array interface primitives, used widely through scientific machine learning (SciML) and other organizations
Stars: ✭ 111 (-70.16%)
Mutual labels:  base
nodejs express template
🐼 source dummy Nodejs
Stars: ✭ 13 (-96.51%)
Mutual labels:  base
Safe Buffer
Safer Node.js Buffer API
Stars: ✭ 302 (-18.82%)
Mutual labels:  safe
Safe Dojo
An introductory dojo to learn how to develop full stack web applications in F#
Stars: ✭ 274 (-26.34%)
Mutual labels:  safe
HackTheBox-Writeups
No description or website provided.
Stars: ✭ 94 (-74.73%)
Mutual labels:  safe

Protolude

Build Status Build Status Build Status Build Status Hackage

A sensible starting Prelude for building custom Preludes.

Design points:

  • Banishes String.
  • Banishes partial functions.
  • Compiler warning on bottoms.
  • Polymorphic string IO functions.
  • Polymorphic show.
  • Automatic string conversions.
  • Types for common data structures in scope.
  • Types for all common string types (Text/ByteString) in scope.
  • Banishes impure exception throwing outside of IO.
  • StateT/ReaderT/ExceptT transformers in scope by default.
  • Foldable / Traversable functions in scope by default.
  • Unsafe functions are prefixed with "unsafe" in separate module.
  • Compiler agnostic, GHC internal modules are abstracted out into Base.
  • sum and product are strict by default.
  • Includes Semiring for GHC >= 7.6.
  • Includes Bifunctor for GHC >= 7.6.
  • Includes Semigroup for GHC >= 7.6.

Supports:

  • GHC 7.6.1
  • GHC 7.6.2
  • GHC 7.6.3
  • GHC 7.8.1
  • GHC 7.8.2
  • GHC 7.8.3
  • GHC 7.8.4
  • GHC 7.10.1
  • GHC 7.10.2
  • GHC 7.10.3
  • GHC 8.0.1
  • GHC 8.0.2
  • GHC 8.2.1
  • GHC 8.4.1
  • GHC 8.6.1
  • GHC 8.8.1
  • GHC 8.10.1

Stack LTS:

  • lts-4.x
  • lts-5.x
  • lts-6.x
  • lts-7.x
  • lts-8.x
  • lts-9.x
  • lts-10.x
  • lts-11.x
  • lts-12.x
  • lts-13.x
  • lts-14.x
  • lts-15.x
  • lts-16.x

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

  • My putStrLn and putStr instances are no longer inferred in the presense of the -XOverloadedStrings extension?

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 ()
  • How do I write manual Show instances if show isn't provided?

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.

  • Partial functions like undefined raise compiler warnings on usage.

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.

  • Why is id not in scope?

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

  • But what if I want the partial functions?

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].