From 8b9ec04c25e2ddf34c9e0b925fb4283f40f54468 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 20 Jan 2021 10:16:19 -0500 Subject: Load Alpha in ghci startup and add pronunciations --- .ghci | 12 +++++++----- Alpha.hs | 35 +++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.ghci b/.ghci index f03d43b..a0784b6 100644 --- a/.ghci +++ b/.ghci @@ -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" diff --git a/Alpha.hs b/Alpha.hs index 113c85a..93308a0 100644 --- a/Alpha.hs +++ b/Alpha.hs @@ -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 ( (a -> b) -> f a -> f b f (a -> b) -> f0 (f1 a) -> f0 (f1 b) ( 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 -- cgit v1.2.3