skulk-0.1.2.0: Eclectic collection of utility functions

Safe HaskellSafe
LanguageHaskell2010

Skulk.ToString

Description

Collection of functions for dealing with typesafe wrappers around strings (i.e. "newtype Name = Name String" etc) and string-like structures alike.

Synopsis

Documentation

class ToString w where Source #

Typeclass for a string-like structures that may expose the contained value.

Typical usage is something along the lines of

newtype LastName = LastName String deriving (IsString, ToString)

Minimal complete definition

toString

Methods

toString :: w -> String Source #

Exposes string content.

Instances

liftT :: (ToString a, IsString a) => (String -> String) -> a -> a Source #

Promotes a function.

shapeshift :: (ToString a, IsString b) => a -> b Source #

Converts from one string-like structure to another one.

emptyToNothing :: ToString a => a -> Maybe a Source #

Converts empty string to Nothing.

nothingToEmpty :: IsString a => Maybe a -> a Source #

Converts Nothing to empty string.