interlude-l 0.1.0.1 → 0.1.0.2
raw patch · 2 files changed
+30/−10 lines, 2 filesdep +MonadRandomdep +monad-controldep +transformers
Dependencies added: MonadRandom, monad-control, transformers
Files
- interlude-l.cabal +5/−1
- src/Interlude.hs +25/−9
interlude-l.cabal view
@@ -1,5 +1,5 @@ name: interlude-l-version: 0.1.0.1+version: 0.1.0.2 synopsis: Prelude replacement based on protolude description: Prelude replacement based on protolude license: BSD3@@ -23,4 +23,8 @@ , lens == 4.13.* , aeson == 0.9.* , witherable == 0.1.*+ , transformers == 0.4.*+ , mtl == 2.2.*+ , monad-control+ , MonadRandom ghc-options: -Wall
src/Interlude.hs view
@@ -1,12 +1,16 @@-{-# LANGUAGE UndecidableInstances, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts #-} +{-# LANGUAGE UndecidableInstances, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts + , NoMonomorphismRestriction, OverloadedStrings #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} module Interlude ( module X, unsafeTail, unsafeHead, unsafeLast, unsafeInit - , PShow(..), perror ) where + , pshow, perror, pread, noWarnUndefined, perrorToFile ) where import qualified Prelude import Protolude as X hiding ( (&), catch, throw, try, (<.>), wait, error, filter, ordNub - , catMaybes, mapMaybe ) + , catMaybes, mapMaybe, handle, catches, Handler(..) ) import Prelude as X (error) -import Control.Monad.Catch as X (MonadThrow, MonadCatch, catch, throwM, try) +import Control.Monad.Catch as X ( MonadThrow, MonadCatch, catch, throwM, try, handle, catches + , Handler(..), handleIf, catchIf ) +import Control.Monad.Trans.Class as X import Control.Monad.State as X (modify') import Control.Lens.Operators as X import Control.Lens.TH as X @@ -18,6 +22,10 @@ import Data.Char as X import Data.Witherable as X import Data.String +import Control.Monad.Trans.Control as X (MonadBaseControl, MonadTransControl) +import Control.Monad.Random as X +import GHC.IO +import System.IO (writeFile) unsafeTail :: [a] -> [a] unsafeTail = Prelude.tail @@ -31,11 +39,19 @@ unsafeInit :: [a] -> [a] unsafeInit = Prelude.init -class Prelude.Show a => PShow a stringLike where - pshow :: a -> stringLike - -instance (Prelude.Show a, IsString stringLike) => PShow a stringLike where - pshow = fromString . show +pshow :: (Show a, IsString c) => a -> c +pshow = fromString . show perror :: StringConv stringLike String => stringLike -> a perror = error . toS + +pread :: (Read a, StringConv stringLike String) => stringLike -> a +pread = Prelude.read . toS + +noWarnUndefined :: a +noWarnUndefined = Prelude.undefined + +perrorToFile :: StringConv stringLike String => Text -> stringLike -> a +perrorToFile path err = unsafePerformIO $ do + writeFile (toS path) (toS err) + perror (take 100 (toS err :: String) <> "...REST OF ERROR IN " <> toS path)