tonalude (empty) → 0.1.0.0
raw patch · 15 files changed
+552/−0 lines, 15 filesdep +Globdep +basedep +bytestringsetup-changed
Dependencies added: Glob, base, bytestring, doctest, rio
Files
- LICENSE +21/−0
- README.md +11/−0
- Setup.hs +2/−0
- src/Tonalude.hs +17/−0
- src/Tonalude/Extra.hs +7/−0
- src/Tonalude/Prelude/Display.hs +17/−0
- src/Tonalude/Prelude/IO.hs +51/−0
- src/Tonalude/Prelude/RIO.hs +5/−0
- src/Tonalude/Prelude/Reexports.hs +227/−0
- src/Tonalude/Prelude/Renames.hs +12/−0
- src/Tonalude/Prelude/Text.hs +6/−0
- src/Tonalude/Prelude/Trace.hs +34/−0
- test/DocTest.hs +58/−0
- test/Spec.hs +8/−0
- tonalude.cabal +76/−0
+ LICENSE view
@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2018 Kadzuya Okamoto https://arow.info++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.
+ README.md view
@@ -0,0 +1,11 @@+# The tonalude library++A standard library for Tonatona framework.++## Prelude replacement for Tonatona framework++The Tonalude module works as a prelude replacement for [Tonatona framework](https://github.com/tonatona-project/tonatona), providing more functionality and types out of the box than the standard prelude (such as common data types like ByteString and Text), as well as removing common "gotchas", like partial functions and lazy I/O.+Most of the functions and types are imported from [rio](https://github.com/commercialhaskell/rio), but Tonalude customizes them to be more suitable for using with Tonatona.++The goal of Tonalude is not to be a **general** alternative to Prelude,+but to be a Prelude alternative **only for Tonatona**.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Tonalude.hs view
@@ -0,0 +1,17 @@+module Tonalude+ ( module Tonalude.Prelude.Display+ , module Tonalude.Prelude.IO+ , module Tonalude.Prelude.RIO+ , module Tonalude.Prelude.Text+ , module Tonalude.Prelude.Reexports+ , module Tonalude.Prelude.Renames+ , module Tonalude.Prelude.Trace+ ) where++import Tonalude.Prelude.Display+import Tonalude.Prelude.IO+import Tonalude.Prelude.RIO+import Tonalude.Prelude.Reexports+import Tonalude.Prelude.Renames+import Tonalude.Prelude.Text+import Tonalude.Prelude.Trace
+ src/Tonalude/Extra.hs view
@@ -0,0 +1,7 @@+module Tonalude.Extra+ ( -- * For creating original plugins+ runRIO+ , liftRIO+ ) where++import RIO
+ src/Tonalude/Prelude/Display.hs view
@@ -0,0 +1,17 @@+module Tonalude.Prelude.Display+ ( Utf8Builder (..)+ , Display (..)+ , displayShow+ , utf8BuilderToText+ , utf8BuilderToLazyText+ , displayBytesUtf8+ , Tonalude.Prelude.Display.writeFileUtf8Builder+ ) where++import RIO+++{- | Write the given Utf8Builder value to a file.+-}+writeFileUtf8Builder :: FilePath -> Utf8Builder -> RIO env ()+writeFileUtf8Builder = RIO.writeFileUtf8Builder
+ src/Tonalude/Prelude/IO.hs view
@@ -0,0 +1,51 @@+module Tonalude.Prelude.IO+ ( withLazyFile+ , readFileBinary+ , writeFileBinary+ , readFileUtf8+ , writeFileUtf8+ , hPutBuilder+ ) where++import RIO hiding+ ( withLazyFile+ , readFileBinary+ , writeFileBinary+ , readFileUtf8+ , writeFileUtf8+ , hPutBuilder+ )+import qualified RIO++import qualified Data.ByteString as B ()+import qualified Data.ByteString.Lazy as BL++-- | Lazily get the contents of a file. Unlike 'BL.readFile', this+-- ensures that if an exception is thrown, the file handle is closed+-- immediately.+withLazyFile :: FilePath -> (BL.ByteString -> RIO env a) -> RIO env a+withLazyFile = RIO.withLazyFile++-- | Write a file in UTF8 encoding+--+-- This function will use OS-specific line ending handling.+writeFileUtf8 :: FilePath -> Text -> RIO env ()+writeFileUtf8 = RIO.writeFileUtf8++hPutBuilder :: Handle -> Builder -> RIO env ()+hPutBuilder = RIO.hPutBuilder++-- | Same as 'B.readFile', but focused on 'RIO'+readFileBinary :: FilePath -> RIO env ByteString+readFileBinary = RIO.readFileBinary++-- | Same as 'B.writeFile', but focused on 'RIO'+writeFileBinary :: FilePath -> ByteString -> RIO env ()+writeFileBinary = RIO.writeFileBinary++-- | Read a file in UTF8 encoding, throwing an exception on invalid character+-- encoding.+--+-- This function will use OS-specific line ending handling.+readFileUtf8 :: FilePath -> RIO env Text+readFileUtf8 = RIO.readFileUtf8
+ src/Tonalude/Prelude/RIO.hs view
@@ -0,0 +1,5 @@+module Tonalude.Prelude.RIO+ ( RIO (..)+ ) where++import RIO
+ src/Tonalude/Prelude/Reexports.hs view
@@ -0,0 +1,227 @@+{-# LANGUAGE CPP #-}++module Tonalude.Prelude.Reexports+ ( Alternative+ , Applicative (..)+ , liftA+#if !MIN_VERSION_base(4, 10, 0)+ , liftA2+#endif+ , liftA3+ , many+ , optional+ , some+ , (<|>)+ , first+ , second+ , (&&&)+ , (***)+ , (>>>)+ , NFData(..)+ , force+ , ($!!)+ , Monad(..)+ , MonadPlus(..)+ , filterM+ , foldM+ , foldM_+ , forever+ , guard+ , join+ , liftM+ , liftM2+ , replicateM_+ , unless+ , when+ , zipWithM+ , zipWithM_+ , (<$!>)+ , (<=<)+ , (=<<)+ , (>=>)+ , MonadIO(..)+ , MonadThrow(..)+ , MonadReader+ , MonadTrans(..)+ , Reader+ , ReaderT(..)+ , ask+ , asks+ , local+ , runReader+ , Bool(..)+ , bool+ , not+ , otherwise+ , (&&)+ , (||)+ , ByteString+ , Builder+ , ShortByteString+ , toShort+ , fromShort+ , Char+ , Data(..)+ , Either(..)+ , either+ , isLeft+ , isRight+ , lefts+ , partitionEithers+ , rights+ , Eq(..)+ , Foldable+ , all+ , and+ , any+ , asum+ , concat+ , concatMap+ , elem+ , fold+ , foldMap+ , foldl'+ , foldr+ , forM_+ , for_+ , length+ , mapM_+ , msum+ , notElem+ , null+ , or+ , product+ , sequenceA_+ , sequence_+ , sum+ , toList+ , traverse_+ , const+ , fix+ , flip+ , id+ , on+ , ($)+ , (&)+ , (.)+ , Functor(..)+ , void+ , ($>)+ , (<$>)+ , (<&>)+ , Const(..)+ , Identity(..)+ , Hashable+ , HashMap+ , HashSet+ , Int+ , Int8+ , Int16+ , Int32+ , Int64+ , IntMap+ , IntSet+ , break+ , drop+ , dropWhile+ , filter+ , lines+ , lookup+ , map+ , replicate+ , reverse+ , span+ , take+ , takeWhile+ , unlines+ , unwords+ , words+ , zip+ , (++)+ , Map+ , Maybe(..)+ , catMaybes+ , fromMaybe+ , isJust+ , isNothing+ , listToMaybe+ , mapMaybe+ , maybe+ , maybeToList+ , Monoid (..)+ , Ord(..)+ , Ordering(..)+ , comparing+ , Proxy(..)+ , Semigroup (..)+ , Set+ , IsString(..)+ , Text+ , decodeUtf8'+ , decodeUtf8With+ , encodeUtf8+ , encodeUtf8Builder+ , UnicodeException(..)+ , lenientDecode+ , Traversable(..)+ , for+ , forM+ , Vector+ , Void+ , absurd+ , Word+ , Word8+ , Word16+ , Word32+ , Word64+ , byteSwap16+ , byteSwap32+ , byteSwap64+ , Storable+ , Generic+ , Natural+ , Bounded (..)+ , Double+ , Enum+ , FilePath+ , Float+ , Floating (..)+ , Fractional (..)+ , IO+ , Integer+ , Integral (..)+ , Num (..)+ , Rational+ , Real (..)+ , RealFloat (..)+ , RealFrac (..)+ , Show+ , String+ , asTypeOf+ , curry+ , error+ , even+ , fromEnum+ , fromIntegral+ , fst+ , gcd+ , lcm+ , odd+ , realToFrac+ , seq+ , show+ , snd+ , subtract+ , uncurry+ , undefined+ , ($!)+ , (^)+ , (^^)+ , ExitCode(..)+ , Read+ , readMaybe+ -- * Unbox+ , Unbox+ ) where++import RIO
+ src/Tonalude/Prelude/Renames.hs view
@@ -0,0 +1,12 @@+module Tonalude.Prelude.Renames+ ( sappend+ , LByteString+ , LText+ , UVector+ , SVector+ , GVector+ , toStrictBytes+ , fromStrictBytes+ ) where++import RIO
+ src/Tonalude/Prelude/Text.hs view
@@ -0,0 +1,6 @@+module Tonalude.Prelude.Text+ ( decodeUtf8Lenient+ , tshow+) where++import RIO
+ src/Tonalude/Prelude/Trace.hs view
@@ -0,0 +1,34 @@+module Tonalude.Prelude.Trace+ ( -- * Text+ trace+ , traceId+ , traceIO+ , traceM+ , traceEvent+ , traceEventIO+ , traceMarker+ , traceMarkerIO+ , traceStack+ -- * Show+ , traceShow+ , traceShowId+ , traceShowIO+ , traceShowM+ , traceShowEvent+ , traceShowEventIO+ , traceShowMarker+ , traceShowMarkerIO+ , traceShowStack+ -- * Display+ , traceDisplay+ , traceDisplayId+ , traceDisplayIO+ , traceDisplayM+ , traceDisplayEvent+ , traceDisplayEventIO+ , traceDisplayMarker+ , traceDisplayMarkerIO+ , traceDisplayStack+ ) where++import RIO
+ test/DocTest.hs view
@@ -0,0 +1,58 @@+module Main (main) where++import RIO++import System.FilePath.Glob (glob)+import Test.DocTest (doctest)++main :: IO ()+main = glob "src/**/*.hs" >>= doDocTest++doDocTest :: [String] -> IO ()+doDocTest options =+ doctest $+ options <>+ ghcExtensions++ghcExtensions :: [String]+ghcExtensions =+ [ "-XAutoDeriveTypeable"+ , "-XBangPatterns"+ , "-XBinaryLiterals"+ , "-XConstraintKinds"+ , "-XDataKinds"+ , "-XDefaultSignatures"+ , "-XDeriveDataTypeable"+ , "-XDeriveFoldable"+ , "-XDeriveFunctor"+ , "-XDeriveGeneric"+ , "-XDeriveTraversable"+ , "-XDoAndIfThenElse"+ , "-XEmptyDataDecls"+ , "-XExistentialQuantification"+ , "-XFlexibleContexts"+ , "-XFlexibleInstances"+ , "-XFunctionalDependencies"+ , "-XGADTs"+ , "-XGeneralizedNewtypeDeriving"+ , "-XInstanceSigs"+ , "-XKindSignatures"+ , "-XLambdaCase"+ , "-XMonadFailDesugaring"+ , "-XMultiParamTypeClasses"+ , "-XMultiWayIf"+ , "-XNamedFieldPuns"+ , "-XNoImplicitPrelude"+ , "-XOverloadedStrings"+ , "-XPartialTypeSignatures"+ , "-XPatternGuards"+ , "-XPolyKinds"+ , "-XRankNTypes"+ , "-XRecordWildCards"+ , "-XScopedTypeVariables"+ , "-XStandaloneDeriving"+ , "-XTupleSections"+ , "-XTypeFamilies"+ , "-XTypeSynonymInstances"+ , "-XViewPatterns"+ ]
+ test/Spec.hs view
@@ -0,0 +1,8 @@+{-# LANGUAGE QuasiQuotes #-}++module Main where++import RIO++main :: IO ()+main = pure ()
+ tonalude.cabal view
@@ -0,0 +1,76 @@+-- This file has been generated from package.yaml by hpack version 0.28.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 09fe4ab2552db6fbcfb1673c770b13b11107214fe1689bc31305c93509968241++name: tonalude+version: 0.1.0.0+synopsis: A standard library for Tonatona framework.+description: Tonaparser provides a way to pass runtime configurations. This library is supposed to be used with @tonatona@. The Tonalude module works as a prelude replacement for Tonatona framework, providing more functionality and types out of the box than the standard prelude (such as common data types like ByteString and Text), as well as removing common "gotchas", like partial functions and lazy I/O.+category: Control, Library, Tonatona+homepage: https://github.com/tonatona-project/tonatona#readme+bug-reports: https://github.com/tonatona-project/tonatona/issues+author: Kadzuya Okamoto+maintainer: arow.okamoto+github@gmail.com+copyright: 2018 Kadzuya Okamoto+license: MIT+license-file: LICENSE+build-type: Simple+cabal-version: >= 1.10+extra-source-files:+ README.md++source-repository head+ type: git+ location: https://github.com/tonatona-project/tonatona++library+ exposed-modules:+ Tonalude+ Tonalude.Extra+ other-modules:+ Tonalude.Prelude.Display+ Tonalude.Prelude.IO+ Tonalude.Prelude.Reexports+ Tonalude.Prelude.Renames+ Tonalude.Prelude.RIO+ Tonalude.Prelude.Text+ Tonalude.Prelude.Trace+ hs-source-dirs:+ src+ default-extensions: AutoDeriveTypeable BangPatterns BinaryLiterals ConstraintKinds DataKinds DefaultSignatures DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DoAndIfThenElse EmptyDataDecls ExistentialQuantification FlexibleContexts FlexibleInstances FunctionalDependencies GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MonadFailDesugaring MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PartialTypeSignatures PatternGuards PolyKinds RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TupleSections TypeFamilies TypeSynonymInstances ViewPatterns+ ghc-options: -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints+ build-depends:+ base >=4.7 && <5+ , bytestring >=0.10+ , rio >=0.1.5+ default-language: Haskell2010++test-suite doctest+ type: exitcode-stdio-1.0+ main-is: DocTest.hs+ hs-source-dirs:+ test+ default-extensions: AutoDeriveTypeable BangPatterns BinaryLiterals ConstraintKinds DataKinds DefaultSignatures DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DoAndIfThenElse EmptyDataDecls ExistentialQuantification FlexibleContexts FlexibleInstances FunctionalDependencies GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MonadFailDesugaring MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PartialTypeSignatures PatternGuards PolyKinds RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TupleSections TypeFamilies TypeSynonymInstances ViewPatterns+ ghc-options: -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints+ build-depends:+ Glob+ , base >=4.7 && <5+ , bytestring >=0.10+ , doctest+ , rio >=0.1.5+ default-language: Haskell2010++test-suite spec+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ hs-source-dirs:+ test+ default-extensions: AutoDeriveTypeable BangPatterns BinaryLiterals ConstraintKinds DataKinds DefaultSignatures DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DoAndIfThenElse EmptyDataDecls ExistentialQuantification FlexibleContexts FlexibleInstances FunctionalDependencies GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MonadFailDesugaring MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude OverloadedStrings PartialTypeSignatures PatternGuards PolyKinds RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TupleSections TypeFamilies TypeSynonymInstances ViewPatterns+ ghc-options: -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints+ build-depends:+ base >=4.7 && <5+ , bytestring >=0.10+ , rio >=0.1.5+ default-language: Haskell2010