'getcps' function gives type error

Hi Guys

I’m tying to use the function ‘getcps’, found here:

If I evaluate ‘getcps’ it returns the current value of cps, but if I try to pass ‘getcps’ to a function I get a type error:

• Couldn't match expected type ‘Pattern Double’
              with actual type ‘IO hosc-0.18.1:Sound.OSC.Time.Time’
• In the first argument of ‘setcps’, namely ‘getcps’
  In the expression: setcps getcps
  In an equation for ‘it’: it = setcps getcps

Does anyone know if there is a way to get cps as a double?

Thanks! :slight_smile:

getcps is an IO action, not a value. You can get a in value out of it with <-, e.g.:

now <- getcps

There’s a little bit to learn here… A good Haskell book will cover it under a section on the IO monad.