incipit-core (empty) → 0.1.0.0
raw patch · 7 files changed
+290/−0 lines, 7 filesdep +basedep +incipit-basedep +polysemysetup-changed
Dependencies added: base, incipit-base, polysemy
Files
- LICENSE +34/−0
- Setup.hs +2/−0
- changelog.md +0/−0
- incipit-core.cabal +120/−0
- lib/Incipit.hs +71/−0
- lib/Prelude.hs +5/−0
- readme.md +58/−0
+ LICENSE view
@@ -0,0 +1,34 @@+Copyright (c) 2022 Torsten Schmits++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the+following conditions are met:++ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following+ disclaimer.+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided with the distribution.++Subject to the terms and conditions of this license, each copyright holder and contributor hereby grants to those+receiving rights under this license a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except+for failure to satisfy the conditions of this license) patent license to make, have made, use, offer to sell, sell,+import, and otherwise transfer this software, where such license applies only to those patent claims, already acquired+or hereafter acquired, licensable by such copyright holder or contributor that are necessarily infringed by:++ (a) their Contribution(s) (the licensed copyrights of copyright holders and non-copyrightable additions of+ contributors, in source or binary form) alone; or+ (b) combination of their Contribution(s) with the work of authorship to which such Contribution(s) was added by such+ copyright holder or contributor, if, at the time the Contribution is added, such addition causes such combination to+ be necessarily infringed. The patent license shall not apply to any other combinations which include the Contribution.++Except as expressly stated above, no rights or licenses from any copyright holder or contributor is granted under this+license, whether expressly, by implication, estoppel or otherwise.++DISCLAIMER++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ changelog.md view
+ incipit-core.cabal view
@@ -0,0 +1,120 @@+cabal-version: 2.2++-- This file has been generated from package.yaml by hpack version 0.34.6.+--+-- see: https://github.com/sol/hpack++name: incipit-core+version: 0.1.0.0+synopsis: A Prelude for Polysemy+description: See <https://hackage.haskell.org/package/incipit/docs/Prelude.html>+category: Prelude+homepage: https://github.com/tek/incipit#readme+bug-reports: https://github.com/tek/incipit/issues+author: Torsten Schmits+maintainer: haskell@tryp.io+copyright: 2022 Torsten Schmits+license: BSD-2-Clause-Patent+license-file: LICENSE+build-type: Simple+extra-source-files:+ readme.md+ changelog.md++source-repository head+ type: git+ location: https://github.com/tek/incipit++library+ exposed-modules:+ Incipit+ Prelude+ reexported-modules:+ Data.ByteString+ , Data.ByteString.Builder+ , Data.ByteString.Lazy+ , Data.ByteString.Short+ , Data.IntMap.Lazy+ , Data.IntMap.Strict+ , Data.IntSet+ , Data.Map.Lazy+ , Data.Map.Strict+ , Data.Sequence+ , Data.Set+ , Data.Text+ , Data.Text.IO+ , Data.Text.Lazy+ , Data.Text.Lazy.IO+ , Data.Text.Read+ , Data.Tree+ hs-source-dirs:+ lib+ default-extensions:+ AllowAmbiguousTypes+ ApplicativeDo+ BangPatterns+ BinaryLiterals+ BlockArguments+ ConstraintKinds+ DataKinds+ DefaultSignatures+ DeriveAnyClass+ DeriveDataTypeable+ DeriveFoldable+ DeriveFunctor+ DeriveGeneric+ DeriveTraversable+ DerivingStrategies+ DerivingVia+ DisambiguateRecordFields+ DoAndIfThenElse+ DuplicateRecordFields+ EmptyDataDecls+ ExistentialQuantification+ FlexibleContexts+ FlexibleInstances+ FunctionalDependencies+ GADTs+ GeneralizedNewtypeDeriving+ InstanceSigs+ KindSignatures+ LambdaCase+ LiberalTypeSynonyms+ MultiParamTypeClasses+ MultiWayIf+ NamedFieldPuns+ NoImplicitPrelude+ OverloadedStrings+ OverloadedLists+ PackageImports+ PartialTypeSignatures+ PatternGuards+ PatternSynonyms+ PolyKinds+ QuantifiedConstraints+ QuasiQuotes+ RankNTypes+ RecordWildCards+ RecursiveDo+ ScopedTypeVariables+ StandaloneDeriving+ TemplateHaskell+ TupleSections+ TypeApplications+ TypeFamilies+ TypeFamilyDependencies+ TypeOperators+ TypeSynonymInstances+ UndecidableInstances+ UnicodeSyntax+ ViewPatterns+ ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wmissing-deriving-strategies -Widentities+ build-depends:+ base ==4.*+ , incipit-base+ , polysemy >=1.6+ mixins:+ base hiding (Prelude)+ if impl(ghc >= 8.10)+ ghc-options: -Wunused-packages+ default-language: Haskell2010
+ lib/Incipit.hs view
@@ -0,0 +1,71 @@+-- |This is the central module on which to build upon when constructing Preludes for Polysemy libraries.+-- It reexports most core effects.+module Incipit (+ module Incipit.Prelude,+ module Polysemy,+ module Polysemy.Async,+ module Polysemy.AtomicState,+ module Polysemy.Error,+ module Polysemy.Fail,+ module Polysemy.Input,+ module Polysemy.Output,+ module Polysemy.Reader,+ module Polysemy.Resource,+ module Polysemy.State,+ module Polysemy.Tagged,+ module Polysemy.Writer,+ module Incipit,+ send,+) where++import qualified Control.Exception as Base+import Control.Exception (SomeException)+import Polysemy+import Polysemy.Async+import Polysemy.AtomicState+import Polysemy.Error+import Polysemy.Fail+import Polysemy.Input+import Polysemy.Internal (send)+import Polysemy.Internal.Kind (Append)+import Polysemy.Output+import Polysemy.Reader+import Polysemy.Resource+import Polysemy.State+import Polysemy.Tagged+import Polysemy.Writer++import Incipit.Prelude++-- |Run an 'IO' via 'Embed' and catch all exceptions, returning 'Either'.+tryAny ::+ Member (Embed IO) r =>+ IO a ->+ Sem r (Either Text a)+tryAny =+ embed @IO . fmap (first show) . Base.try @SomeException+{-# inline tryAny #-}++-- |Run an 'IO' via 'Embed' and catch all exceptions, returning 'Maybe'.+tryMaybe ::+ Member (Embed IO) r =>+ IO a ->+ Sem r (Maybe a)+tryMaybe =+ embed @IO . fmap rightToMaybe . Base.try @SomeException+{-# inline tryMaybe #-}++-- |Run an 'IO' via 'Embed' and catch and ignore all exceptions.+ignoreException ::+ Member (Embed IO) r =>+ IO () ->+ Sem r ()+ignoreException =+ void . embed @IO . Base.try @SomeException+{-# inline ignoreException #-}++-- |Convenience type alias for concatenating two effect rows.+type a ++ b =+ Append a b++infixr 5 ++
+ lib/Prelude.hs view
@@ -0,0 +1,5 @@+module Prelude (+ module Incipit+) where++import Incipit
+ readme.md view
@@ -0,0 +1,58 @@+This library provides a `Prelude` for [Polysemy] libraries, building upon [incipit-base] and exporting most of+Polysemy's core modules.+For a more comprehensive variant that includes some basic libraries, consider [incipit].+# Usage++`incipit-core` exports `Prelude`, so in order to use it you only have to hide `Prelude` from `base`:++For `hpack`:+```yaml+dependencies:+ - name: base+ version: '>= 4 && < 5'+ mixin:+ - hiding (Prelude)+ - incipit-core >= 0.1+```++For `cabal`:+```cabal+build-depends:+ base >=4 && <5, incipit-core >= 0.1+mixins:+ base hiding (Prelude)+```++# Custom Prelude++In order to extend `incipit-core` with a local `Prelude`, the module `Incipit` has to be reexported and `incipit-core`'s+`Prelude` needs to be hidden:++```yaml+dependencies:+ - name: base+ version: '>= 4 && < 5'+ mixin:+ - hiding (Prelude)+ - name: incipit-core+ version: >= 0.1+ mixin:+ - hiding (Prelude)+```++```haskell+module Prelude (+ module Prelude,+ module Incipit,+) where++import Incipit++projectName :: Text+projectName =+ "spaceship"+```++[incipit-base]: https://hackage.haskell.org/package/incipit-base+[incipit]: https://hackage.haskell.org/package/incipit+[Polysemy]: https://hackage.haskell.org/package/polysemy