Squashed commit of the following:

commit a6f62265f345c8b7a7226515171752586b0d66e5
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 13:41:05 2016 -0400

    bump version

commit 1a809623cd1484ce215612e6b3ecef15015bc602
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 13:26:11 2016 -0400

    masking for ghc 8.0 specific type

commit 54bafb0bb80c8450863eac53a1f3a20a21c8b0c9
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 12:55:08 2016 -0400

    bump ghc-prim for GHC 8.0 compat

commit 8808d5f37369107b3e5961255089a8a9e02bf3d5
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 12:53:39 2016 -0400

    expose base State transformers

commit 05c32a4542aa66f715aea3855e140f74e97d4852
Author: Stephen Diehl <stephen.m.diehl@gmail.com>
Date:   Wed Apr 13 12:46:00 2016 -0400

    adds compiler-independent base module
This commit is contained in:
Stephen Diehl
2016-04-13 13:51:47 -04:00
parent 99427e741c
commit 5388b8cd4b
7 changed files with 136 additions and 80 deletions
+6 -2
View File
@@ -1,5 +1,5 @@
name: protolude name: protolude
version: 0.1.1 version: 0.1.2
synopsis: A sensible set of defaults for writing custom Preludes. synopsis: A sensible set of defaults for writing custom Preludes.
description: A sensible set of defaults for writing custom Preludes. description: A sensible set of defaults for writing custom Preludes.
homepage: https://github.com/sdiehl/protolude homepage: https://github.com/sdiehl/protolude
@@ -33,27 +33,31 @@ Source-Repository head
library library
exposed-modules: exposed-modules:
Protolude Protolude
Unsafe
other-modules: other-modules:
Base
Applicative Applicative
Bool Bool
Debug Debug
List List
Monad Monad
Show Show
Unsafe
Either Either
Functor Functor
Bifunctor Bifunctor
default-extensions: default-extensions:
NoImplicitPrelude NoImplicitPrelude
OverloadedStrings
MultiParamTypeClasses
ghc-options: ghc-options:
-Wall -Wall
build-depends: build-depends:
base >= 4.6 && <4.10, base >= 4.6 && <4.10,
ghc-prim >= 0.3 && <0.6,
safe >= 0.3 && <0.4, safe >= 0.3 && <0.4,
async >= 2.1 && <2.2, async >= 2.1 && <2.2,
deepseq >= 1.3 && <= 1.5, deepseq >= 1.3 && <= 1.5,
+3 -2
View File
@@ -7,9 +7,10 @@ module Applicative (
eitherA, eitherA,
) where ) where
import Data.Monoid import Data.Bool (Bool)
import Data.Either (Either(..))
import Data.Monoid (Monoid(..))
import Control.Applicative import Control.Applicative
import Prelude (Bool, Either(..))
orAlt :: (Alternative f, Monoid a) => f a -> f a orAlt :: (Alternative f, Monoid a) => f a -> f a
orAlt f = f <|> pure mempty orAlt f = f <|> pure mempty
+57
View File
@@ -0,0 +1,57 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Base (
module X,
($!),
) where
-- Glorious Glashgow Haskell Compiler
#if defined(__GLASGOW_HASKELL__) && ( __GLASGOW_HASKELL__ >= 600 )
-- Base GHC types
import GHC.Num as X
import GHC.Enum as X
import GHC.Real as X
import GHC.Float as X
import GHC.Show as X
import GHC.Exts as X (
Constraint
, Ptr
, FunPtr
, the
)
import GHC.Base as X (
(++)
, seq
, asTypeOf
)
import System.IO as X (
print
, putStr
, putStrLn
)
#if ( __GLASGOW_HASKELL__ >= 800 )
import GHC.Types as X hiding (Any)
#else
import GHC.Types as X
#endif
infixr 0 $!
($!) :: (a -> b) -> a -> b
f $! x = let !vx = x in f vx
#endif
-- Simple Haskell Compiler
#if defined(__SHC_HASKELL__)
import SHC.Prim as X
import SHC.Types as X
import SHC.Classes as X
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE Safe #-} {-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
module Monad ( module Monad (
@@ -39,8 +39,8 @@ module Monad (
, (<$!>) , (<$!>)
) where ) where
import Base (seq)
import Data.List (concat) import Data.List (concat)
import Prelude (seq)
#if (__GLASGOW_HASKELL__ >= 710) #if (__GLASGOW_HASKELL__ >= 710)
import Control.Monad hiding ((<$!>)) import Control.Monad hiding ((<$!>))
+27 -40
View File
@@ -1,13 +1,13 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Protolude ( module Protolude (
module X, module X,
module Base,
identity, identity,
bool,
(&), (&),
($!),
uncons, uncons,
applyN, applyN,
print, print,
@@ -16,16 +16,23 @@ module Protolude (
LByteString, LByteString,
) where ) where
import qualified Prelude as P {-import qualified Prelude as P-}
import qualified List as X import List as X
import qualified Show as X import Show as X
import qualified Bool as X import Bool as X
import qualified Debug as X import Debug as X
import qualified Monad as X import Monad as X
import qualified Functor as X import Functor as X
import qualified Either as X import Either as X
import qualified Applicative as X import Applicative as X
import Base as Base hiding (
putStr
, putStrLn
, print
)
import qualified Base as PBase
-- Maybe'ized version of partial functions -- Maybe'ized version of partial functions
import Safe as X ( import Safe as X (
@@ -88,7 +95,6 @@ import Control.DeepSeq as X (
-- Data structures -- Data structures
import Data.Tuple as X import Data.Tuple as X
import Data.Semiring as X
import Data.List as X ( import Data.List as X (
splitAt splitAt
, break , break
@@ -99,6 +105,8 @@ import Data.List as X (
, reverse , reverse
, replicate , replicate
, take , take
, zipWith
, zip
) )
import Data.Map as X (Map) import Data.Map as X (Map)
import Data.Set as X (Set) import Data.Set as X (Set)
@@ -117,6 +125,10 @@ import Control.Monad.State as X (
, modify , modify
, withState , withState
, runState
, execState
, evalState
, runStateT , runStateT
, execStateT , execStateT
, evalStateT , evalStateT
@@ -168,24 +180,6 @@ import Data.Function as X (
, on , on
) )
-- Base GHC types
import GHC.IO as X (IO)
import GHC.Num as X
import GHC.Enum as X
import GHC.Real as X
import GHC.Float as X
import GHC.Show as X
import GHC.Exts as X (
Constraint
, Ptr
, FunPtr
, the
)
import GHC.Base as X (
(++)
, seq
, asTypeOf
)
-- Genericss -- Genericss
import GHC.Generics ( import GHC.Generics (
@@ -225,6 +219,7 @@ import Data.String.Conv as X (
, toS , toS
, toSL , toSL
, Leniency(..) , Leniency(..)
, StringConv
) )
-- Printf -- Printf
@@ -270,14 +265,6 @@ infixl 1 &
(&) :: a -> (a -> b) -> b (&) :: a -> (a -> b) -> b
x & f = f x x & f = f x
infixr 0 $!
($!) :: (a -> b) -> a -> b
($!) = (P.$!)
bool :: a -> a -> Bool -> a
bool f t b = if b then t else f
identity :: a -> a identity :: a -> a
identity x = x identity x = x
@@ -288,5 +275,5 @@ uncons (x:xs) = Just (x, xs)
applyN :: Int -> (a -> a) -> a -> a applyN :: Int -> (a -> a) -> a -> a
applyN n f = X.foldr (.) identity (X.replicate n f) applyN n f = X.foldr (.) identity (X.replicate n f)
print :: (X.MonadIO m, P.Show a) => a -> m () print :: (X.MonadIO m, PBase.Show a) => a -> m ()
print = liftIO . P.print print = liftIO . PBase.print
+10 -8
View File
@@ -1,8 +1,9 @@
{-# LANGUAGE Safe #-} {-# LANGUAGE Trustworthy #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE ExtendedDefaultRules #-}
module Show ( module Show (
Print(..), Print(..),
@@ -10,8 +11,8 @@ module Show (
putLText, putLText,
) where ) where
import Prelude ((.), Char, IO) import qualified Base
import qualified Prelude import Data.Function ((.))
import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.IO.Class (MonadIO, liftIO)
import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Char8 as BS
@@ -23,6 +24,7 @@ import qualified Data.Text.IO as T
import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.IO as TL import qualified Data.Text.Lazy.IO as TL
class Print a where class Print a where
putStr :: MonadIO m => a -> m () putStr :: MonadIO m => a -> m ()
putStrLn :: MonadIO m => a -> m () putStrLn :: MonadIO m => a -> m ()
@@ -43,15 +45,15 @@ instance Print BL.ByteString where
putStr = liftIO . BL.putStr putStr = liftIO . BL.putStr
putStrLn = liftIO . BL.putStrLn putStrLn = liftIO . BL.putStrLn
instance Print [Char] where instance Print [Base.Char] where
putStr = liftIO . Prelude.putStr putStr = liftIO . Base.putStr
putStrLn = liftIO . Prelude.putStrLn putStrLn = liftIO . Base.putStrLn
-- For forcing type inference -- For forcing type inference
putText :: MonadIO m => T.Text -> m () putText :: MonadIO m => T.Text -> m ()
putText = putStrLn putText = putStrLn
{-# SPECIALIZE putText :: T.Text -> IO () #-} {-# SPECIALIZE putText :: T.Text -> Base.IO () #-}
putLText :: MonadIO m => TL.Text -> m () putLText :: MonadIO m => TL.Text -> m ()
putLText = putStrLn putLText = putStrLn
{-# SPECIALIZE putLText :: TL.Text -> IO () #-} {-# SPECIALIZE putLText :: TL.Text -> Base.IO () #-}
+20 -15
View File
@@ -1,28 +1,33 @@
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
module Unsafe where module Unsafe (
unsafeHead,
unsafeTail,
unsafeInit,
unsafeLast,
fromJust,
unsafeIndex,
) where
import qualified Prelude import Base (Int)
import qualified Data.Maybe import qualified Data.List as List
import qualified Data.List import qualified Data.Maybe as Maybe
unsafeHead :: [a] -> a unsafeHead :: [a] -> a
unsafeHead = Prelude.head unsafeHead = List.head
unsafeTail :: [a] -> [a] unsafeTail :: [a] -> [a]
unsafeTail = Prelude.tail unsafeTail = List.tail
unsafeInit :: [a] -> [a] unsafeInit :: [a] -> [a]
unsafeInit = Prelude.init unsafeInit = List.init
unsafeLast :: [a] -> a unsafeLast :: [a] -> a
unsafeLast = Prelude.last unsafeLast = List.last
fromJust :: Prelude.Maybe a -> a fromJust :: Maybe.Maybe a -> a
fromJust = Data.Maybe.fromJust fromJust = Maybe.fromJust
unsafeIndex :: [a] -> Prelude.Int -> a unsafeIndex :: [a] -> Int -> a
unsafeIndex = (Data.List.!!) unsafeIndex = (List.!!)
(!!) :: [a] -> Prelude.Int -> a
(!!) = (Data.List.!!)