Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added cs and ca convenience functions

  • Loading branch information...
commit 2832375ae2358121c26f62f7e4204d3a1be39b52 1 parent 6111a5d
@snoyberg authored
Showing with 11 additions and 1 deletion.
  1. +10 −0 Data/Convertible/Base.hs
  2. +1 −1  convertible-text.cabal
View
10 Data/Convertible/Base.hs
@@ -27,6 +27,8 @@ For license and copyright information, see the file COPYRIGHT
module Data.Convertible.Base( ConvertAttempt (..),
ConvertSuccess (..),
+ cs,
+ ca,
ConversionException (..),
convertUnsafe,
convertAttemptWrap
@@ -47,12 +49,20 @@ class ConvertAttempt a b where
-}
convertAttempt :: a -> Attempt b
+-- | A convenience synonym for 'convertAttempt'
+ca :: ConvertAttempt x y => x -> Attempt y
+ca = convertAttempt
+
{- | A typeclass that represents something that guarantees a successful conversion.
A @ConvertSuccess a b@ instance represents an @a@ that can be converted to a @b@. -}
class ConvertAttempt a b => ConvertSuccess a b where
{- | Convert @a@ to @b@. -}
convertSuccess :: a -> b
+-- | A convenience synonym for 'convertSuccess'
+cs :: ConvertSuccess x y => x -> y
+cs = convertSuccess
+
instance ConvertSuccess a b => ConvertAttempt a b where
convertAttempt = return . convertSuccess
View
2  convertible-text.cabal
@@ -1,5 +1,5 @@
Name: convertible-text
-Version: 0.0.0.1
+Version: 0.0.1
License: LGPL
Maintainer: Michael Snoyman <michael@snoyman.com>
Author: John Goerzen, Michael Snoyman
Please sign in to comment.
Something went wrong with that request. Please try again.