[Haskell-beginners] Type error when using splitOn function.

S. H. Aegis shaegis at gmail.com
Wed Feb 22 13:41:10 UTC 2017


It works !!! (^O^)
Thank you so much.

Have a nice day~!

2017-02-22 22:31 GMT+09:00 Francesco Ariis <fa-ml at ariis.it>:

> On Wed, Feb 22, 2017 at 09:02:22PM +0900, S. H. Aegis wrote:
> > Thank you so much.
> >
> > --makeRxDxList :: Functor f => f Text -> f [Text]
> > Above signature comes from ghci using command :t
> > My intention is
> > makeRxDxList :: Text -> [[Text]]
> > but, I got error, and try several times and below codes pass a complier.
> > makeRxDxList rowRxDx = fmap (\x -> splitOn (pack ",") x) rowRxDx  -- This
> > code pass a compile.
> > and then, I run ghci, type :t, and got below signature.
> > makeRxDxList :: Functor f => f Text -> f [Text]
> >
> > Your kind answer says, I cannot help using fmap. right? ^^;
> > Thanks again.
>
> Then this:
>
>     makeRxDxList :: Text -> [[Text]]
>     makeRxDxList rowRxDx = fmap f (lines rowRxDx)
>                 -- you imported Prelude hiding map, so we will use fmap
>         where
>               f :: Text -> [Text]
>               f x = splitOn (pack ",") x
>
> should do (at least it typechecks).
>
> GHC errors may not have the prettiest formatting ever, but they are
> very useful, the most important bits being line & column of the offending
> expression plus the "expected this but got that" part; get acquainted
> with them!
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>



-- 
Sok Ha, CHANG
Dr. Chang's Clinic. #203. 503-23. AmSa-Dong, GangDong-Gu, Seoul.
Tel: +82-2-442-7585
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170222/0d194b9d/attachment.html>


More information about the Beginners mailing list