summaryrefslogtreecommitdiff
path: root/Com/Simatime
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-04-12 12:15:49 -0700
committerBen Sima <ben@bsima.me>2020-04-12 19:01:15 -0700
commit46a680f7ca7def264a0f0b616883fb8e47271bab (patch)
tree92020970623359e6dc76f02d7c537c846c1d4ed9 /Com/Simatime
parent72e42deeb5d5b9cd2765d2ff20a06e708f8efc07 (diff)
De-namespace Alpha
A bunch of formatting changes got in there too. Oops. I will probably eventually de-namespace everything, mostly because I'm tired of typing "Com.Whatever.Thing" all the time. A better namespacing strategy might be to use normal Haskell namespacing (Data, Control, Network, etc) for code that is not specific to biz activities (i.e. if I could open-source it at any time), and use simply "Biz" for stuff that I would never want to open-source.
Diffstat (limited to 'Com/Simatime')
-rw-r--r--Com/Simatime/Alpha.hs83
-rw-r--r--Com/Simatime/Go.hs2
2 files changed, 1 insertions, 84 deletions
diff --git a/Com/Simatime/Alpha.hs b/Com/Simatime/Alpha.hs
deleted file mode 100644
index 7003cc5..0000000
--- a/Com/Simatime/Alpha.hs
+++ /dev/null
@@ -1,83 +0,0 @@
-{-# LANGUAGE NoImplicitPrelude #-}
--- | Commonly useful functions, a Prelude replacement.
-module Com.Simatime.Alpha
- (
- -- * Re-export Protolude
- module X
- -- * Applying
- , (<|)
- , (|>)
- -- * Mapping
- , (/>)
- , (</)
- , (<//)
- -- * Text
- , chomp
- , lchomp
- , joinWith
- -- * Debugging tools
- , say
- -- * TODO: remove this
- , Prelude.read
- )
-where
-
-import Data.Function ( (&) )
-import Data.Functor ( (<&>) )
-import Data.String
-import Data.Text ( Text )
-import qualified Data.Text as Text
-import qualified Data.Text.Lazy as LazyText
-import qualified Prelude
-import Protolude as X
-
--- | Debugging printf
-say :: Text -> IO ()
-say msg = putStrLn msg
-
--- $operators
---
--- Operators have a pattern to their characters
---
--- `|` normal function-level applications
--- `/` indicates doing something inside a functor
--- `<` and `>` indicate the direction in which values flow btw functions
-
--- | Alias for map, fmap, <$>
-(</) :: Functor f => (a -> b) -> f a -> f b
-(</) = fmap
-
--- | Double fmap. A function on the left goes "into" two functors
--- (i.e. it goes "two levels deep"), applies the function to the inner
--- values, then returns the result wrapped in the two functors.
-(<//) :: (Functor f0, Functor f1) => (a -> b) -> f0 (f1 a) -> f0 (f1 b)
-(<//) = fmap . fmap
-
--- | Normal function application. Do the right side, then pass the
--- return value to the function on the left side.
-(<|) :: (a -> b) -> a -> b
-(<|) = ($)
-infixr 0 <|
-
--- | Reverse function application. Do the left side, then pass the
--- return value to the function on the right side.
-(|>) :: a -> (a -> b) -> b
-(|>) = (&)
-
--- | Alias for <&>. Can be read as "and then". Basically does into a
--- functor, does some computation, then returns the same kind of
--- functor. Could also be defined as `f >>= return . g`
-(/>) :: Functor f => f a -> (a -> b) -> f b
-(/>) = (<&>)
-
--- | Removes newlines from text.
-chomp :: Text -> Text
-chomp = Text.filter (/= '\n')
-
--- | Removes newlines from lazy text.
-lchomp :: LazyText.Text -> LazyText.Text
-lchomp = LazyText.filter (/= '\n')
-
--- | Join a list of things with a separator.
-joinWith :: [a] -> [[a]] -> [a]
-joinWith = intercalate
diff --git a/Com/Simatime/Go.hs b/Com/Simatime/Go.hs
index 9ea2896..01555f3 100644
--- a/Com/Simatime/Go.hs
+++ b/Com/Simatime/Go.hs
@@ -22,7 +22,7 @@ module Com.Simatime.Go
)
where
-import Com.Simatime.Alpha hiding ( read )
+import Alpha hiding ( read )
import qualified Control.Concurrent as Concurrent
import qualified Control.Concurrent.Chan.Unagi.Bounded
as Chan