Skip to content

code example in API comment for spread' is broken #1108

Open
@jwaldmann

Description

@jwaldmann

https://hackage.haskell.org/package/tidal-1.9.5/docs/Sound-Tidal-UI.html#v:spread-39-

GHCi, version 9.10.1: https://www.haskell.org/ghc/  :? for help
ghci> import Sound.Tidal.Context 
ghci> :set -XOverloadedStrings 
ghci> :t spread' slow "2 4%3" $ sound "ho ho:2 ho:3 hc"
<interactive>:1:14: error: [GHC-39999]
    • No instance for ‘Enumerable (Pattern Time)’
        arising from the literal ‘"2 4%3"’
    • In the second argument of ‘spread'’, namely ‘"2 4%3"’
      In the first argument of ‘($)’, namely ‘spread' slow "2 4%3"’
      In the expression: spread' slow "2 4%3" $ sound "ho ho:2 ho:3 hc"

this version is type-correct (inserting pure)

spread' slow (pure "2 4%3") $ sound "ho ho:2 ho:3 hc"

is that how it's supposed to be used? (I guess not, since implementation then does pure "..." >>= _ where the monadic-bind is useless)

then perhaps this?

spread' slow (fmap pure "2 4%3") $ sound "ho ho:2 ho:3 hc"

NB: to catch documentation bugs like this, it would be good to have a method of evaluating examples (like https://github.com/sol/doctest#readme) (at least, type-checking)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions