haproxy – Redirect www to non-www and http to https in one redirect?

I’ve been trying to get this to work, but cannot.

I know I can redirect http -> https using something like this:

http-request redirect scheme https code 301 if !{ ssl_fc }

I know I can redirect www -> non-www using something like this:

http-request redirect prefix https://%(hdr(host)) code 301 if { hdr_beg(host) -i www } 
// although note this doesn't work for me, it does nothing

I need the following:

http://example.com/any-uri      -> https://example.com/any-uri
http://www.example.com/any-uri  -> https://example.com/any-uri
https://www.example.com/any-uri -> https://example.com/any-uri

How can I do both http -> https and www -> non-www using a single 301 redirect?

Thanks