summaryrefslogtreecommitdiff
path: root/Com/Simatime/Alpha.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-03-17 18:32:14 -0700
committerBen Sima <ben@bsima.me>2020-03-17 18:34:56 -0700
commite77e424fdbbc7b541a5542883f3d3559f9535340 (patch)
tree52af539b98a4bfcc334c188db22ef0cf73d9cf8b /Com/Simatime/Alpha.hs
parent70e534303c5cdc37ccc86d631573be6bb265857c (diff)
Add double fmap, switch "say" to Text, and autoformat
Diffstat (limited to 'Com/Simatime/Alpha.hs')
-rw-r--r--Com/Simatime/Alpha.hs23
1 files changed, 16 insertions, 7 deletions
diff --git a/Com/Simatime/Alpha.hs b/Com/Simatime/Alpha.hs
index 438b97a..16d21e3 100644
--- a/Com/Simatime/Alpha.hs
+++ b/Com/Simatime/Alpha.hs
@@ -1,24 +1,33 @@
{-# LANGUAGE NoImplicitPrelude #-}
-- | Commonly useful functions, a Prelude replacement.
-module Com.Simatime.Alpha (
+module Com.Simatime.Alpha
+ (
-- * Re-export Protolude
- module X
+ module X
-- * General functions
, (/@)
+ , (/@@)
-- * Debugging tools
, say
-- * TODO: remove this
, Prelude.read
- ) where
+ )
+where
+import Data.Text ( Text )
import qualified Prelude
-import Protolude as X
-import Data.String
+import Protolude as X
+import Data.String
-- | Debugging printf
-say :: String -> IO ()
+say :: Text -> IO ()
say msg = putStrLn msg
--- | Alias for map, fmap, <$>
+-- | Alias for map, fmap, <$>. Inspired by Mathematica.
(/@) :: Functor f => (a -> b) -> f a -> f b
(/@) = fmap
+
+-- | Double fmap.
+-- (/@@) :: (Functor f1, Functor f2) => f1 (a -> b) -> f1 (f2 a) -> f1 (f2 b)
+(/@@) :: (Functor f0, Functor f1) => (a -> b) -> f0 (f1 a) -> f0 (f1 b)
+(/@@) = fmap . fmap