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

S. H. Aegis shaegis at gmail.com
Wed Feb 22 12:02:22 UTC 2017


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.

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

> On Wed, Feb 22, 2017 at 05:33:01PM +0900, S. H. Aegis wrote:
> > Hello.
> > I'm new to Haskell and this is the first time I use Data.Text module.
> > And using stack on OSX 10.12.3
> > I'm try several times, but fail. and I don't understand what error
> message
> > says.
> > How can I fix this?
> > Thank you a lot.
>
> Hello SH, Text.map has signature `(Char -> Char) -> Text -> Text`, so
> I expect you to need fmap too if the return value of makeRxDxList has
> type f [Text]
>
>     makeRxDxList rowRxDx = fmap _ rowRxDx
>     -- or base map
>
> _ is a hole and if the compiler will tell you which function needs to
> go there, in this case one with signature `Text -> [Text]`.
>
> Does that help? If not, provide makeRxDxList signature and a brief
> description so it's easier to diagnose the problem
> -F
> _______________________________________________
> 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/9b396f90/attachment.html>


More information about the Beginners mailing list