tomland-0.3: TOML parser

Safe HaskellNone
LanguageHaskell2010

Toml.Prism

Contents

Description

Naive implementation of data-prism approach.

Synopsis

Prism idea

data Prism object field Source #

Implementation of prism idea using simple data prism approach. Single value of type Prism has two capabilities:

  1. preview: first-class pattern-matching (deconstruct object to possible field).
  2. review: constructor of object from field.

Constructors

Prism 

Fields

Instances

Category * Prism Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

match :: Prism AnyValue a -> Value t -> Maybe a Source #

Allows to match against given Value using provided prism for AnyValue.

mkAnyValuePrism :: (forall t. Value t -> Maybe a) -> (a -> Value tag) -> Prism AnyValue a Source #

Creates prism for AnyValue.

Value prisms

_Bool :: Prism AnyValue Bool Source #

Bool prism for AnyValue. Usually used with arrayOf combinator.

_Integer :: Prism AnyValue Integer Source #

Integer prism for AnyValue. Usually used with arrayOf combinator.

_Double :: Prism AnyValue Double Source #

Double prism for AnyValue. Usually used with arrayOf combinator.

_Text :: Prism AnyValue Text Source #

Text prism for AnyValue. Usually used with arrayOf combinator.

_Array :: Prism AnyValue a -> Prism AnyValue [a] Source #

Array prism for AnyValue. Usually used with arrayOf combinator.

Useful utility functions

unsafeArray :: [AnyValue] -> Value TArray Source #

Unsafe function for creating Array from list of AnyValue. This function assumes that every element in this list has the same type. Usually used when list of AnyValue is created using single prism.