[livecode] Vivid: Create a value of type `I a` where `a` is chosen at runtime

From: Jeffrey Brown <jeffbrown.the_at_gmail.com>
Date: Wed, 4 Jul 2018 07:30:22 -0500

Composers reuse melodic material across different instruments. I would like
to do that in Vivid. I would keep a sequence of values and send it
sometimes to one parameter of one synth, sometimes to a different parameter
of a different synth.

To do that I would have to coerce those numbers to values of type `I a`,
where the string `a` is known only at runtime. I tried to write a function
to do that:

    import GHC.TypeLits
    toIOf :: (Real n, GHC.TypeLits.KnownSymbol a) => String -> n -> I a
    toIOf "freq" n = toI n :: I "freq"
    toIOf "amp" n = toI n :: I "amp"

but it won't compile, because the outputs of `toIOf "freq"` and `toIOf
"amp"` have different types.

Is this possible?

-- 
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/>   |   Facebook
<https://www.facebook.com/mejeff.younotjeff>   |   LinkedIn
<https://www.linkedin.com/in/jeffreybenjaminbrown>(spammy, so I often miss
messages here)   |   Github <https://github.com/jeffreybenjaminbrown>


_______________________________________________
Livecode mailing list -- livecode_at_we.lurk.org
To unsubscribe send an email to livecode-leave_at_we.lurk.org
Received on Wed Jul 04 2018 - 12:30:49 BST

This archive was generated by hypermail 2.4.0 : Sun Aug 20 2023 - 16:02:23 BST