diff options
author | Ben Sima <ben@bsima.me> | 2021-01-27 22:24:37 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-01-27 22:24:37 -0500 |
commit | 1c07b112aa8c721beadc0494972c18462a5946bf (patch) | |
tree | 9e15cb6c118f8d6dda35b09c481360e0e266f3f2 /Alpha.hs | |
parent | 6c72ee7b29b5b69e93854fde67cbc7a53f998ed7 (diff) |
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.
Diffstat (limited to 'Alpha.hs')
-rw-r--r-- | Alpha.hs | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -41,6 +41,10 @@ module Alpha (</), (<//), + -- * Shoving / binding + bind, + (>>=), + -- * 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 <. (</) :: Functor f => (a -> b) -> f a -> f b f </ g = fmap f g +-- infixr 1 </ + -- | 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. @@ -117,6 +124,8 @@ f </ g = fmap f g (<//) :: (Functor f0, Functor f1) => (a -> b) -> f0 (f1 a) -> f0 (f1 b) (<//) = fmap .> fmap +-- infixr 1 <// + -- | Normal function application. Do the right side, then pass the -- return value to the function on the left side. -- @@ -124,7 +133,7 @@ f </ g = fmap f g (<|) :: (a -> 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') |