# [Haskell-beginners] numerical types, the \$ operator

TG cowscanfly at airpost.net
Sun Mar 29 13:00:37 EDT 2009

```
On Sat, 28 Mar 2009 17:34 -0400, "Brent Yorgey" <byorgey at seas.upenn.edu>
wrote:

> > Moreover, I've put the 'RealFrac' by looking at ":t floor".
> > What kind of class constraint whould you put for doing eg:
> >
> > >frac x = x - fromInteger (floor (sqrt x) )
> >
> > since 'floor' takes fractional and 'sqrt' takes RealFrac? Some kind of
> > super-class?
>
> Every instance of RealFrac must also be an instance of Fractional, so
> just putting RealFrac would be fine.  (And I didn't have this
> memorized, I just started up ghci and typed ':info Fractional' and
> ':info RealFrac' to see how they are declared.)

Hmm, I gave the wrong types for floor and sqrt above (oops) but your
answer should still be valid as a way of looking at things
So
floor :: (RealFrac a, Integral b) => a -> b
sqrt :: (Floating a) => a -> a
and looking as you suggest,
(Real a, Fractional a) => RealFrac a
(Fractional a) => Floating a
So in this case the answer is...
frac :: (Floating a, RealFrac a) => a -> a
frac x = x - fromInteger (floor (sqrt x))
No, common! Please tell me I'm wrong, that there's a simpler way!

Clear, qualified answers and a bit of showing off for having something
to aspire too. Thank you guys!
--
TG
cowscanfly at airpost.net

--
http://www.fastmail.fm - Does exactly what it says on the tin

```
{"ft_lang_label":"__label__en","ft_lang_prob":0.8828924,"math_prob":0.68880975,"size":1456,"snap":"2021-43-2021-49","text_gpt3_token_len":429,"char_repetition_ratio":0.10812672,"word_repetition_ratio":0.02962963,"special_character_ratio":0.3028846,"punctuation_ratio":0.15878378,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9550306,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-25T19:13:34Z\",\"WARC-Record-ID\":\"<urn:uuid:02134b13-a68d-4e7b-9498-ad4f0b21dac0>\",\"Content-Length\":\"4449\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:1f1cd7f5-270e-46a1-a5b3-9f0ee94e5535>\",\"WARC-Concurrent-To\":\"<urn:uuid:fce93735-ffe8-454f-8b8c-bafceab6d123>\",\"WARC-IP-Address\":\"23.253.242.70\",\"WARC-Target-URI\":\"https://mail.haskell.org/pipermail/beginners/2009-March/001354.html\",\"WARC-Payload-Digest\":\"sha1:HYEEHERGBF4AF2Y5HMSH7YWKBMJ2BY5J\",\"WARC-Block-Digest\":\"sha1:MZTEMCSQ5YQ2LT5MV42W6IJ3JWNRRP2D\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323587767.18_warc_CC-MAIN-20211025185311-20211025215311-00500.warc.gz\"}"}