Skip to content

Cannot implement TupleConverters for Higher-kinded Types #609

@laurencer

Description

@laurencer

Whilst you can implement a TupleConverter for a higher-kinded type (i.e. TupleConverter[ValidationNel[String, SomeCaseClass]]) - when used with a TypeDelimited pipe (i.e. TypedTsv[ValidationNel[String, SomeCaseClass]]) with multiple fields it will always throw NoSuchElementException: None.get (FileSource.scala:103).

This is because TypeDelimited will perform a rudimentary analysis to determine the classes to deserialize (see FileSource.scala:322 - 331). For a complex higher-kinded type, this will result in only a single class being assigned to types. If your input has multiple fields, this will throw an exception in DelimitedParser.java:136. This will then be caught in FileSource.scala:90 and discarded - making it very difficult to track down.

There are a number of ways this could be fixed - but they require non-trivial design changes. My thoughts are that the types should be manually specifiable in the TupleConverter (i.e. add some logic in TypeDelimited to check if the types have been provided by the TupleConverter).

This could be retrofitted fairly easily - by making types: Option[Seq[Class]] = None on TupleConverter.

I'm happy to write the fix - I just want to make sure I'm not missing something obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions