Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / BasicTypes.hs @ 3af1359f

History | View | Annotate | Download (12.7 kB)

# Date Author Comment
fb54b24a 01/30/2014 04:10 pm Petr Pudlak

Improve liftIO of ResultT to catch IOErrors

Any IOErrors are now captured in ResultT's liftIO using try and converted into
'Bad'. This prevents IO exceptions from leaking into ResultT code and allows
them to be handled in a pure way inside ResultT's sum type....

f59cefcb 01/30/2014 04:10 pm Petr Pudlak

Rename 'resultT' to 'toError'

.. to better correspond to its generalized type.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

87f15934 01/30/2014 04:10 pm Petr Pudlak

Generalize type signatures of functions that produce Result

This allows them to be used in any 'MonadError', in particular in monad stacks
composed using ResultT, without explicit lifting.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

565821d1 01/30/2014 04:10 pm Petr Pudlak

Add functions for manipulating errors in Result(T)

There is often need to manipulate these errors, for example to convert a String
from Result into an exception. These functions make this easier.

Function 'toErrorStr' lifts 'Result' to any 'MonadError'. This is useful...

a87a017b 01/30/2014 04:10 pm Petr Pudlak

Remove FromString in favor of Error from standard libraries

They have the very same functionality, and using our own FromString only
causes unnecessary code duplication.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

78209a84 01/16/2014 05:11 pm Petr Pudlak

Add Alternative instances for GenericResult and ResultT

This allows to use Alternative specific combinators, namely `optional`.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

95e683c6 12/11/2013 01:31 pm Petr Pudlak

Add MonadPlus and MonadError instances for GenericResult

.. and ResultT.

While at it, generalize also the MonadPlus instance of GenericResult and
add some Functor/Applicative instances.

Signed-off-by: Petr Pudlak <>
Reviewed-by: Klaus Aehlig <>

ea128e20 11/26/2013 03:31 pm Klaus Aehlig

Add a function justBad to filter the Bad value of a list

In the same way as justOk allows to filter the Ok values,
add justBad to filter the Bad values. While there, simplify
the definition of justOk.

Signed-off-by: Klaus Aehlig <>
Reviewed-by: Petr Pudlak <>

9491766c 10/16/2013 08:57 pm Hrvoje Ribicic

Add further fields to instance queries

This commit adds some more fields that are simple to retrieve, as
they are properties of instances recorded in the configuration.

Signed-off-by: Hrvoje Ribicic <>
Reviewed-by: Jose A. Lopes <>

4651c69f 09/10/2013 11:58 am Jose A. Lopes

Wrap 'Set' in 'ListSet' for the opcodes

In what Haskell to Python opcodes are concerned, a Haskell 'Set' is
translated into a Python 'list'. In other words, currently, opcodes
that handle sets of parameters are actually handling lists because
this is how sets are currently encoded. This patch introduces a new...

b1c772fd 06/17/2013 05:36 pm Klaus Aehlig

Convenience function for iterating while the result is Ok

For a function f :: a -> GenericResult a, iterate it (in the sense of the
monad), until the result is Bad; return the list of values occurred.

Signed-off-by: Klaus Aehlig <>
Reviewed-by: Michele Tartara <>

b74ebe44 06/17/2013 05:36 pm Klaus Aehlig

Provide witness for the sum-type structure of GenericResult

GenericResult, while rightfully a type of its own, is isomorphic
to Either. So, also provide the case analysis function (i.e., the
universal arrow out of the sum).

Signed-off-by: Klaus Aehlig <>...

3add7574 12/24/2012 11:38 pm Iustin Pop

Rename htools/ to src/

Per offline discussions, this is the first patch of the
renames. Tested with "make distcheck", seems to work fine.

The only change outside of the renaming is a bit of simplification in
the .gitignore rules; otherwise, simply s/htools/src/....