{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE DeriveGeneric #-} {-| Module : Data.Svfactor.Text.Space Copyright : (C) CSIRO 2017-2018 License : BSD3 Maintainer : George Wilson Stability : experimental Portability : non-portable A sum type for space characters -} module Data.Svfactor.Text.Separator ( Separator , HasSeparator (..) , comma, pipe, tab ) where import Control.Lens (Lens') -- | By what are your values separated? The answer is often 'comma', but not always. -- -- A 'Separator' is just a 'Char'. It could be a sum type instead, since it -- will usually be comma or pipe, but our preference has been to be open here -- so that you can use whatever you'd like. There are test cases, for example, -- ensuring that you're free to use null-byte separated values if you so desire. type Separator = Char -- | Classy lens for 'Separator' class HasSeparator c where separator :: Lens' c Separator instance HasSeparator Char where separator = id {-# INLINE separator #-} -- | The venerable comma separator. Used for CSV documents. comma :: Separator comma = ',' -- | The pipe separator. Used for PSV documents. pipe :: Separator pipe = '|' -- | Tab is a separator too - why not? tab :: Separator tab = '\t'