/**
 * @since 1.5.0
 */
import { Index, Optional } from '..';
import { updateAt } from 'fp-ts/es6/NonEmptyArray';
import { lookup } from 'fp-ts/es6/Array';
import { isNone } from 'fp-ts/es6/Option';
/**
 * @category constructor
 * @since 1.5.0
 */
export function indexNonEmptyArray() {
    return new Index(function (i) {
        return new Optional(function (s) { return lookup(i, s); }, function (a) { return function (nea) {
            var onea = updateAt(i, a)(nea);
            if (isNone(onea)) {
                return nea;
            }
            else {
                return onea.value;
            }
        }; });
    });
}