Skip to content

Instantly share code, notes, and snippets.

@jml
Last active August 25, 2018 12:48
Show Gist options
  • Save jml/53dfdf608537fd501bad3e4f0e473b60 to your computer and use it in GitHub Desktop.
Save jml/53dfdf608537fd501bad3e4f0e473b60 to your computer and use it in GitHub Desktop.
Things I want in Protolude

Stephen Diehl's protolude library is excellent. I highly recommend it as a default prelude for Haskell.

It's so good and so close to what I want that whenever I do come across something missing it's as obvious as a glitch in good music.

Here's what I'd like:

<<$>>

(<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
(<<$>>) = fmap . fmap

I do this enough that I'd like it to hand. Pi Delport suggested the syntax & that it should be in a standard library somewhere.

for / forA

I want for to be flip fmap and forA to be what's currently for (protolude/protolude#19).

ppShow

From the pretty-show library.

A very simple pretty printer, great for debugging data structures. Would have to be adjusted for better string types for protolude.

tracePpShow

Like traceShow, but pretty. Doesn't actually exist yet.

guarded

guarded :: Alternative f => (a -> Bool) -> a -> f a
guarded p x = bool empty (pure x) (p x)

Another great idea from Pi Delport.

@jml
Copy link
Author

jml commented Aug 23, 2016

Another silly one:

pass :: Applicative f => f ()
pass = pure ()

@sdiehl
Copy link

sdiehl commented Jan 2, 2017

All of these functions should be added as of 0.1.10. Any issues please report on the issue tracker. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment