Operator alias for Data.Functor.map (left-associative / precedence 4)
I've chosen a train as you might thing of it as the second thing going through a "magic tunnel" that transforms its passengers. Bear with me: this will make more sense in a second.
Operator alias for Control.Apply.apply (left-associative / precedence 4)
You may, from time to time, see some code like
f <$> a <*> b <*> c. What
this does is apply three (specifically
Apply) functor-wrapped values to
f, and returns the answer wrapped up in the same
Apply. To make this
Prelewd would write this as
f 🚂(a)🚋(b)🚋(c). We can now see
that what we're actually doing is driving our train through the "magic
tunnel" with some extra passengers. We are effectively combining
c using the
f function to bring them all together.
Operator alias for Control.Apply.applySecond (left-associative / precedence 4)
Particularly with things like validation, you'll get code sequences like
isUpper name *> pure name, where
Either is the underlying mechanism.
What's going on here is that the values are combined with
\x y -> y,
which means that any "side-effects" from the first value aren't forgotten.
So, for validation, this means that any validation failure is carried
forward. Or, in
Prelewd, we use the now-look-at-that-one operator.
Operator alias for Control.Bind.bind (left-associative / precedence 1)
I desperately wanted to use 🌯 for this, and I probably will as soon as the
compiler starts handling the weird emoji set. For now, though, I'm going to
use this explosion thing. The point is that stuff (well, air) goes in one
end, and gets transformed into noise or whatever. Stretched metaphor. The
point is that confetti and stuff happens as a side-effect.
>>= is scary,
but 🎉 is delightful.
readLine 🎉 log means "pass the input to
throw confetti everywhere in the process".
Operator alias for Control.Semigroupoid.compose (right-associative / precedence 9)
In the early days, composition is a confusing thing to read. When we write,
f <<< g, what we actually get is
\x -> f (g x). When we write something
f <<< g <<< h, we get
\x -> f (g (h x)). PureScript's syntax
actually makes this pretty straightforward already, with some pretty clear
direction to these operators, but this is prelewd, so let's bung in some
Operator alias for Control.Semigroupoid.composeFlipped (right-associative / precedence 9)
For people coming from Elm and most imperative languages, it probably seems
a bit more familiar to see composition the other way round. Don't worry: we
got your back, friends. At least for iOS, this arrow is labelled
that's quite exciting!
Operator alias for Data.Function.apply (right-associative / precedence 0)
$ is waaay less frightening than it looks at first. The idea is that you
take the result of everything on the left, and apply it to the result of
everything on the right. So,
f x $ g x is actually
(f x) (g x). That's
all there is to it! With the exception of brackets/parentheses, this is a
will be the very last thing to evaluate, so you can make the sides as weird
as you like. The gust of wind is to show the sides being "blown apart" to
work separately, before being recombined at the end!
#type (🐛) Source
Operator alias for Data.NaturalTransformation.NaturalTransformation (right-associative / precedence 4)
It's quite a transformation. You'll see
~> every now and then in types.
Array ~> Maybe. Fear not: this expands to the more friendly,
type NaturalTransformation f g = forall a. f a -> g a. In other words,
Array ~> Maybe is a function that takes an array of any type, and turns
it into a
Maybe of the same type. In other words, your scary natural
transformations are just functions that change the functor around a value
without touching the value in the middle! Why is it a caterpillar, though?
Well, when it becomes a butterfly, its outer shell changes a lot, but it's
still the same friendly personality inside 😌
Operator alias for Data.Semigroup.append (right-associative / precedence 5)
Semigroups aren't too scary. We have a type that lets us "smoosh" values
together and get a new value of that type. The
<> operator is pretty good
and intuitive, but let's use the "high five": two values coming together to
 🙏  == [2, 3],
"He" 🙏 "llo" == "Hello", etc.
Operator alias for Control.Alt.alt (left-associative / precedence 3)
<|> operator gets a lot of publicity in parser libraries. When you go
for a rummage in the docs, you find phrases like "monoidal applicative",
which don't help a lot. Basically, we're combining the behavior of two
functor values of the same type. For some functors like
Array, this is
just the same as 🙏. However, it's often for fallbacks: if your functor
x <|> y <|> z <|> ... will return the first
Nothing if there aren't any.
investigate :: forall b a. Warn "Debug.Trace usage" => Show a => a -> b -> b
Once in a while, we all need to debug. A lot of programmers from imperative
languages find real trouble with debugging, as they can't just bung in a
console.log to see values. Well, what if I told you... you can! So,
we can cheat a little bit, and use some escape hatches in the
traceShow, which will log anything
this function, we can show a value at any point, and return anything!
Operator alias for Prelewd.investigate (left-associative / precedence 8)
For example, if we have
f x and want to know what
x is, we can write
x 🔍 f x. This will return the same value as
f x, but also print the
x value (sneaky-like) to the console for us to look at.
Operator alias for Data.Void.absurd (non-associative / precedence 9)
Be careful with this! It's a function never to be called. Anyway, since
there are no values of type
Void, what would you even call it with?
Operator alias for Partial.Unsafe.unsafePartial (non-associative / precedence 1)
Sometimes you need to tell the compiler that you know what you're doing,
even though it might not be obvious. That's OK! Maybe you know you have
fromJust 🙈 Just 2 will get you that 2 with no trouble!
Beware, though: if you're wrong, PureScript won't save you from runtime
type Compose f g a = f (g a)
Not only can we compose functions, but also functors! Maybe we want a list
Maybe values, or an
Aff of a function. Whatever it is, we can write
some "stacks" with
#type (🍔) Source
Operator alias for Prelewd.Compose (right-associative / precedence 9)
forall a b. Tuple a b -> Tuple a (Array b).
forall a. Tuple a 🐛 Tuple a 🍔 Array.
I'm not saying that you should do this, but it looked funny to write out. A
stack of functors is like a stack of burger ingredients: do as you will.
#type (🆚) Source
Operator alias for Data.Either.Either (left-associative / precedence 3)
Either is defined as having two types. The constructors hold one each. So
Either Int String is either a
Left Int or
Right String. This has
lots of uses, commonly with error-handling. You can use
Left to carry any
Right to carry success.
Error 🆚 Result, if you like.
Operator alias for Data.Pair.Pair (left-associative / precedence 3)
Pair bundles two values of the same type together. Name a more famous
twin ... I'll wait.
Operator alias for Data.Tuple.Tuple (left-associative / precedence 3)
Tuple takes two arguments and bundles them together, always together,
both in the type and in the value.
Operator alias for Data.Functor.Contravariant.cmap (left-associative / precedence 9)
Make a value presentable!
Contravariant functors are usually of the form
F a = a -> X, where
X is some fixed type like
Boolean. When we do a
cmap, we say, "I don't have an
a, but I do have a way to get to
b, and we can therefore have an
F b = b -> x. In a sense, we
need a way to make the value look suitable. What better way to make oneself
presentable than to put on some lipstick?
Operator alias for Data.Lens.Iso.iso (non-associative / precedence 1)
Equivalent things can be exchanged for each other. Like currency! This is
called an isomorphism, see Data.Lens.Iso. Swap an
a for a