diff --git a/COPYING b/COPYING
new file mode 100644
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,510 @@
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+	51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard.  To achieve this, non-free programs must
+be allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at least
+    three years, to give the same user the materials specified in
+    Subsection 6a, above, for a charge no more than the cost of
+    performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James
+  Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/COPYRIGHT b/COPYRIGHT
new file mode 100644
--- /dev/null
+++ b/COPYRIGHT
@@ -0,0 +1,18 @@
+Copyright (C) 2009 John Goerzen <jgoerzen@complete.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+Please see COPYING for the license.
+
diff --git a/Data/Convertible/Base.hs b/Data/Convertible/Base.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Base.hs
@@ -0,0 +1,92 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE OverlappingInstances #-}
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE UndecidableInstances #-}
+{-
+Copyright (C) 2009 John Goerzen <jgoerzen@complete.org>
+
+All rights reserved.
+
+For license and copyright information, see the file COPYRIGHT
+
+-}
+
+{- |
+   Module     : Data.Convertible.Base
+   Copyright  : Copyright (C) 2009 John Goerzen
+   License    : LGPL
+
+   Maintainer : Michael Snoyman <michael@snoyman.com>
+   Stability  : provisional
+   Portability: portable
+
+-}
+
+module Data.Convertible.Base( ConvertAttempt (..),
+                              ConvertSuccess (..),
+                              ConversionException (..),
+                              convertUnsafe,
+                              convertAttemptWrap
+                             )
+where
+import Data.Attempt
+import Control.Exception (Exception)
+import Data.Typeable (Typeable)
+
+----------------------------------------------------------------------
+-- Conversions
+----------------------------------------------------------------------
+
+{- | A typeclass that represents something that can attempt a conversion.
+An @ConvertAttempt a b@ instance represents an @a@ that might be convertible to a @b@. -}
+class ConvertAttempt a b where
+    {- | Convert @a@ to @b@, returning 'Success' on success and 'Failure' on error.
+     -}
+    convertAttempt :: a -> Attempt b
+
+{- | 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
+
+instance ConvertSuccess a b => ConvertAttempt a b where
+    convertAttempt = return . convertSuccess
+
+{- | Any type can be converted to itself. -}
+instance ConvertSuccess a a where
+    convertSuccess = id
+
+{-
+{- | Lists of any convertible type can be converted. -}
+instance Convertible a b => Convertible [a] [b] where
+    safeConvert = mapM safeConvert
+-}
+
+{- | Convert from one type of data to another.  Raises an exception if there is
+an error with the conversion.  For a function that does not raise an exception
+in that case, see 'convertAttempt'. -}
+convertUnsafe :: ConvertAttempt a b => a -> b
+convertUnsafe = fromSuccess . convertAttempt
+
+{- | Wraps any 'Exception' which could occur during a 'convertAttempt'.
+-}
+data ConversionException = forall e. Exception e => ConversionException e
+    deriving Typeable
+instance Show ConversionException where
+    show (ConversionException e) = "ConversionException " ++ show e
+instance Exception ConversionException
+
+{- | Calls 'convertAttempt', wrapping any 'Exception's in a
+ 'ConversionException'
+-}
+convertAttemptWrap :: (ConvertAttempt a b,
+                       MonadFailure ConversionException m
+                      )
+                   => a
+                   -> m b
+convertAttemptWrap = attempt (failure . ConversionException) return .
+                     convertAttempt
diff --git a/Data/Convertible/Instances.hs b/Data/Convertible/Instances.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Instances.hs
@@ -0,0 +1,46 @@
+{-
+Copyright (C) 2009 John Goerzen <jgoerzen@complete.org>
+
+All rights reserved.
+
+For license and copyright information, see the file COPYRIGHT
+
+-}
+
+{- |
+   Module     : Data.Convertible.Instances
+   Copyright  : Copyright (C) 2009 John Goerzen
+   License    : LGPL
+
+   Maintainer : Michael Snoyman <michael@snoyman.com>
+   Stability  : provisional
+   Portability: portable
+
+Collection of ready-made 'ConvertSuccess' and 'ConvertAttempt' instances.  See
+each individual module for more docs:
+
+"Data.Convertible.Instances.C"
+
+"Data.Convertible.Instances.Map"
+
+"Data.Convertible.Instances.Num"
+
+"Data.Convertible.Instances.Time"
+
+"Data.Convertible.Instances.Text"
+
+"Data.Convertible.Instances.String"
+
+You can find a list of these instances at 'ConvertSuccess' and 'ConvertAttempt'.
+-}
+
+module Data.Convertible.Instances
+    ( module Data.Convertible.Instances.String
+    ) where
+
+import Data.Convertible.Instances.C()
+import Data.Convertible.Instances.Map()
+import Data.Convertible.Instances.Num()
+import Data.Convertible.Instances.Time()
+import Data.Convertible.Instances.Text()
+import Data.Convertible.Instances.String
diff --git a/Data/Convertible/Instances/C.hs b/Data/Convertible/Instances/C.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Instances/C.hs
@@ -0,0 +1,1517 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeSynonymInstances #-}
+{- |
+   Module     : Data.Convertible.Instances.C
+   Copyright  : Copyright (C) 2009 John Goerzen
+   License    : LGPL
+
+   Maintainer : Michael Snoyman <michael@snoyman.com>
+   Stability  : provisional
+   Portability: portable
+
+Numeric instances for Convertible for C types.  See comments in
+"Data.Convertible.Instances.Num".
+
+Copyright (C) 2009 John Goerzen <jgoerzen@complete.org>
+
+All rights reserved.
+
+For license and copyright information, see the file COPYRIGHT
+-}
+module Data.Convertible.Instances.C()
+where
+
+import Data.Convertible.Base
+import Data.Convertible.Utils
+import Data.Convertible.Instances.Num()
+import Data.Int
+import Data.Word
+import Foreign.C.Types
+
+-- remainder of this file generated by utils/genCinstances.hs
+
+-- Section 1
+instance ConvertAttempt CFloat Int where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CFloat Int8 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int8 CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CFloat Int16 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int16 CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CFloat Int32 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int32 CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CFloat Int64 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int64 CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CFloat Word where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CFloat Word8 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word8 CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CFloat Word16 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word16 CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CFloat Word32 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word32 CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CFloat Word64 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word64 CFloat where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Int where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Int8 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int8 CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Int16 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int16 CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Int32 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int32 CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Int64 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int64 CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Word where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Word8 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word8 CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Word16 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word16 CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Word32 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word32 CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CDouble Word64 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word64 CDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Int where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int CLDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Int8 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int8 CLDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Int16 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int16 CLDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Int32 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int32 CLDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Int64 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int64 CLDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Word where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word CLDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Word8 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word8 CLDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Word16 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word16 CLDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Word32 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word32 CLDouble where 
+    convertSuccess= fromIntegral
+
+instance ConvertAttempt CLDouble Word64 where 
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word64 CLDouble where 
+    convertSuccess= fromIntegral
+
+-- Section 2
+instance ConvertSuccess CFloat Double where
+    convertSuccess = realToFrac
+instance ConvertSuccess Double CFloat where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CFloat Float where
+    convertSuccess = realToFrac
+instance ConvertSuccess Float CFloat where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CFloat Rational where
+    convertSuccess = realToFrac
+instance ConvertSuccess Rational CFloat where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CDouble Double where
+    convertSuccess = realToFrac
+instance ConvertSuccess Double CDouble where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CDouble Float where
+    convertSuccess = realToFrac
+instance ConvertSuccess Float CDouble where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CDouble Rational where
+    convertSuccess = realToFrac
+instance ConvertSuccess Rational CDouble where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CLDouble Double where
+    convertSuccess = realToFrac
+instance ConvertSuccess Double CLDouble where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CLDouble Float where
+    convertSuccess = realToFrac
+instance ConvertSuccess Float CLDouble where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CLDouble Rational where
+    convertSuccess = realToFrac
+instance ConvertSuccess Rational CLDouble where
+    convertSuccess = realToFrac
+
+-- Section 3
+instance ConvertAttempt CChar Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int8 CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int16 CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int32 CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Int64 CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word8 CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word16 CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word32 CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertAttempt Word64 CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+-- Section 4
+instance ConvertAttempt CChar CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CChar CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSChar CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUChar CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CShort CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUShort CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CInt CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CUInt CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLong CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULong CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CSize CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CWchar CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CLLong CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt CULLong CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+-- Section 5
+instance ConvertSuccess CFloat CDouble where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CFloat CLDouble where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CDouble CFloat where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CDouble CLDouble where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CLDouble CFloat where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess CLDouble CDouble where
+    convertSuccess = realToFrac
+
+-- Section 6
+instance ConvertSuccess CFloat Integer where
+    convertSuccess = truncate
+instance ConvertSuccess Integer CFloat where
+    convertSuccess = fromIntegral
+
+instance ConvertSuccess CDouble Integer where
+    convertSuccess = truncate
+instance ConvertSuccess Integer CDouble where
+    convertSuccess = fromIntegral
+
+instance ConvertSuccess CLDouble Integer where
+    convertSuccess = truncate
+instance ConvertSuccess Integer CLDouble where
+    convertSuccess = fromIntegral
+
+-- Section 7
+instance ConvertSuccess CChar Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CSChar Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CUChar Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CShort Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CUShort Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CInt Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CUInt Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CLong Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CULong Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CULong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CSize Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CSize where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CWchar Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CLLong Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess CULLong Integer where
+    convertSuccess = fromIntegral
+instance ConvertAttempt Integer CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+-- Section 8o
+instance ConvertAttempt CChar Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CChar where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CSChar Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CSChar where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CUChar Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CUChar where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CShort Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CShort where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CUShort Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CUShort where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CInt Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CInt where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CUInt Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CUInt where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CLong Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CLong where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CULong Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CULong where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CSize Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CSize where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CWchar Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CWchar where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CLLong Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CLLong where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
+instance ConvertAttempt CULLong Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+instance ConvertAttempt Char CULLong where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+
diff --git a/Data/Convertible/Instances/Map.hs b/Data/Convertible/Instances/Map.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Instances/Map.hs
@@ -0,0 +1,33 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{- |
+   Module     : Data.Convertible.Instances.Map
+   Copyright  : Copyright (C) 2009 John Goerzen
+   License    : LGPL
+
+   Maintainer : Michael Snoyman <michael@snoyman.com>
+   Stability  : provisional
+   Portability: portable
+
+Instances to convert between Map and association list.
+
+Copyright (C) 2009 John Goerzen <jgoerzen@complete.org>
+
+All rights reserved.
+
+For license and copyright information, see the file COPYRIGHT
+
+-}
+
+module Data.Convertible.Instances.Map()
+where
+
+import Data.Convertible.Base
+
+import qualified Data.Map as Map
+
+instance Ord k => ConvertSuccess [(k, a)] (Map.Map k a) where
+    convertSuccess = Map.fromList
+
+instance ConvertSuccess (Map.Map k a) [(k, a)] where
+    convertSuccess = Map.toList
diff --git a/Data/Convertible/Instances/Num.hs b/Data/Convertible/Instances/Num.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Instances/Num.hs
@@ -0,0 +1,609 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeSynonymInstances #-}
+{- |
+   Module     : Data.Convertible.Instances.Num
+   Copyright  : Copyright (C) 2009 John Goerzen
+   License    : LGPL
+
+   Maintainer : Michael Snoyman <michael@snoyman.com>
+   Stability  : provisional
+   Portability: portable
+
+Numeric instances for Convertible.
+
+Copyright (C) 2009 John Goerzen <jgoerzen@complete.org>
+
+All rights reserved.
+
+For license and copyright information, see the file COPYRIGHT
+
+These instances perform conversion between numeric types such as Double, Int, Integer,
+Rational, and the like.  Here are some notes about the conversion process:
+
+Conversions from floating-point types such as Double to integral types are dune via the
+'truncate' function.  This is a somewhat arbitrary decision; if you need different
+behavior, you will have to write your own instance or manually perform the conversion.
+
+All conversions perform bounds checking.  If a value is too large for its destination
+type, you will get a 'ConvertError' informing you of this.  Note that this behavior
+differs from functions in the Haskell standard libraries, which will perform the
+conversion without error, but give you garbage in the end.
+
+Conversions do not perform precision checking; loss of precision is implied with certain
+conversions (for instance, Double to Float) and this is not an error.
+-}
+
+module Data.Convertible.Instances.Num()
+where
+
+import Data.Convertible.Base
+import Data.Convertible.Utils
+import Data.Int
+import Data.Word
+
+------------------------------------------------------------
+
+instance ConvertSuccess Integer Integer where
+    convertSuccess = id
+
+instance ConvertSuccess Char Integer where
+    convertSuccess = fromIntegral . fromEnum
+
+{- The following instances generated by util/genNumInstances.hs
+
+-}
+
+instance ConvertAttempt Integer Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Int Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Integer Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Int8 Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Integer Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Int16 Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Integer Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Int32 Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Integer Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Int64 Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Integer Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Word Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Integer Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Word8 Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Integer Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Word16 Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Integer Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Word32 Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Integer Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+instance ConvertSuccess Word64 Integer where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Int Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int8 Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int8 Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int8 Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int8 Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int8 Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int8 Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int8 Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int8 Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int8 Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int16 Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int16 Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int16 Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int16 Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int16 Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int16 Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int16 Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int16 Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int16 Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int32 Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int32 Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int32 Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int32 Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int32 Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int32 Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int32 Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int32 Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int32 Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int64 Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int64 Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int64 Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int64 Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int64 Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int64 Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int64 Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int64 Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Int64 Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word8 Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word8 Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word8 Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word8 Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word8 Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word8 Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word8 Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word8 Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word8 Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word16 Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word16 Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word16 Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word16 Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word16 Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word16 Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word16 Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word16 Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word16 Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word32 Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word32 Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word32 Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word32 Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word32 Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word32 Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word32 Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word32 Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word32 Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word64 Int where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word64 Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word64 Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word64 Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word64 Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word64 Word where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word64 Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word64 Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertAttempt Word64 Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral)
+
+instance ConvertSuccess Integer Double where
+    convertSuccess = fromIntegral
+instance ConvertSuccess Double Integer where
+    convertSuccess = truncate
+
+instance ConvertSuccess Integer Float where
+    convertSuccess = fromIntegral
+instance ConvertSuccess Float Integer where
+    convertSuccess = truncate
+
+instance ConvertSuccess Integer Rational where
+    convertSuccess = fromIntegral
+instance ConvertSuccess Rational Integer where
+    convertSuccess = truncate
+
+instance ConvertAttempt Double Int where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Double Int8 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int8 Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Double Int16 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int16 Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Double Int32 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int32 Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Double Int64 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int64 Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Double Word where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Double Word8 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word8 Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Double Word16 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word16 Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Double Word32 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word32 Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Double Word64 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word64 Double where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Int where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Int8 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int8 Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Int16 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int16 Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Int32 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int32 Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Int64 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int64 Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Word where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Word8 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word8 Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Word16 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word16 Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Word32 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word32 Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Float Word64 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word64 Float where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Int where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Int8 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int8 Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Int16 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int16 Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Int32 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int32 Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Int64 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Int64 Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Word where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Word8 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word8 Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Word16 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word16 Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Word32 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word32 Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertAttempt Rational Word64 where
+    convertAttempt = boundedConversion (return . truncate)
+instance ConvertSuccess Word64 Rational where
+    convertSuccess = fromIntegral
+
+instance ConvertSuccess Double Float where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess Double Rational where
+    convertSuccess = toRational
+
+instance ConvertSuccess Float Double where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess Float Rational where
+    convertSuccess = toRational
+
+instance ConvertSuccess Rational Double where
+    convertSuccess = realToFrac
+
+instance ConvertSuccess Rational Float where
+    convertSuccess = realToFrac
+
+instance ConvertAttempt Char Int where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Int Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
+instance ConvertAttempt Char Int8 where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Int8 Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
+instance ConvertAttempt Char Int16 where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Int16 Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
+instance ConvertAttempt Char Int32 where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Int32 Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
+instance ConvertAttempt Char Int64 where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Int64 Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
+instance ConvertAttempt Char Word where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Word Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
+instance ConvertAttempt Char Word8 where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Word8 Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
+instance ConvertAttempt Char Word16 where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Word16 Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
+instance ConvertAttempt Char Word32 where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Word32 Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
+instance ConvertAttempt Char Word64 where
+    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)
+instance ConvertAttempt Word64 Char where
+    convertAttempt = boundedConversion (return . toEnum . fromIntegral)
+
diff --git a/Data/Convertible/Instances/String.hs b/Data/Convertible/Instances/String.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Instances/String.hs
@@ -0,0 +1,181 @@
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+---------------------------------------------------------
+--
+-- Module        : Data.Convertible.Instances.String
+-- Copyright     : Michael Snoyman
+-- License       : BSD3
+--
+-- Maintainer    : Michael Snoyman <michael@snoyman.com>
+-- Stability     : Stable
+-- Portability   : portable
+--
+---------------------------------------------------------
+
+-- | Instances of 'ConvertSuccess' and 'ConvertAttempt' for 'String', along
+-- with instances for bytestrings and text (lazy and strict).
+module Data.Convertible.Instances.String
+    ( InvalidDayException (..)
+    , InvalidBoolException (..)
+    ) where
+
+import Data.Convertible.Base
+import Data.Typeable (Typeable)
+import Control.Exception (Exception)
+import qualified Safe.Failure as SF
+import Data.Convertible.Instances.Text ()
+import Data.Attempt
+import Control.Monad ((<=<))
+
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Lazy as BL
+import qualified Data.Text as ST
+import qualified Data.Text.Lazy as LT
+
+import Data.Time.Calendar
+import Data.Ratio (Ratio)
+
+{- Not needed yet
+fromString :: ConvertSuccess String a => String -> a
+fromString = convertSuccess
+-}
+
+fromStringA :: ConvertAttempt String a => String -> Attempt a
+fromStringA = convertAttempt
+
+toString :: ConvertSuccess a String => a -> String
+toString = convertSuccess
+
+-- Day
+data InvalidDayException = InvalidDayException String
+    deriving (Show, Typeable)
+instance Exception InvalidDayException
+
+instance ConvertSuccess Day [Char] where
+    convertSuccess = show
+instance ConvertAttempt [Char] Day where
+    convertAttempt s = wrapFailure (const $ InvalidDayException s) $ do
+        SF.assert (length s == 10) () $ InvalidDayException s
+        y <- SF.read $ take 4 s
+        m <- SF.read $ take 2 $ drop 5 s
+        d <- SF.read $ take 2 $ drop 8 s
+        return $ fromGregorian y m d
+
+-- Bool
+data InvalidBoolException = InvalidBoolException String
+    deriving (Show, Typeable)
+instance Exception InvalidBoolException
+
+instance ConvertSuccess Bool [Char] where
+    convertSuccess b = if b then "true" else "false"
+instance ConvertAttempt [Char] Bool where
+    convertAttempt s =
+        case s of
+            -- list comes from http://yaml.org/type/bool.html
+            "y" -> return True
+            "Y" -> return True
+            "yes" -> return True
+            "Yes" -> return True
+            "YES" -> return True
+            "true" -> return True
+            "True" -> return True
+            "TRUE" -> return True
+            "on" -> return True
+            "On" -> return True
+            "ON" -> return True
+
+            "n" -> return False
+            "N" -> return False
+            "no" -> return False
+            "No" -> return False
+            "NO" -> return False
+            "false" -> return False
+            "False" -> return False
+            "FALSE" -> return False
+            "off" -> return False
+            "Off" -> return False
+            "OFF" -> return False
+
+            _ -> failure $ InvalidBoolException s
+
+-- Int
+instance ConvertSuccess Int [Char] where
+    convertSuccess = show
+instance ConvertAttempt [Char] Int where
+    convertAttempt = SF.read
+
+-- Rational
+instance ConvertSuccess (Ratio Integer) [Char] where
+    convertSuccess = show
+instance ConvertAttempt [Char] (Ratio Integer) where
+    convertAttempt = SF.read
+
+-- Instances for bytestrings and text (generated by utils/StringHelper.hs)
+
+instance ConvertAttempt BS.ByteString Day where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt BL.ByteString Day where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt ST.Text Day where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt LT.Text Day where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt BS.ByteString Bool where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt BL.ByteString Bool where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt ST.Text Bool where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt LT.Text Bool where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt BS.ByteString Int where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt BL.ByteString Int where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt ST.Text Int where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt LT.Text Int where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt BS.ByteString (Ratio Integer) where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt BL.ByteString (Ratio Integer) where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt ST.Text (Ratio Integer) where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertAttempt LT.Text (Ratio Integer) where
+    convertAttempt = fromStringA <=< convertAttempt
+instance ConvertSuccess Day BS.ByteString where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Day BL.ByteString where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Day ST.Text where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Day LT.Text where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Bool BS.ByteString where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Bool BL.ByteString where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Bool ST.Text where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Bool LT.Text where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Int BS.ByteString where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Int BL.ByteString where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Int ST.Text where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess Int LT.Text where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess (Ratio Integer) BS.ByteString where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess (Ratio Integer) BL.ByteString where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess (Ratio Integer) ST.Text where
+    convertSuccess = convertSuccess . toString
+instance ConvertSuccess (Ratio Integer) LT.Text where
+    convertSuccess = convertSuccess . toString
diff --git a/Data/Convertible/Instances/Text.hs b/Data/Convertible/Instances/Text.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Instances/Text.hs
@@ -0,0 +1,84 @@
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+---------------------------------------------------------
+--
+-- Module        : Data.Convertible.Instances.Text
+-- Copyright     : Michael Snoyman
+-- License       : BSD3
+--
+-- Maintainer    : Michael Snoyman <michael@snoyman.com>
+-- Stability     : Stable
+-- Portability   : portable
+--
+---------------------------------------------------------
+
+-- | Instances to convert amongst 'String's, strict bytestrings, lazy
+-- bytestrings, strict text and lazy text.
+module Data.Convertible.Instances.Text () where
+
+import Data.Convertible.Base
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Lazy as BL
+import qualified Data.Text as ST
+import qualified Data.Text.Lazy as LT
+import qualified Data.Text.Encoding as STE
+import qualified Data.Text.Lazy.Encoding as LTE
+
+toST :: ConvertSuccess a ST.Text => a -> ST.Text
+toST = convertSuccess
+
+toLT :: ConvertSuccess a LT.Text => a -> LT.Text
+toLT = convertSuccess
+
+instance ConvertSuccess [Char] [Char] where
+    convertSuccess = id
+instance ConvertSuccess [Char] BS.ByteString where
+    convertSuccess = convertSuccess . toST
+instance ConvertSuccess [Char] BL.ByteString where
+    convertSuccess = convertSuccess . toLT
+instance ConvertSuccess [Char] ST.Text where
+    convertSuccess = ST.pack
+instance ConvertSuccess [Char] LT.Text where
+    convertSuccess = LT.pack
+instance ConvertSuccess BS.ByteString [Char] where
+    convertSuccess = convertSuccess . toST
+instance ConvertSuccess BS.ByteString BS.ByteString where
+    convertSuccess = id
+instance ConvertSuccess BS.ByteString BL.ByteString where
+    convertSuccess = BL.fromChunks . return
+instance ConvertSuccess BS.ByteString ST.Text where
+    convertSuccess = STE.decodeUtf8
+instance ConvertSuccess BS.ByteString LT.Text where
+    convertSuccess = convertSuccess . toST
+instance ConvertSuccess BL.ByteString [Char] where
+    convertSuccess = convertSuccess . toLT
+instance ConvertSuccess BL.ByteString BS.ByteString where
+    convertSuccess = BS.concat . BL.toChunks
+instance ConvertSuccess BL.ByteString BL.ByteString where
+    convertSuccess = id
+instance ConvertSuccess BL.ByteString ST.Text where
+    convertSuccess = convertSuccess . BS.concat . BL.toChunks
+instance ConvertSuccess BL.ByteString LT.Text where
+    convertSuccess = LTE.decodeUtf8
+instance ConvertSuccess ST.Text [Char] where
+    convertSuccess = ST.unpack
+instance ConvertSuccess ST.Text BS.ByteString where
+    convertSuccess = STE.encodeUtf8
+instance ConvertSuccess ST.Text BL.ByteString where
+    convertSuccess = convertSuccess . STE.encodeUtf8
+instance ConvertSuccess ST.Text ST.Text where
+    convertSuccess = id
+instance ConvertSuccess ST.Text LT.Text where
+    convertSuccess = LT.fromChunks . return
+instance ConvertSuccess LT.Text [Char] where
+    convertSuccess = LT.unpack
+instance ConvertSuccess LT.Text BS.ByteString where
+    convertSuccess = convertSuccess . toST
+instance ConvertSuccess LT.Text BL.ByteString where
+    convertSuccess = LTE.encodeUtf8
+instance ConvertSuccess LT.Text ST.Text where
+    convertSuccess = ST.concat . LT.toChunks
+instance ConvertSuccess LT.Text LT.Text where
+    convertSuccess = id
diff --git a/Data/Convertible/Instances/Time.hs b/Data/Convertible/Instances/Time.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Instances/Time.hs
@@ -0,0 +1,394 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeSynonymInstances #-}
+{- |
+   Module     : Data.ConvertAttempt.Instances.Time
+   Copyright  : Copyright (C) 2009 John Goerzen
+   License    : LGPL
+
+   Maintainer : Michael Snoyman <michael@snoyman.com>
+   Stability  : provisional
+   Portability: portable
+
+Instances to convert between various time structures, both old- and new-style.
+
+At present, this module does not do full input validation.  That is, it is possible
+to get an exception rather than a Left result from these functions if your input is
+invalid, particularly when converting from the old-style System.Time structures.
+
+Copyright (C) 2009 John Goerzen <jgoerzen@complete.org>
+
+All rights reserved.
+
+For license and copyright information, see the file COPYRIGHT
+
+-}
+
+module Data.Convertible.Instances.Time()
+where
+
+import Data.Convertible.Base
+import Data.Convertible.Utils
+import Data.Convertible.Instances.Num()
+import qualified System.Time as ST
+import Data.Time
+import Data.Time.Clock
+import Data.Time.Clock.POSIX
+import Data.Time.Calendar.OrdinalDate
+#ifndef TIME_GTE_113
+import Data.Typeable
+#endif
+import Data.Ratio
+import Foreign.C.Types
+
+----------------------------------------------------------------------
+-- Intra-System.Time stuff
+----------------------------------------------------------------------
+
+instance ConvertAttempt ST.ClockTime ST.CalendarTime where
+    convertAttempt = return . ST.toUTCTime
+instance ConvertSuccess ST.ClockTime ST.CalendarTime where
+    convertSuccess = ST.toUTCTime
+
+instance ConvertAttempt ST.CalendarTime ST.ClockTime where
+    convertAttempt = return . ST.toClockTime
+instance ConvertSuccess ST.CalendarTime ST.ClockTime where
+    convertSuccess = ST.toClockTime
+
+instance ConvertAttempt ST.ClockTime Integer where
+    convertAttempt (ST.TOD x _) = return x
+instance ConvertSuccess ST.ClockTime Integer where
+    convertSuccess (ST.TOD x _) = x
+
+instance ConvertAttempt Integer ST.ClockTime where
+    convertAttempt x = return $ ST.TOD x 0
+instance ConvertSuccess Integer ST.ClockTime where
+    convertSuccess x = ST.TOD x 0
+
+----------------------------------------------------------------------
+-- Intra-Data.Time stuff
+----------------------------------------------------------------------
+
+------------------------------ POSIX and UTC times
+
+#ifndef TIME_GTE_113
+instance Typeable NominalDiffTime where
+    typeOf _ = mkTypeName "NominalDiffTime"
+
+instance Typeable UTCTime where
+    typeOf _ = mkTypeName "UTCTime"
+#endif
+
+{- Covered under Real a
+instance ConvertAttempt Rational POSIXTime where
+    convertAttempt = return . fromRational
+-}
+
+instance ConvertSuccess Rational POSIXTime where
+    convertSuccess = fromRational
+instance ConvertSuccess Integer POSIXTime where
+    convertSuccess = fromInteger
+instance ConvertSuccess Int POSIXTime where
+    convertSuccess = fromIntegral
+instance ConvertSuccess Double POSIXTime where
+    convertSuccess = realToFrac
+
+instance ConvertAttempt Rational POSIXTime where
+    convertAttempt = return . fromRational
+instance ConvertAttempt Integer POSIXTime where
+    convertAttempt = return . fromInteger
+instance ConvertAttempt Int POSIXTime where
+    convertAttempt = return . fromIntegral
+instance ConvertAttempt Double POSIXTime where
+    convertAttempt = return . realToFrac
+
+instance ConvertSuccess POSIXTime Integer where
+    convertSuccess = truncate
+instance ConvertSuccess POSIXTime Rational where
+    convertSuccess = toRational
+instance ConvertSuccess POSIXTime Double where
+    convertSuccess = realToFrac
+
+instance ConvertAttempt POSIXTime Integer where
+    convertAttempt = return . truncate
+instance ConvertAttempt POSIXTime Rational where
+    convertAttempt = return . toRational
+instance ConvertAttempt POSIXTime Double where
+    convertAttempt = return . realToFrac
+instance ConvertAttempt POSIXTime Int where
+    convertAttempt = boundedConversion (return . truncate)
+
+instance ConvertSuccess POSIXTime UTCTime where
+    convertSuccess = posixSecondsToUTCTime
+instance ConvertSuccess UTCTime POSIXTime where
+    convertSuccess = utcTimeToPOSIXSeconds
+
+instance ConvertAttempt POSIXTime UTCTime where
+    convertAttempt = return . posixSecondsToUTCTime
+instance ConvertAttempt UTCTime POSIXTime where
+    convertAttempt = return . utcTimeToPOSIXSeconds
+
+instance ConvertSuccess Rational UTCTime where
+    convertSuccess = posixSecondsToUTCTime . convertSuccess
+instance ConvertSuccess Integer UTCTime where
+    convertSuccess = posixSecondsToUTCTime . convertSuccess
+instance ConvertSuccess Int UTCTime where
+    convertSuccess = posixSecondsToUTCTime . convertSuccess
+instance ConvertSuccess Double UTCTime where
+    convertSuccess = posixSecondsToUTCTime . convertSuccess
+
+instance ConvertAttempt Rational UTCTime where
+    convertAttempt a = convertAttempt a >>= return . posixSecondsToUTCTime
+instance ConvertAttempt Integer UTCTime where
+    convertAttempt a = convertAttempt a >>= return . posixSecondsToUTCTime
+instance ConvertAttempt Int UTCTime where
+    convertAttempt a = convertAttempt a >>= return . posixSecondsToUTCTime
+instance ConvertAttempt Double UTCTime where
+    convertAttempt a = convertAttempt a >>= return . posixSecondsToUTCTime
+
+instance ConvertSuccess UTCTime Rational where
+    convertSuccess = convertSuccess . utcTimeToPOSIXSeconds
+instance ConvertSuccess UTCTime Integer where
+    convertSuccess = convertSuccess . utcTimeToPOSIXSeconds
+instance ConvertSuccess UTCTime Double where
+    convertSuccess = convertSuccess . utcTimeToPOSIXSeconds
+
+instance ConvertAttempt UTCTime Rational where
+    convertAttempt = convertAttempt . utcTimeToPOSIXSeconds
+instance ConvertAttempt UTCTime Integer where
+    convertAttempt = convertAttempt . utcTimeToPOSIXSeconds
+instance ConvertAttempt UTCTime Double where
+    convertAttempt = convertAttempt . utcTimeToPOSIXSeconds
+instance ConvertAttempt UTCTime Int where
+    convertAttempt = boundedConversion (convertAttempt . utcTimeToPOSIXSeconds)
+
+------------------------------ LocalTime stuff
+
+instance ConvertSuccess UTCTime ZonedTime where
+    convertSuccess = utcToZonedTime utc
+instance ConvertSuccess POSIXTime ZonedTime where
+    convertSuccess = utcToZonedTime utc . posixSecondsToUTCTime
+instance ConvertSuccess ZonedTime UTCTime where
+    convertSuccess = zonedTimeToUTC
+instance ConvertSuccess ZonedTime POSIXTime where
+    convertSuccess = utcTimeToPOSIXSeconds . zonedTimeToUTC
+
+instance ConvertAttempt UTCTime ZonedTime where
+    convertAttempt = return . utcToZonedTime utc
+instance ConvertAttempt POSIXTime ZonedTime where
+    convertAttempt = return . utcToZonedTime utc . posixSecondsToUTCTime
+instance ConvertAttempt ZonedTime UTCTime where
+    convertAttempt = return . zonedTimeToUTC
+instance ConvertAttempt ZonedTime POSIXTime where
+    convertAttempt = return . utcTimeToPOSIXSeconds . zonedTimeToUTC
+
+{- Too obvious?
+instance ConvertAttempt LocalTime Day where
+    convertAttempt = return . localDay
+instance ConvertAttempt LocalTime TimeOfDay where
+    convertAttempt = return . localTimeOfDay
+-}
+
+----------------------------------------------------------------------
+-- Conversions between old and new time
+----------------------------------------------------------------------
+instance ConvertSuccess ST.CalendarTime ZonedTime where
+    convertSuccess ct = ZonedTime {
+     zonedTimeToLocalTime = LocalTime {
+       localDay = fromGregorian (fromIntegral $ ST.ctYear ct) 
+                  (1 + (fromEnum $ ST.ctMonth ct))
+                  (ST.ctDay ct),
+       localTimeOfDay = TimeOfDay {
+         todHour = ST.ctHour ct,
+         todMin = ST.ctMin ct,
+         todSec = (fromIntegral $ ST.ctSec ct) + 
+                  fromRational (ST.ctPicosec ct % 1000000000000)
+                        }
+                            },
+     zonedTimeZone = TimeZone {
+                       timeZoneMinutes = ST.ctTZ ct `div` 60,
+                       timeZoneSummerOnly = ST.ctIsDST ct,
+                       timeZoneName = ST.ctTZName ct}
+}
+
+instance ConvertSuccess ST.CalendarTime POSIXTime where
+    convertSuccess = convertSuccessVia (undefined::ST.ClockTime)
+instance ConvertSuccess ST.CalendarTime UTCTime where
+    convertSuccess = convertSuccessVia (undefined::POSIXTime)
+
+instance ConvertAttempt ST.CalendarTime POSIXTime where
+    convertAttempt = convertAttemptVia (undefined::ST.ClockTime)
+instance ConvertAttempt ST.CalendarTime UTCTime where
+    convertAttempt = convertAttemptVia (undefined::POSIXTime)
+
+instance ConvertSuccess ST.ClockTime POSIXTime where
+    convertSuccess (ST.TOD x y) = fromRational $ 
+                                        fromInteger x + fromRational (y % 1000000000000)
+
+instance ConvertSuccess ST.ClockTime UTCTime where
+    convertSuccess = convertSuccessVia (undefined::POSIXTime)
+instance ConvertSuccess ST.ClockTime ZonedTime where
+    convertSuccess = convertSuccessVia (undefined::UTCTime)
+instance ConvertSuccess ZonedTime ST.ClockTime where
+    convertSuccess = convertSuccessVia (undefined::POSIXTime)
+
+instance ConvertAttempt ST.ClockTime UTCTime where
+    convertAttempt = convertAttemptVia (undefined::POSIXTime)
+instance ConvertAttempt ST.ClockTime ZonedTime where
+    convertAttempt = convertAttemptVia (undefined::UTCTime)
+instance ConvertAttempt ZonedTime ST.ClockTime where
+    convertAttempt = convertAttemptVia (undefined::POSIXTime)
+
+instance ConvertSuccess POSIXTime ST.ClockTime where
+    convertSuccess x = ST.TOD rsecs rpico
+        where rsecs = floor x
+              rpico = truncate $ abs $ 1000000000000 * (x - (fromIntegral rsecs))
+
+instance ConvertSuccess UTCTime ST.ClockTime where
+    convertSuccess = convertSuccess . utcTimeToPOSIXSeconds
+instance ConvertAttempt UTCTime ST.ClockTime where
+    convertAttempt = convertAttempt . utcTimeToPOSIXSeconds
+
+instance ConvertSuccess ZonedTime ST.CalendarTime where
+    convertSuccess zt = ST.CalendarTime {
+            ST.ctYear = fromIntegral year,
+            ST.ctMonth = toEnum (month - 1),
+            ST.ctDay = day,
+            ST.ctHour = todHour ltod,
+            ST.ctMin = todMin ltod,
+            ST.ctSec = secs,
+            ST.ctPicosec = pico,
+            ST.ctWDay = toEnum . snd . sundayStartWeek . localDay . zonedTimeToLocalTime $ zt,
+            ST.ctYDay = (snd . toOrdinalDate . localDay . zonedTimeToLocalTime $ zt) - 1,
+            ST.ctTZName = timeZoneName . zonedTimeZone $ zt,
+            ST.ctTZ = (timeZoneMinutes . zonedTimeZone $ zt) * 60,
+            ST.ctIsDST = timeZoneSummerOnly . zonedTimeZone $ zt
+          }
+        where (year, month, day) = toGregorian . localDay . zonedTimeToLocalTime $ zt
+              ltod = localTimeOfDay . zonedTimeToLocalTime $ zt
+              secs = (truncate . todSec $ ltod)::Int
+              picoRational = toRational (todSec ltod) - toRational secs
+              pico = truncate (picoRational * 1000000000000)
+
+instance ConvertSuccess POSIXTime ST.CalendarTime where
+    convertSuccess = convertSuccessVia (undefined::ZonedTime)
+instance ConvertSuccess UTCTime ST.CalendarTime where
+    convertSuccess = convertSuccess . utcTimeToPOSIXSeconds
+
+instance ConvertAttempt POSIXTime ST.CalendarTime where
+    convertAttempt = convertAttemptVia (undefined::ZonedTime)
+instance ConvertAttempt UTCTime ST.CalendarTime where
+    convertAttempt = convertAttempt . utcTimeToPOSIXSeconds
+
+instance ConvertSuccess ST.TimeDiff NominalDiffTime where
+    {- This is a clever hack.  We convert the TimeDiff to a ClockTime, applying
+       it as a diff vs. the epoch.  Converting this ClockTime to a POSIXTime yiels
+       the NominalDiffTime we want, since a POSIXTime is a NominalDiffTime vs. the
+       epoch. -}
+    convertSuccess td = convertSuccess clockTime
+        where clockTime = ST.addToClockTime td (ST.TOD 0 0)
+instance ConvertSuccess NominalDiffTime ST.TimeDiff where
+    {- Similar clever hack as above. -}
+    convertSuccess ndt =
+       let clockt = convertSuccess ndt
+        in ST.diffClockTimes clockt (ST.TOD 0 0)
+
+instance ConvertSuccess Integer ST.TimeDiff where
+    convertSuccess = convertSuccessVia (undefined::NominalDiffTime)
+instance ConvertSuccess Double ST.TimeDiff where
+    convertSuccess = convertSuccessVia (undefined::NominalDiffTime)
+instance ConvertSuccess ST.TimeDiff Integer where
+    convertSuccess = convertSuccessVia (undefined :: NominalDiffTime)
+instance ConvertSuccess ST.TimeDiff Rational where
+    convertSuccess = convertSuccessVia (undefined :: NominalDiffTime)
+instance ConvertSuccess ST.TimeDiff Double where
+    convertSuccess = convertSuccessVia (undefined :: NominalDiffTime)
+
+instance ConvertAttempt Integer ST.TimeDiff where
+    convertAttempt = convertAttemptVia (undefined::NominalDiffTime)
+instance ConvertAttempt Double ST.TimeDiff where
+    convertAttempt = convertAttemptVia (undefined::NominalDiffTime)
+instance ConvertAttempt ST.TimeDiff Integer where
+    convertAttempt = convertAttemptVia (undefined :: NominalDiffTime)
+instance ConvertAttempt ST.TimeDiff Rational where
+    convertAttempt = convertAttemptVia (undefined :: NominalDiffTime)
+instance ConvertAttempt ST.TimeDiff Double where
+    convertAttempt = convertAttemptVia (undefined :: NominalDiffTime)
+
+----------------------------------------------------------------------
+-- Foreign.C Types
+----------------------------------------------------------------------
+
+instance ConvertSuccess CTime POSIXTime where
+    convertSuccess = realToFrac
+instance ConvertSuccess POSIXTime CTime where
+    convertSuccess = fromInteger . truncate
+
+instance ConvertSuccess CTime Integer where
+    convertSuccess = truncate . toRational
+instance ConvertSuccess Integer CTime where
+    convertSuccess = fromInteger
+
+instance ConvertSuccess CTime Double where
+    convertSuccess = realToFrac
+instance ConvertSuccess Double CTime where
+    convertSuccess = fromInteger . truncate
+
+instance ConvertAttempt CTime POSIXTime where
+    convertAttempt = return . realToFrac
+instance ConvertAttempt POSIXTime CTime where
+    convertAttempt = return . fromInteger . truncate
+
+instance ConvertAttempt CTime Integer where
+    convertAttempt = return . truncate . toRational
+instance ConvertAttempt Integer CTime where
+    convertAttempt = return . fromInteger
+
+instance ConvertAttempt CTime Double where
+    convertAttempt = return . realToFrac
+instance ConvertAttempt Double CTime where
+    convertAttempt = return . fromInteger . truncate
+
+instance ConvertAttempt CTime Int where
+    convertAttempt x = do r1 <- convertAttempt x
+                          boundedConversion (return . fromInteger) r1
+instance ConvertAttempt Int CTime where
+    convertAttempt = convertAttempt . toInteger
+instance ConvertSuccess Int CTime where
+    convertSuccess = convertSuccess . toInteger
+
+instance ConvertSuccess CTime UTCTime where
+    convertSuccess = convertSuccessVia (undefined :: POSIXTime)
+instance ConvertSuccess UTCTime CTime where
+    convertSuccess = convertSuccessVia (undefined :: POSIXTime)
+instance ConvertAttempt CTime UTCTime where
+    convertAttempt = convertAttemptVia (undefined :: POSIXTime)
+instance ConvertAttempt UTCTime CTime where
+    convertAttempt = convertAttemptVia (undefined :: POSIXTime)
+
+instance ConvertSuccess CTime ST.ClockTime where
+    convertSuccess = convertSuccessVia (undefined :: POSIXTime)
+instance ConvertSuccess ST.ClockTime CTime where
+    convertSuccess = convertSuccessVia (undefined :: POSIXTime)
+instance ConvertAttempt CTime ST.ClockTime where
+    convertAttempt = convertAttemptVia (undefined :: POSIXTime)
+instance ConvertAttempt ST.ClockTime CTime where
+    convertAttempt = convertAttemptVia (undefined :: POSIXTime)
+
+instance ConvertSuccess CTime ST.CalendarTime where
+    convertSuccess = convertSuccessVia (undefined::POSIXTime)
+instance ConvertSuccess ST.CalendarTime CTime where
+    convertSuccess = convertSuccessVia (undefined::POSIXTime)
+instance ConvertAttempt CTime ST.CalendarTime where
+    convertAttempt = convertAttemptVia (undefined::POSIXTime)
+instance ConvertAttempt ST.CalendarTime CTime where
+    convertAttempt = convertAttemptVia (undefined::POSIXTime)
+
+instance ConvertSuccess CTime ZonedTime where
+    convertSuccess = convertSuccessVia (undefined::POSIXTime)
+instance ConvertSuccess ZonedTime CTime where
+    convertSuccess = convertSuccessVia (undefined::POSIXTime)
+instance ConvertAttempt CTime ZonedTime where
+    convertAttempt = convertAttemptVia (undefined::POSIXTime)
+instance ConvertAttempt ZonedTime CTime where
+    convertAttempt = convertAttemptVia (undefined::POSIXTime)
diff --git a/Data/Convertible/Text.hs b/Data/Convertible/Text.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Text.hs
@@ -0,0 +1,40 @@
+{-
+Copyright (C) 2009 John Goerzen <jgoerzen@complete.org>
+
+All rights reserved.
+
+For license and copyright information, see the file COPYRIGHT
+
+-}
+
+{- |
+   Module     : Data.Convertible.Text
+   Copyright  : Copyright (C) 2009 John Goerzen
+   License    : LGPL
+
+   Maintainer : Michael Snoyman <michael@snoyman.com>
+   Stability  : provisional
+   Portability: portable
+
+This is a library to provide a uniform interface for safe conversions between
+different types of data.  To get started reading about it, consult:
+
+"Data.Convertible.Base" for information about the conversions themselves
+
+"Data.Convertible.Utils" for helpful tools for people writing 'Convertible' instances
+
+"Data.Convertible.Instances" for a large collection of ready-built 'Convertible' instances
+
+You can import these modules individually, or this module will export the entire library
+for you.
+-}
+
+module Data.Convertible.Text (
+                         module Data.Convertible.Base,
+                         module Data.Convertible.Utils,
+                         module Data.Convertible.Instances
+                         )
+where
+import Data.Convertible.Base
+import Data.Convertible.Utils
+import Data.Convertible.Instances
diff --git a/Data/Convertible/Utils.hs b/Data/Convertible/Utils.hs
new file mode 100644
--- /dev/null
+++ b/Data/Convertible/Utils.hs
@@ -0,0 +1,103 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-
+Copyright (C) 2009 John Goerzen <jgoerzen@complete.org>
+
+All rights reserved.
+
+For license and copyright information, see the file COPYRIGHT
+
+-}
+
+{- |
+   Module     : Data.Convertible.Utils
+   Copyright  : Copyright (C) 2009 John Goerzen
+   License    : LGPL
+
+   Maintainer : Michael Snoyman <michael@snoyman.com>
+   Stability  : provisional
+   Portability: portable
+
+-}
+
+module Data.Convertible.Utils(boundedConversion,
+                             ConvertBoundsException (..),
+                             mkTypeName,
+                             convertAttemptVia,
+                             convertSuccessVia
+                             )
+where
+import Data.Convertible.Base
+import Data.Typeable
+import Data.Attempt
+import Control.Exception (Exception)
+
+{- | Utility function to perform bounds checking as part of a conversion.
+
+Does this be examining the bounds of the destination type, converting to the type of
+the source via 'safeConvert', comparing to the source value.  Results in an error
+if the conversion is out of bounds. -}
+boundedConversion :: (Ord a, Bounded b, Show a, Show b,
+                      ConvertAttempt a Integer,
+                      ConvertAttempt b Integer,
+                      Typeable a, Typeable b) =>
+                     (a -> Attempt b) -- ^ Function to do the conversion
+                  -> a                -- ^ Input data
+                  -> Attempt b        -- ^ Result
+boundedConversion func inp =
+    do result <- func inp
+       let smallest = minBound `asTypeOf` result
+           biggest  = maxBound `asTypeOf` result
+       smallest' <- convertAttempt smallest :: Attempt Integer
+       biggest'  <- convertAttempt biggest  :: Attempt Integer
+       inp'      <- convertAttempt inp      :: Attempt Integer
+       if inp' < smallest' || inp' > biggest'
+          then failure $ ConvertBoundsException smallest biggest inp
+          else return result
+
+data ConvertBoundsException v a = ConvertBoundsException v v a
+    deriving Typeable
+instance (Show v, Show a) => Show (ConvertBoundsException v a) where
+    show (ConvertBoundsException x y a) =
+        "Input value outside of bounds: " ++ show (x, y) ++ ": " ++ show a
+instance (Show v, Show a, Typeable v, Typeable a)
+    => Exception (ConvertBoundsException v a)
+
+{- | Useful for defining 'Typeable' instances.  Example:
+
+>instance Typeable TimeOfDay where
+>    typeOf _ = mkTypeName "TimeOfDay"
+-}
+mkTypeName :: String -> TypeRep
+mkTypeName name = mkTyConApp (mkTyCon name) []
+
+{- | Useful for defining conversions that are implemented in terms of other
+conversions via an intermediary type. Instead of:
+
+>instance Convertible CalendarTime POSIXTime where
+>    safeConvert a = do r <- safeConvert a
+>                       safeConvert (r :: ClockTime)
+
+we can now write:
+
+>instance Convertible CalendarTime POSIXTime where
+>    safeConvert = convertVia (undefined::ClockTime)
+
+which does the same thing -- converts a CalendarTime to a ClockTime, then a
+ClockTime to a POSIXTime, both using existing 'Convertible' instances.
+ -}
+convertAttemptVia :: (ConvertAttempt a b, ConvertAttempt b c) =>
+              b                 -- ^ Dummy data to establish intermediate type - can be undefined
+           -> a                 -- ^ Input value
+           -> Attempt c         -- ^ Result
+convertAttemptVia dummy inp =
+    do r1 <- convertAttempt inp
+       convertAttempt (r1 `asTypeOf` dummy)
+
+{- | Same as 'convertAttemptVia' for 'ConvertSuccess' -}
+convertSuccessVia :: (ConvertSuccess a b, ConvertSuccess b c) =>
+              b                 -- ^ Dummy data to establish intermediate type - can be undefined
+           -> a                 -- ^ Input value
+           -> c                 -- ^ Result
+convertSuccessVia dummy inp =
+    convertSuccess $ convertSuccess inp `asTypeOf` dummy
diff --git a/Setup.lhs b/Setup.lhs
new file mode 100644
--- /dev/null
+++ b/Setup.lhs
@@ -0,0 +1,5 @@
+#!/usr/bin/env runhaskell
+
+> import Distribution.Simple
+
+> main = defaultMain
diff --git a/convertible-text.cabal b/convertible-text.cabal
new file mode 100644
--- /dev/null
+++ b/convertible-text.cabal
@@ -0,0 +1,53 @@
+Name: convertible-text
+Version: 0.0.0
+License: LGPL
+Maintainer: Michael Snoyman <michael@snoyman.com>
+Author: John Goerzen, Michael Snoyman
+Copyright: Copyright (c) 2009-2009 John Goerzen
+license-file: COPYRIGHT
+extra-source-files: COPYING, utils/genCinstances.hs
+homepage: http://github.com/snoyberg/convertible/tree/text
+Category: Data, Failure
+synopsis: Typeclasses and instances for converting between types
+Description:
+ This is a port of John Goerzen's convertible package, intended to distinguish between conversions which are guaranteed to succeed and those which might fail.  It uses the attempt package, which in turn uses the failure package, so that this package is fully compatible with the failure framework.
+ .
+ This package currently contains all of the typeclasses and instances for convertible.  However, as these features are ported to the convertible package, this package will be left with only the instances for converting to and from text types (String, ByteString (lazy and strict) and Text (lazy and strict).
+ .
+ Be aware that conversions to and from bytestrings assume UTF-8 encoding. If a different encoding is desired, you can use a newtype wrapper and declare an instance of @ConvertAttempt@ or @ConvertSuccess@ on it.
+ .
+ The main module to import is "Data.Convertible.Text".
+Stability: Stable
+Build-Type: Simple
+
+Cabal-Version: >=1.2
+
+flag time_gte_113
+  description: time > 1.1.3 has defined some more instances so omit them here
+
+library
+  Build-Depends: base >= 4 && < 5,
+                 old-time >= 1.0.0.2 && < 1.1,
+                 containers >= 0.2.0.1 && < 0.3,
+                 text >= 0.5 && < 0.6,
+                 bytestring >= 0.9.1.4 && < 0.10,
+                 safe-failure >= 0.4 && < 0.5,
+                 attempt >= 0.2.0 && < 0.3
+  if flag(time_gte_113)
+    Build-Depends: time>=1.1.3 && <= 1.1.4
+    CPP-OPTIONS: -DTIME_GTE_113
+  else
+    Build-Depends: time<1.1.3
+
+  GHC-Options: -Wall -fno-warn-orphans
+
+  Exposed-Modules: Data.Convertible.Text,
+                   Data.Convertible.Base,
+                   Data.Convertible.Utils,
+                   Data.Convertible.Instances,
+                   Data.Convertible.Instances.C,
+                   Data.Convertible.Instances.Map,
+                   Data.Convertible.Instances.Num,
+                   Data.Convertible.Instances.Time,
+                   Data.Convertible.Instances.Text,
+                   Data.Convertible.Instances.String
diff --git a/utils/genCinstances.hs b/utils/genCinstances.hs
new file mode 100644
--- /dev/null
+++ b/utils/genCinstances.hs
@@ -0,0 +1,61 @@
+cint = ["CChar", "CSChar", "CUChar", "CShort", "CUShort", "CInt", "CUInt", "CLong",
+        "CULong", "CSize", "CWchar", "CLLong", "CULLong"]
+cfloat = ["CFloat", "CDouble", "CLDouble"]
+hsint = ["Int", "Int8", "Int16", "Int32", "Int64", "Word", "Word8", "Word16", "Word32",
+         "Word64"]
+hsfloat = ["Double", "Float", "Rational"]
+
+printFP (f, i) =
+    "instance ConvertAttempt " ++ f ++ " " ++ i ++ " where \n\
+    \    convertAttempt = boundedConversion (return . truncate)\n\
+    \instance ConvertSuccess " ++ i ++ " " ++ f ++ " where \n\
+    \    convertSuccess= fromIntegral\n"
+
+printIntegerF f =
+    "instance ConvertSuccess " ++ f ++ " Integer where\n\
+    \    convertSuccess = truncate\n\
+    \instance ConvertSuccess Integer " ++ f ++ " where\n\
+    \    convertSuccess = fromIntegral\n"
+
+printIntegerI i =
+    "instance ConvertSuccess " ++ i ++ " Integer where\n\
+    \    convertSuccess = fromIntegral\n\
+    \instance ConvertAttempt Integer " ++ i ++ " where\n\
+    \    convertAttempt = boundedConversion (return . fromIntegral)\n"
+
+printCharI i =
+    "instance ConvertAttempt " ++ i ++ " Char where\n\
+    \    convertAttempt = boundedConversion (return . toEnum . fromIntegral)\n\
+    \instance ConvertAttempt Char " ++ i ++ " where\n\
+    \    convertAttempt = boundedConversion (return . fromIntegral . fromEnum)\n"
+
+printFP1 (f1, f2) = 
+    "instance ConvertSuccess " ++ f1 ++ " " ++ f2 ++ " where\n\
+    \    convertSuccess = realToFrac\n"
+
+printFPFP (f1, f2) = printFP1 (f1, f2) ++ printFP1 (f2, f1)
+
+printInt (i1, i2) =
+    "instance ConvertAttempt " ++ i1 ++ " " ++ i2 ++ " where\n\
+    \    convertAttempt = boundedConversion (return . fromIntegral)\n"
+
+printIntInt (i1, i2) = printInt (i1, i2) ++ printInt (i2, i1)
+
+main = do putStrLn "-- Section 1"
+          mapM_ (putStrLn . printFP) (concatMap (\x -> map (\y -> (x, y)) hsint) cfloat)
+          putStrLn "-- Section 2"
+          mapM_ (putStrLn . printFPFP) (concatMap (\x -> map (\y -> (x, y)) hsfloat) cfloat)
+          putStrLn "-- Section 3"
+          mapM_ (putStrLn . printIntInt) (concatMap (\x -> map (\y -> (x, y)) hsint) cint)
+          putStrLn "-- Section 4"
+          mapM_ (putStrLn . printInt) . filter (\(a, b) -> a /= b) $ 
+                (concatMap (\x -> map (\y -> (x, y)) cint) cint)
+          putStrLn "-- Section 5"
+          mapM_ (putStrLn . printFP1) . filter (\(a, b) -> a /= b) $
+                (concatMap (\x -> map (\y -> (x, y)) cfloat) cfloat)
+          putStrLn "-- Section 6"
+          mapM_ (putStrLn . printIntegerF) cfloat
+          putStrLn "-- Section 7"
+          mapM_ (putStrLn . printIntegerI) cint
+          putStrLn "-- Section 8o"
+          mapM_ (putStrLn . printCharI) cint
