From 1c07b112aa8c721beadc0494972c18462a5946bf Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 27 Jan 2021 22:24:37 -0500 Subject: Set subscription in user page, operator precedence I'm still working on figuring out operator precedence with my custom operators. The normal precedences don't work well for writing code in a pipeline as I like, so I have to re-define the operators with my own fixity settings. This will take some fiddling to get right. The user subscription allows setting to "Free" only now. It's fine because I still need to do a design refresh on the pages I just made. One thing I noticed is that it's getting harder to make changes without breaking stuff, so I either need to make smaller incremental changes, or actually write some real tests. I'll probably write tests soon. --- Alpha.hs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'Alpha.hs') diff --git a/Alpha.hs b/Alpha.hs index 7da7161..7405103 100644 --- a/Alpha.hs +++ b/Alpha.hs @@ -41,6 +41,10 @@ module Alpha (>=), + -- * Bool don't, @@ -73,7 +77,8 @@ import Data.String import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Lazy as LazyText -import Protolude as X hiding (list, ($), (&), (.)) +import Protolude as X hiding (list, ($), (&), (.), (>>=)) +import qualified Prelude -- | Create a list. This should be @Data.List.singleton@ but that doesn't exist. list :: a -> [a] @@ -93,7 +98,7 @@ compose f g x = g (f x) (.>) :: (a -> b) -> (b -> c) -> (a -> c) f .> g = compose f g -infixl 9 .> +-- infixl 0 .> -- | Left-composition operator -- @@ -101,7 +106,7 @@ infixl 9 .> (<.) :: (b -> c) -> (a -> b) -> (a -> c) g <. f = compose f g -infixr 9 <. +-- infixr 0 <. -- | Alias for map, fmap, <$> -- @@ -109,6 +114,8 @@ infixr 9 <. ( (a -> b) -> f a -> f b f (a -> b) -> f0 (f1 a) -> f0 (f1 b) ( fmap +-- infixr 1 b) -> a -> b f <| g = f g -infixr 0 <| +infixr 1 <| -- | Reverse function application. Do the left side, then pass the -- return value to the function on the right side. @@ -143,6 +152,16 @@ infixl 1 |> (/>) :: Functor f => f a -> (a -> b) -> f b f /> g = fmap g f +infixl 1 /> + +bind :: Monad m => m a -> (a -> m b) -> m b +bind a f = a Prelude.>>= f + +(>>=) :: Monad m => m a -> (a -> m b) -> m b +a >>= b = a Prelude.>>= b + +infixl 1 >>= + -- | Removes newlines from text. chomp :: Text -> Text chomp = Text.filter (/= '\n') -- cgit v1.2.3