<div dir="ltr">I solved it. I was misreading the error report as being about the input to floor, when the problem was the output of it. This code works:<div><br></div><div><div><font face="monospace, monospace">splitArcAtIntegers:: Arc -> [Arc]</font></div><div><font face="monospace, monospace">splitArcAtIntegers (a,b) = let</font></div><div><font face="monospace, monospace"> ceiling_ish = fromInteger $ (floor a) + 1 </font></div><div><font face="monospace, monospace"> in if b <= a then [] </font></div><div><font face="monospace, monospace"> else if b <= ceiling_ish then [(a,b)]</font></div><div><font face="monospace, monospace"> else (a,ceiling_ish) : splitArcAtIntegers (ceiling_ish,b)</font></div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 7, 2015 at 10:14 PM, Jeffrey Brown <span dir="ltr"><<a href="mailto:jeffbrown.the@gmail.com" target="_blank">jeffbrown.the@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Tidal [1] defines these data types:</div><div> </div><div> type Time = Rational</div><div> type Arc = (Time, Time)</div><div> </div><div>I want to write a function "splitMultiCycArc" which divides an Arc into mostly-integer segments, so that, for instance,</div><div> </div><div> splitMultiCycArc (0,1) = [(0,1)]</div><div> splitMultiCycArc (0,2) = [(0,1),(1,2)]</div><div> splitMultiCycArc (0,3) = [(0,1),(1,2),(2,3)]</div><div> splitMultiCycArc (1%2,2) = [(1%2,1),(1,2)]</div><div> splitMultiCycArc (1,5%2) = [(1,2),(2,5%2)]</div><div><br></div><div>I thought I had solved the problem with this code:</div><div><br></div><div> splitMultiCycArc:: Arc -> [Arc]</div><div> splitMultiCycArc (a,b) = let ceiling_ish = floor a + 1 in</div><div> if b <= a then [] </div><div> else if b <= ceiling_ish then [(a,b)]</div><div> else (a,ceiling_ish) : splitMultiCycArc (ceiling_ish,b)</div><div> </div><div>When I try to load that, I get this single error:</div><div><br></div><div> > :reload</div><div> [12 of 13] Compiling Sound.Tidal.JBB ( Sound/Tidal/JBB.hs, interpreted )</div><div> </div><div> Sound/Tidal/JBB.hs:16:44:</div><div> No instance for (Integral Time) arising from a use of ‘floor’</div><div> In the first argument of ‘(+)’, namely ‘floor a’</div><div> In the expression: floor a + 1</div><div> In an equation for ‘ceiling_ish’: ceiling_ish = floor a + 1</div><div> Failed, modules loaded: Sound.Tidal.Strategies, Sound.Tidal.Dirt, Sound.Tidal.Pattern, Sound.Tidal.Stream, Sound.Tidal.Parse, Sound.Tidal.Tempo, Sound.Tidal.Time, Sound.Tidal.Utils, Sound.Tidal.SuperCollider, Sound.Tidal.Params, Sound.Tidal.Transition.</div><div> > </div><div> </div><div>And yet under other conditions, "floor" is perfectly happy operating on a Time value:</div><div><br></div><div> > let a = (1%2,1) :: Arc</div><div> > floor (fst a) + 1</div><div> 1</div><div> > </div><div><br></div><div>[1] <a href="https://hackage.haskell.org/package/tidal" target="_blank">https://hackage.haskell.org/package/tidal</a></div></div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br></div>-- <br><div><div dir="ltr">Jeffrey Benjamin Brown</div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Jeffrey Benjamin Brown</div></div>
</div>