summaryrefslogtreecommitdiff
path: root/Com/Simatime
diff options
context:
space:
mode:
Diffstat (limited to 'Com/Simatime')
-rw-r--r--Com/Simatime/Alpha.hs13
-rw-r--r--Com/Simatime/Go.hs5
2 files changed, 18 insertions, 0 deletions
diff --git a/Com/Simatime/Alpha.hs b/Com/Simatime/Alpha.hs
index 8f5a506..cc3d23c 100644
--- a/Com/Simatime/Alpha.hs
+++ b/Com/Simatime/Alpha.hs
@@ -11,6 +11,9 @@ module Com.Simatime.Alpha
, (/>)
, (</)
, (<//)
+ -- * Text
+ , chomp
+ , lchomp
-- * Debugging tools
, say
-- * TODO: remove this
@@ -22,6 +25,8 @@ 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
@@ -63,3 +68,11 @@ infixr 0 <|
-- 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')
diff --git a/Com/Simatime/Go.hs b/Com/Simatime/Go.hs
index bd9296a..e622539 100644
--- a/Com/Simatime/Go.hs
+++ b/Com/Simatime/Go.hs
@@ -7,6 +7,7 @@ Golang and Clojure's core.async.
$example
-}
{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE OverloadedStrings #-}
module Com.Simatime.Go
(
-- * Running and forking
@@ -25,6 +26,7 @@ import Com.Simatime.Alpha hiding ( read )
import qualified Control.Concurrent as Concurrent
import qualified Control.Concurrent.Chan.Unagi.Bounded
as Chan
+import qualified Data.Aeson as Aeson
-- | A standard channel.
data Channel a = Channel
@@ -33,6 +35,9 @@ data Channel a = Channel
, _size :: Int
}
+instance Aeson.ToJSON (Channel a) where
+ toJSON _ = Aeson.String ("#<channel>" :: Text)
+
-- | Starts a background process.
fork :: IO () -> IO Concurrent.ThreadId
fork = Concurrent.forkIO