Tidal icon indicating copy to clipboard operation
Tidal copied to clipboard

OSC Spec ArgList couldn't match type error when given default values

Open jarmitage opened this issue 5 years ago • 5 comments

I just updated to 1.6.2 on main and suddenly can't use OSC Spec ArgLists with default values. When I revert back to 1.5.2 this issue now persists. Was working perfectly moments before attempting the update...

-- A simple video synth for Consoles, controlled by OSC
-- https://github.com/zarquin/ASCII-Simple-Video-Synth
:{
let ascTarget = Target {oName     = "ascii",
                        oAddress  = "127.0.0.1",
                        oPort     = 5050,
                        oLatency  = 0.2,
                        oWindow   = Nothing,
                        oSchedule = Live
                       }
    ascOSCSpecs = [OSC "/{asccolour}/speed"  $ ArgList [("ascspeed", Just $ VF 0)], -- <-- has a default value
                   OSC "/{asccolour}/mode"   $ ArgList [("ascmode", Nothing)],
                   OSC "/{asccolour}/offset" $ ArgList [("ascoffset", Nothing)],
                   OSC "/{asccolour}/scale"  $ ArgList [("ascscale", Nothing)],
                   OSC "/shape/sides" $ ArgList [("ascsides", Nothing)],
                   OSC "/shape/size"  $ ArgList [("ascsize", Nothing)],
                   OSC "/shape/xinc"  $ ArgList [("ascxinc", Nothing)],
                   OSC "/shape/yinc"  $ ArgList [("ascyinc", Nothing)]
                  ]
    ascspeed  = pI "ascspeed"
    ascmode   = pI "ascmode"
    ascoffset = pI "ascoffset"
    ascscale  = pI "ascscale"
    ascsides  = pI "ascsides"
    ascsize   = pI "ascsize"
    ascxinc   = pI "ascxinc"
    ascyinc   = pI "ascyinc"
    asccolour = pS "asccolour"
    ascOscMap = (ascTarget, ascOSCSpecs)
:}
osc/targets/ASCIISVS.hs:12:70: error:
    • Couldn't match type ‘Maybe Int -> Value’ with ‘Value’
      Expected type: Maybe Value
        Actual type: Maybe (Maybe Int -> Value)
    • In the expression: Just $ VF 0
      In the expression: ("ascspeed", Just $ VF 0)
      In the first argument of ‘ArgList’, namely
        ‘[("ascspeed", Just $ VF 0)]’
   |
12 |     ascOSCSpecs = [OSC "/{asccolour}/speed"  $ ArgList [("ascspeed", Just $ VF 0)],
   |                                                                      ^^^^^^^^^^^

jarmitage avatar Sep 27 '20 11:09 jarmitage

Actually I didn't revert properly, 1.5.2 does not have this issue. Seeing if I can track it down...

jarmitage avatar Sep 27 '20 11:09 jarmitage

Can confirm this only happens on latest main which installs as 1.6.2

jarmitage avatar Sep 27 '20 11:09 jarmitage

VF has two arguments (recently?)

data Value
  = VS {svalue :: String, vbus :: Maybe Int}
  | VF {fvalue :: Double, vbus :: Maybe Int}
  ...

introduced: https://github.com/tidalcycles/Tidal/commit/bb79e9eba8d0d4efe732ace12b375fdb54886f8c#diff-e9ef85b1fa65610b76d8d846ba7e48b2

looks like Just $ VF 0 is fDefault 0 now.

jwaldmann avatar Sep 27 '20 11:09 jwaldmann

Yes values can come from numbered buses now, so that they can be changed independently from trigger messages. So Just $ VF 0 should now be Just $ VF 0 Nothing.

The question is whether exposing this to the end user is useful. Would you want a value to default to a bus value? That seems feasible, but unlikely..

yaxu avatar Sep 27 '20 13:09 yaxu

Yes values can come from numbered buses now, so that they can be changed independently from trigger messages. So Just $ VF 0 should now be Just $ VF 0 Nothing.

Cool!

The question is whether exposing this to the end user is useful. Would you want a value to default to a bus value? That seems feasible, but unlikely..

I can't think of a reason why right now.

jarmitage avatar Sep 27 '20 16:09 jarmitage

I think that bus logic has been moved back out of the Value type, so the original code here (and in the current documentation) is still correct with recent Tidal versions.

So, this bug is resolved, no?

matthewkaney avatar Nov 25 '22 22:11 matthewkaney