summaryrefslogtreecommitdiff
path: root/src/Prolog.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Prolog.hs')
-rw-r--r--src/Prolog.hs166
1 files changed, 166 insertions, 0 deletions
diff --git a/src/Prolog.hs b/src/Prolog.hs
new file mode 100644
index 0000000..70545c9
--- /dev/null
+++ b/src/Prolog.hs
@@ -0,0 +1,166 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+module Prolog
+ (
+ -- * Modules
+ module Control.Applicative
+ , module Control.Monad
+ , module Control.Monad.Except
+ , module Control.Monad.Identity
+ , module Control.Monad.IO.Class
+ , module Control.Monad.Reader
+ , module Data.Bifunctor
+ , module Data.Bifoldable
+ , module Data.Bitraversable
+ , module Data.Bool
+ , module Data.Either
+ , module Data.Foldable
+ , module Data.Function
+ , module Data.Functor
+ , module Data.Functor.Contravariant
+ , module Data.Maybe
+ -- * Types
+ , Binary
+ , Generic
+ , Generically (..)
+ , MonadThrow (..)
+ , Exception (..)
+ , SomeException (..)
+ , B.StrictByteString
+ , BL.LazyByteString
+ , T.StrictText
+ , TL.LazyText
+ -- * Strings
+ , IsString (..)
+ , StringConv (..)
+ , toS
+ , toSL
+ , convS
+ , convSL
+ -- * Utils
+ , (<<$>>)
+ , (<<<$>>>)
+ , (<<&>>)
+ , (-->)
+ , (-/>)
+ , foreach
+ , liftMaybe
+ , squashMaybe
+ ) where
+
+import Control.Applicative
+import Control.Monad
+import Control.Monad.Catch
+import Control.Monad.Except
+import Control.Monad.Identity
+import Control.Monad.IO.Class
+import Control.Monad.Reader
+import Data.Bifunctor
+import Data.Bifoldable
+import Data.Binary
+import Data.Bitraversable
+import Data.Bool
+import Data.ByteString qualified as B
+import Data.ByteString.Lazy qualified as BL
+import Data.Either
+import Data.Foldable
+import Data.Function
+import Data.Functor
+import Data.Functor.Contravariant
+import Data.Maybe
+import Data.String
+import Data.String.Conv
+import Data.Text qualified as T
+import Data.Text.Lazy qualified as TL
+import GHC.Generics
+
+import Hakyll qualified as H
+import Text.Blaze.Html
+import Text.Blaze.Html.Renderer.Pretty as BS
+import Text.Blaze.Html.Renderer.Text as BT
+import Text.Blaze.Html.Renderer.Utf8 as BB
+import Text.LaTeX.Base qualified as L
+
+(<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
+infixl 4 <<$>>
+(<<$>>) = fmap fmap fmap
+{-# INLINE (<<$>>) #-}
+
+(<<<$>>>) :: (Functor f, Functor g, Functor h) => (a -> b) -> f (g (h a)) -> f (g (h b))
+infixl 4 <<<$>>>
+(<<<$>>>) = fmap . fmap . fmap
+{-# INLINE (<<<$>>>) #-}
+
+(<<&>>) :: (Functor f, Functor g) => f (g a) -> (a -> b) -> f (g b)
+infixl 1 <<&>>
+(<<&>>) = flip (<<$>>)
+{-# INLINE (<<&>>) #-}
+
+foreach :: Functor f => f a -> (a -> b) -> f b
+foreach = flip fmap
+{-# INLINE foreach #-}
+
+
+(-->) :: (Monad m, Monoid w) => m Bool -> m w -> m w
+infixr 0 -->
+b --> a = b >>= bool (pure mempty) a
+{-# INLINE (-->) #-}
+
+(-/>) :: (Monad m, Monoid w) => m Bool -> m w -> m w
+infixr 0 -/>
+(-/>) = (-->) . fmap not
+{-# INLINE (-/>) #-}
+
+liftMaybe :: Alternative m => Maybe a -> m a
+liftMaybe = maybe empty pure
+{-# INLINE liftMaybe #-}
+
+squashMaybe :: Alternative m => m (Maybe a) -> m a
+squashmaybe = (>>= liftMaybe)
+{-# INLINE squashMaybe #-}
+
+
+-- Orphan instances
+
+
+instance Binary L.MathType
+instance Binary L.Measure
+instance Binary L.TeXArg
+instance Binary L.LaTeX
+
+instance H.Writable L.LaTeX where
+ write p = L.renderFile p . H.itemBody
+
+
+instance Contravariant H.Context where
+ contramap f (H.Context c) = H.Context $ \x xs -> c x xs . fmap f
+
+
+instance StringConv L.LaTeX T.Text where
+ strConv _ = L.render
+
+instance StringConv L.LaTeX TL.Text where
+ strConv l = strConv l . L.render
+
+instance StringConv L.LaTeX B.ByteString where
+ strConv l = strConv l . L.render
+
+instance StringConv L.LaTeX BL.ByteString where
+ strConv l = strConv l . L.render
+
+instance StringConv L.LaTeX String where
+ strConv l = strConv l . L.render
+
+instance StringConv Html T.Text where
+ strConv _ = BT.renderHtml
+
+instance StringConv Html TL.Text where
+ strConv l = strConv l . BT.renderHtml
+
+instance StringConv Html String where
+ strConv _ = BS.renderHtml
+
+instance StringConv Html B.ByteString where
+ strConv l = strConv l . BB.renderHtml
+
+instance StringConv Html BL.ByteString where
+ strConv _ = BB.renderHtml