Re: [Haskell-beginners] [Haskell-cafe] I think someone had a complicated program to use brackets for array indexing - is it possible to use a DSL for this?

Then a tuple might work better as input to a function to index into an array
e.g. myArray (5)
--
--
Sent from an expensive device which will be obsolete in a few months! :D
Casey
On Jun 1, 2015 1:21 PM, "Tikhon Jelvis"
You could make myArray a function that takes a list as an input. Of course, all your other array functions have to account for this too. A potential advantage is that this approach leaves the underlying array type abstract, so you could mix and match different data structure on the backend. (IntMap, Array, Vector… etc.)
A disadvantage is that this is non-standard usage which could be confusing to people and there's no way I know of to statically ensure the list passed in always had one element. That is, myArray [1, 2] would be legal and result in a runtime error.
I don't know of a way to do it while using a normal array type directly.
On Mon, Jun 1, 2015 at 1:17 PM, KC
wrote: I think someone had a complicated program to use brackets for array indexing - is it possible to use a DSL for this?
That is, to use myArray [5] and have a DSL convert it to standard Haskell syntax
-- --
Sent from an expensive device which will be obsolete in a few months! :D
Casey
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

On Mon, Jun 1, 2015 at 4:29 PM, KC
Then a tuple might work better as input to a function to index into an array
e.g. myArray (5)
Aside from 1-tuples not being a thing? (That's the same as (myArray 5).) -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

I'm a part time tutor even though I don't look Elizabethan
I was trying to lower the learning curve for students
Maybe I'll point them to
http://dev.stephendiehl.com/hask/
And
Data.Vector
--
--
Sent from an expensive device which will be obsolete in a few months! :D
Casey
On Jun 1, 2015 1:35 PM, "Brandon Allbery"
On Mon, Jun 1, 2015 at 4:29 PM, KC
wrote: Then a tuple might work better as input to a function to index into an array
e.g. myArray (5)
Aside from 1-tuples not being a thing? (That's the same as (myArray 5).)
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (2)
-
Brandon Allbery
-
KC