[Haskell-cafe] Lift data from IO to Validation

Daniel Díaz Casanueva dhelta.diaz at gmail.com
Sat Jan 4 21:43:21 UTC 2020


The documentation of monad-validate is indeed great. I didn't know about
this package before. I will add it to my list of nice Haskell libraries.

Cheers,
Daniel

Am Sa., 4. Jan. 2020 um 20:31 Uhr schrieb Alexis King <lexi.lambda at gmail.com
>:

> You might want to check out
> https://hackage.haskell.org/package/monad-validate, which provides a
> monad transformer version of a Validation-like type. You can stack it on
> top of IO and do whatever you want there. Errors are collected from
> multiple branches as long as you use applicative operations where possible,
> so you probably want to use ApplicativeDo. The monad laws are satisfied via
> a relaxed notion of equality; see the documentation for more info.
>
> Disclaimer: I am the author of monad-validate.
>
> Alexis
>
> On Jan 4, 2020, at 08:58, Debasish Ghosh <ghosh.debasish at gmail.com> wrote:
>
> Hi -
>
> I am not an experienced Haskell programmer and would like to have some
> help with the following problem ..
>
> I am trying to validate a bunch of inputs and found the package
> Data.Validation. I am also using Data.Time for date and time. I have a
> function like this ..
>
> validateOpenDate :: ZonedTime -> Validation [String] ZonedTime
>
> It's supposed to validate a date for which I need to fetch the current
> date and time. I can do that with getZonedTime :: IO ZonedTime. I want to
> check if the current time is less than the date time I pass to the function
> and return an appropriate Validation.
>
> The question is how do I lift the result from IO into the Validation ? Or
> is there any alternative strategy that I should consider for this
> validation ? I have a number of other validations which follow the same
> strategy but don't have the IO. My final goal is to be able to compose all
> these validations applicatively to prepare a final ADT in a smart
> constructor.
>
> Any help will be appreciated ..
>
> regards.
>
> --
> Debasish Ghosh
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20200104/74ec4bff/attachment.html>


More information about the Haskell-Cafe mailing list