Xmonad: when floating a window, move or resize it

I suppose you've xmonad-contrib package installed. Then you should take a look at XMonad.Actions.FloatKeys

I guess modified function will be:

...
import XMonad.Actions.FloatKeys
...

toggleFloat = withFocused (\windowId -> do
                              { floats <- gets (W.floating . windowset);
                                if windowId `M.member` floats
                                then withFocused $ windows . W.sink
                                else do
                                     keysMoveWindowTo (x, y) (gx1, gy1) windowId
                                     keysResizeWindow (dx, dy) (gx2, gy2) windowId
                              }
                          ) 

where x,y,dx,dy,gx1,gy1,gx2,gy2 are your settings.
Operator % mentioned in docs is from Data.Ratio; a % b means rational number with numerator a and denominator b. You have to import if you want to use it:

import Data.Ratio ((%))

Float window with mod+left dragging, resize it with mod+right dragging.