Packages

  • package root
    Definition Classes
    root
  • package kantan
    Definition Classes
    root
  • package codecs
    Definition Classes
    kantan
  • package collection
    Definition Classes
    codecs
  • package error
    Definition Classes
    codecs
  • package export

    Provides a simple mechanism to insert derived type class instances in the implicit resolution mechanism.

    Provides a simple mechanism to insert derived type class instances in the implicit resolution mechanism.

    By default, when imported, such instances have the highest possible priority, which is typically problematic with shapeless instance derivation: bespoke instances for Option or Either, for example, find themselves shadowed by the generically derived ones.

    If such instances are of type kantan.codecs.export.DerivedDecoder / kantan.codecs.export.DerivedEncoder rather than Decoder / Encoder, however, they'll find themselves with a lower precedence and only be used if no other, more specific instance is found.

    Definition Classes
    codecs
  • package resource
    Definition Classes
    codecs
  • package bom

    Adds Byte Order Mark support to resources.

    Adds Byte Order Mark support to resources.

    By importing this package, the default behaviour of kantan libraries will be changed to: * add a BOM when writing textual data (if one exists for the output charset). * attempt to find a BOM when reading textual data and, if one is found, use the corresponding charset (potentially overriding whatever charset was specified "in-code").

    Those behaviours are not enabled by default as they're very Microsoft-specific.

  • Closeable
  • InputResource
  • OutputResource
  • PlatformSpecificInstances
  • ReaderResource
  • Resource
  • ResourceError
  • ResourceIterable
  • ResourceIterator
  • WriterResource
  • package strings

    Defines codecs for encoding to and decoding from strings.

    Defines codecs for encoding to and decoding from strings.

    These codecs are not necessary meant to use directly, but more as part of larger ones. kantan.csv, for example, works with CSV files but delegates the act of encoding to or decoding from a CSV cell to string codecs.

    Default instances can be found in kantan.codecs.strings.codecs.

    Definition Classes
    codecs
p

kantan.codecs

resource

package resource

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. resource
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type CloseResult = Either[CloseError, Unit]
  2. trait Closeable[A] extends AnyRef

    Type class for all types that can be closed.

  3. type InputResource[A] = Resource[A, InputStream]

    Resource specialised for java.io.InputStream.

  4. type OpenResult[A] = Either[OpenError, A]
  5. type OutputResource[A] = Resource[A, OutputStream]

    Resource specialised for java.io.OutputStream.

  6. trait PlatformSpecificInstances extends AnyRef

    JVM specific instances of Resource.

  7. type ProcessResult[A] = Either[ProcessError, A]
  8. type ReaderResource[A] = Resource[A, Reader]

    Resource specialised for java.io.Reader.

    Resource specialised for java.io.Reader.

    Note that it's good practice not to declare explicit instances of ReaderResource for types that have an instance of InputResource. It's better to let the implicit resolution mechanism work out how to best turn an InputStream into a Reader - the JVM-specific kantan.codecs.resource.bom package, in particular, relies on this.

  9. trait Resource[I, R] extends AnyRef

    Represents a resource that can be opened and worked on.

    Represents a resource that can be opened and worked on.

    The purpose of this trait is to abstract over the notion of "things that can be opened", such as files, URLs... Default instances are provided for java.io types - java.io.File, for example, has instances for both opening it for reading and for writing.

    I

    type of the resource itself (eg java.io.File).

    R

    type of the opened resource (eg java.io.InputStream)

  10. sealed trait ResourceError extends Product with Serializable
  11. trait ResourceIterable[A] extends AnyRef
  12. trait ResourceIterator[+A] extends TraversableOnce[A] with java.io.Closeable

    Offers iterator-like access to IO resources.

    Offers iterator-like access to IO resources.

    For the most part, values of type ResourceIterator can be considered as iterators, with a few improvements.

    First, they have a ResourceIterator.close()* method, which allows you to release the underlying resource when needed. This is fairly important and part of the reason why working with Source.getLines can be so aggravating.

    Second, ResourceIterator.close()* is mostly not needed: whenever an IO error occurs or the underlying resource is empty, it will be closed automatically. Provided you intend to read the whole resource, you never need to explicitly close it. This covers non-obvious cases such as filtering or dropping elements.

    You should be able to express most common causes for not reading the entire stream through standard combinators. For example, "take the first n elements" is take(n), or "take all odd elements" is filter(_ % 2 == 0). This allows you to ignore the fact that the underlying resource needs to be closed. Should you ever find youself in a situation when you just want to stop, however, ResourceIterator.close()* is available.

    Annotations
    @SuppressWarnings()
  13. type ResourceResult[A] = Either[ResourceError, A]
  14. type WriterResource[A] = Resource[A, Writer]

    Resource specialised for java.io.Writer.

    Resource specialised for java.io.Writer.

    Note that it's good practice not to declare explicit instances of WriterResource for types that have an instance of OutputResource. It's better to let the implicit resolution mechanism work out how to best turn an OutputStream into a Writer - the JVM-specific kantan.codecs.resource.bom package, in particular, relies on this.

Value Members

  1. object Closeable
  2. object InputResource

    Provides instance summoning methods for InputResource.

  3. object OutputResource

    Provides instance summoning methods for OutputResource.

  4. object ReaderResource

    Provides instance summoning methods for ReaderResource.

  5. object Resource extends PlatformSpecificInstances
  6. object ResourceError extends Serializable
  7. object ResourceIterator
  8. object WriterResource

    Provides instance summoning methods for WriterResource.

Inherited from AnyRef

Inherited from Any

Ungrouped