[Haskell-beginners] Doing IO in terms of Arrow
Haisheng Wu
freizl at gmail.com
Mon Jun 27 19:03:36 CEST 2011
You find point I need the correct type signatures.
And seems like it is (missed IO in your description)
Kleisli IO FilePath [FilePath]
Thanks a lot!
-Haisheng
On Tue, Jun 28, 2011 at 12:38 AM, Ertugrul Soeylemez <es at ertes.de> wrote:
> Haisheng Wu <freizl at gmail.com> wrote:
>
> > I'm wondering if it is possible doing IO in terms of Arrow.
> > I got a function search all files under directory recursively and
> > I'd like to refartoring using Arrow terms.
>
> Yes, it's possible using Kleisli, but it's not very convenient, because
> you need the Kleisli wrapper around everything. Also usually there is
> really little reason to do that, because monads are more expressive.
> For example they allow you to encode computations with only outputs
> directly, without wrapping them in a computation, which takes a stub
> argument.
>
>
> > I tried to define a function like below but failed.
> > isDirExist = Kleisli doesDirectoryExist
> >
> > Do I need to define a instance for IO to be Arrow? Or is there any
> > existing solutions?
>
> No, the needed instances are already there, but you need to change your
> type signatures:
>
> myGetFilesInDir :: Kleisli FilePath [FilePath]
>
>
> Greets,
> Ertugrul
>
>
> --
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://ertes.de/
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110628/5145cdeb/attachment.htm>
More information about the Beginners
mailing list