[Haskell-cafe] Lift data from IO to Validation

Tom Ellis tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Sat Jan 4 15:01:51 UTC 2020


On Sat, Jan 04, 2020 at 08:28:50PM +0530, Debasish Ghosh wrote:
> 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.

How about

    validateNow = do
        zonedTime <- getZonedTime
        return (validateOpenDate zonedTime)


More information about the Haskell-Cafe mailing list