Closed byorgey closed 4 years ago
can you provide examples of what this could look like?
Sure! The oeis package provides a way to retrieve all the info related to a sequence, but I am thinking of keeping things simple. Maybe we could have two primitives: one to extend a sequence, and the other to yield the URL of a sequence. So, in more detail:
lookupSequence
and extendSequence
.
Disco.Syntax.Prims
, in both the Prim
data type and the primTable
. Probably make them non-exposed (i.e. set the boolean in the primTable
to False
).inferPrim
function in Disco.Typecheck
. I'm imagining type [N] -> String
for lookupSequence
and [N] -> [N]
for extendSequence
.Op
data type in Disco.AST.Core
, and update the compilePrim
function in Disco.Compile
to trivially turn the new prims into the new Op
constants.whnfOp
function in Disco.Interpret.Core
to handle the new constants. This is where you would actually write code to call the Haskell oeis
package and convert back and forth to Disco runtime values.oeis.disco
in lib/
, and have it simply re-export the prims (you can see how this is done for num.disco
as an example).As a further example of what this might look like when it's working:
Disco> import oeis
Disco> :type extendSequence
extendSequence : List ℕ → List ℕ
Disco> extendSequence [0,1,1,2,3,5]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155]
Disco> :type lookupSequence
lookupSequence : List ℕ → List Char
Disco> lookupSequence [0,1,1,2,3,5]
"http://oeis.org/A000045"
I'm also open to other suggestions!
Using the
oeis
package. Provide some OEIS primitives that allow interaction with the OEIS database.