thatguy 2017-02-06 06:51:52
could anyone tell me if this is a sensible implementation of "mapA :: Applicative f => (a -> f b) -> [a] -> f [b]" http://lpaste.net/352143 ?
monochrom 2017-02-06 06:57:14
thatguy: Who is cons?
thatguy 2017-02-06 06:58:15
monochrom: it does a -> [a] -> [a], it appends an element to a list
thatguy 2017-02-06 06:58:33
I just searched for a -> [a] -> [a] on hoogle and cons is what I found
pavonia 2017-02-06 06:59:57
@hoogle a -> [a] -> [a]
lambdabot 2017-02-06 07:00:00
Data.List intersperse :: a -> [a] -> [a]
lambdabot 2017-02-06 07:00:00
GHC.OldList intersperse :: a -> [a] -> [a]
lambdabot 2017-02-06 07:00:00
Data.Text.Internal.Functions intersperse :: a -> [a] -> [a]
pavonia 2017-02-06 07:00:37
thatguy: You are looking fo (:)
pavonia 2017-02-06 07:00:41
for
chef_excellence[ 2017-02-06 07:00:41
or simply use (:)
monochrom 2017-02-06 07:01:11
@type \fun list -> foldr (liftA2 (:).fun) (pure []) list
lambdabot 2017-02-06 07:01:13
(Foldable t, Applicative f) => (a -> f a1) -> t a -> f [a1]
monochrom 2017-02-06 07:01:54
OK it looks OK.
thatguy 2017-02-06 07:02:45
pavonia: ah thanks
chef_excellence[ 2017-02-06 07:02:55
dropping the list would be nicer though
thatguy 2017-02-06 07:03:21
chef_excellence[: ah yes it is not needed
chef_excellence[ 2017-02-06 07:03:27
mapA f = foldr (liftA2 (:).f) (pure [])
tfc 2017-02-06 07:03:42
i am looking for the nicest possible way to express something like in python, but in haskell: >>> "foo={}, bar={}".format("param1", "param2") <<<
tfc 2017-02-06 07:03:46
anyone a nice idea?
ongy 2017-02-06 07:04:15
formatting is pretty nice for such things
ongy 2017-02-06 07:04:20
package on hackage
chef_excellence[ 2017-02-06 07:04:46
@thatguy well in this case you also can replace the brackets with $
lambdabot 2017-02-06 07:04:47
Unknown command, try @list
tfc 2017-02-06 07:04:57
the thing is that i will use this on one very long, very simple string and i hoped to not need another library
chef_excellence[ 2017-02-06 07:05:13
foldr (liftA2 (:).f) $ pure []
thatguy 2017-02-06 07:08:34
chef_excellence[: is it considered to be nicer style to have $ instead of brackets?
Jinixt 2017-02-06 07:09:03
that's a heavily opinionated area
chef_excellence[ 2017-02-06 07:11:15
okay :D so do as you like @thatguy
thatguy 2017-02-06 07:14:45
chef_excellence[: thanks for helping!
chef_excellence[ 2017-02-06 07:15:39
@thatguy you're welcome :)
lambdabot 2017-02-06 07:15:39
Unknown command, try @list
ongy 2017-02-06 07:15:58
tfc: if the arguments are strings aswell, you can use concat
tfc 2017-02-06 07:20:06
ongy: that's similar to "unwords". the thing is that i'd like to store the string separated from arguments and then combine in a handy way without an external library for that little task
ongy 2017-02-06 07:24:35
tfc: do you know the string compile time? you could make it something like \arg1 arg2 -> concat ["This is my ", arg1, " string I want to format: ", arg2]
mizu_no_oto_work 2017-02-06 07:26:38
or even \arg1 arg2 -> "This is my " <> arg1 <> " string I want to format: " <> arg2
tfc 2017-02-06 07:29:21
ongy yes, this is what i am doing now, but i don't like it and i wondered if there is any haskell magic for that. :)
ongy 2017-02-06 07:30:51
not that I know of at least
tfc 2017-02-06 07:34:15
ongy just learned how to build fancy applicative parsers on the fly. i am still new to this, but now on every corner i see optimization potential (in sight of code expression length) in my code. :D