Skip to content

Instantly share code, notes, and snippets.

Last active Aug 24, 2017
What would you like to do?
TODO: Stuff
Copy link

Icelandjack commented Aug 4, 2017

generic-transformation transformer

fmap : (b. Term b => b -> b) -> (b. Term b => b -> b)

6 Refinements and reflections

Having introduced the basics, we pause to reflect on the ideas a little and to make some modest generalisations.

6.1 An aside about types

It is worth noticing that the type of everywhere could equivalently
be written thus:

everywhere :: (forall b. Term b => b -> b) -> (forall a. Term a => a -> a)

by moving the implicit forall a inwards. The nice thing about writing it this way is that it becomes clear that everywhere is a generic-transformation transformer. We might even write this:

type GenericT = forall a. Term a => a -> a
everywhere :: GenericT -> GenericT

The same approach gives a more perspicuous type for everything:

type GenericQ r = forall a. Term a => a -> r
everything :: (r -> r -> r) -> GerericQ r -> GerericQ r

Copy link

Icelandjack commented Aug 24, 2017

A tutorial on the universality and expressiveness of fold


fold :: (α  β  β)  β  ([α]  β)

instead of

fold :: (a -> b -> b) -> b -> [a] -> b
-- or
fold :: (a -> b -> b) -> (b -> [a] -> b)

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