plyWith error?

Hey folks! I'm back in tidal land after a few years away, and I find myself struggling with plyWith, which I previously used all the time.

No matter what I try, I'm hit with an ambiguous type variable 't0' error.

Example

d1
  $ plyWith 4 (|* gain 0.6)
  $ s "ot"
  # n "4"
  # start 0.6 # end 0.7
  # legato 1
  # gain 1
Full error
    • Ambiguous type variable ‘t0’ arising from a use of ‘plyWith’
      prevents the constraint ‘(Ord t0)’ from being solved.
      Probable fix: use a type annotation to specify what ‘t0’ should be.
      Potentially matching instances:
        instance Integral a => Ord (Ratio a)
          -- Defined in ‘GHC.Internal.Real’
        instance Ord Ordering -- Defined in ‘GHC.Classes’
        ...plus 31 others
        ...plus 41 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘($)’, namely ‘plyWith 4 (|* gain 0.6)’
      In the second argument of ‘($)’, namely
        ‘plyWith 4 (|* gain 0.6)
           $ s "ot" # n "4" # start 0.6 # end 0.7 # legato 1 # gain 1’
      In the expression:
        d1
          $ plyWith 4 (|* gain 0.6)
              $ s "ot" # n "4" # start 0.6 # end 0.7 # legato 1 # gain 1

Any thoughts appreciated!

Hey Oli!

Hmm it seems this is a problem with newer haskell versions needing to be more specific about the types of things.

You can fix your pattern like this:

d1 $ plyWith (4 :: Pattern Int) (|* gain 0.6) $ s "ot"

Or to avoid having to do that everywhere, redefine the function with a specific type like this:

plyWith :: Pattern Int -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a
plyWith np f p = innerJoin $ (\n -> _plyWith n f p) <$> np
2 Likes

Much appreciated! Excited to be back here.

A slightly better fix seems to be running these two lines:

default (Rational, Integer, Double, Pattern String)

:set -Wno-type-defaults

This will be in the next version of tidal so if you can test it out that would be great !