Re: Vector.toList

Matthew Fluet <[email protected]> Tue, 4 Oct 2016 14:41:04 -0400
Newsgroups gmane.comp.lang.ml.mlton.user
Message-ID <CAMrhFL7vzNeXPXztqd+u-j5Tmgt+tzbmVwWSZjpei1c3HUu4MA@mail.gmail.com>
On Tue, Oct 4, 2016 at 8:33 AM, Thomas Logan <[email protected]> wrote:
> MLton doesn't seem to compile programs using Vector.toList, even though it
> appears to exist in VECTOR_EXTRA
>
> Test program:
> val _ = Vector.toList (Vector.fromList [1,2,3])
>
> Error: test.sml 1.9.
>   Undefined variable Vector.toList.
> compilation aborted: parseAndElaborate reported errors
>
> from version mlton-20130715-1.amd64-darwin.gmp-static.tgz

The VECTOR_EXTRA signature
(https://github.com/MLton/mlton/blob/master/basis-library/arrays-and-vectors/vector.sig#L32)
is used to ascribe a signature to the Vector structure
(https://github.com/MLton/mlton/blob/master/basis-library/arrays-and-vectors/vector.sml#L9)
for use within the Basis Library implementation.  It extends the Basis
Library VECTOR signature (http://sml-family.org/Basis/vector.html)
with a number of functions that are useful for implementing other
components of the Basis Library.  Ultimately, the Vector structure as
seen by user code is constrained to exactly the VECTOR signature
prescribed by the Basis Library by a later signature match.

The convention of a XYZ_EXTRA signature extending a Basis Library XYZ
signature is common in MLton's implementation; some of these
extensions are exported to the user through one of the MLton
sub-structures (http://mlton.org/MLtonStructure); see
http://mlton.org/MLtonVector (which corresponds functions in the
MLton.Vector structure), although Vector.toList is not provided there.

There is a proposal to extend the Basis Library with additional
sequence operations
(https://github.com/SMLFamily/BasisLibrary/wiki/2015-003-Additional-operations-on-sequences),
including Vector.toList
(https://github.com/SMLFamily/BasisLibrary/wiki/2015-003e-Vector).

You can use "(fn v => Vector.foldr (op::) [] v)" to convert a vector to a list.

-- 
You received this message because you are subscribed to the Google Groups "MLton-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot