diff options
author | Ben Sima <ben@bsima.me> | 2021-01-20 10:16:19 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-01-22 08:00:27 -0500 |
commit | 8b9ec04c25e2ddf34c9e0b925fb4283f40f54468 (patch) | |
tree | 8b3b0fbae94eec5912130da1ba2e7ab362bc9d72 | |
parent | 92d3ab89ffd6e65d5a79de0cf5907aad3786ce44 (diff) |
Load Alpha in ghci startup and add pronunciations
-rw-r--r-- | .ghci | 12 | ||||
-rw-r--r-- | Alpha.hs | 35 |
2 files changed, 34 insertions, 13 deletions
@@ -1,11 +1,13 @@ :set -XOverloadedStrings +:set -XNoImplictPrelude :set prompt " λ " :set prompt-cont " | " :set -Wall :set -haddock +:load Alpha -- ':iq Module M' -> 'import qualified Module as M' -:def iq (\arg -> let [x, y] = Prelude.words arg in return $ "import qualified " ++ x ++ " as " ++ y) -:def hoogle \s -> return $ ":! hoogle search --count=15 \"" ++ s ++ "\"" -:def hdoc \s -> return $ ":! hoogle search --info \"" ++ s ++ "\"" -:def f \_ -> return $ ":! ftags \n:r" -:def test \_ -> return $ ":main test" +:def iq (\arg -> let [x, y] = Prelude.words arg in return <| "import qualified " ++ x ++ " as " ++ y) +:def hoogle \s -> return <| ":! hoogle search --count=15 \"" ++ s ++ "\"" +:def hdoc \s -> return <| ":! hoogle search --info \"" ++ s ++ "\"" +:def f \_ -> return <| ":! ftags \n:r" +:def test \_ -> return <| ":main test" @@ -17,6 +17,11 @@ -- -- It seems unnecessarily different at first but it makes things easier -- to read quickly. +-- +-- Pronunciations are given for operators and are taken from +-- [Hoon](https://urbit.org/docs/tutorials/hoon/hoon-school/hoon-syntax/). +-- Pronouncing operators as you write the code is actually a nice way to +-- interact with the codebase, and I do recommend it. module Alpha ( -- * Re-export Protolude module X, @@ -75,44 +80,58 @@ compose :: (a -> b) -> (b -> c) -> (a -> c) compose f g x = g (f x) -- | Right-composition operator -infixl 9 .> - +-- +-- Pronunciation: dot-gar (.>) :: (a -> b) -> (b -> c) -> (a -> c) f .> g = compose f g --- | Left-composition operator -infixr 9 <. +infixl 9 .> +-- | Left-composition operator +-- +-- Pronunciation: gal-dot (<.) :: (b -> c) -> (a -> b) -> (a -> c) g <. f = compose f g +infixr 9 <. + -- | Alias for map, fmap, <$> +-- +-- Pronunciation: gal-fas (</) :: Functor f => (a -> b) -> f a -> f b f </ g = fmap f g -- | 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. +-- +-- Pronunciation: gal-fas-fas (<//) :: (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. -infixr 0 <| - +-- +-- Pronunciation: gal-bar (<|) :: (a -> b) -> a -> b f <| g = f g +infixr 0 <| + -- | Reverse function application. Do the left side, then pass the -- return value to the function on the right side. -infixl 0 |> - +-- +-- Pronunciation: bar-gar (|>) :: a -> (a -> b) -> b f |> g = g f +infixl 0 |> + -- | 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` +-- +-- Pronunciation: fas-gar (/>) :: Functor f => f a -> (a -> b) -> f b f /> g = fmap g f |