Haskell functions - String concatenation & composition

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Haskell functions - String concatenation & composition

mj3000
Hi

I have 2 questions...

1st:
I am writing a function which takes a list of Strings as an input and returns one string with elements separated by commas.
so far i have written this:

commaSeperate :: [String] -> String
commaSeperate [] = "[]"
commaSeperate (x:xs) = showChar "[" . shows x . showl xs

showl :: [String] -> String
showl [] = showChar "]"
showl (x:xs) = showChar "," . shows x . showl xs

But i am getting errors type 'Char' and '[Char]' and I can't find any help online.

2nd question:
how do i do function composition in haskell?
if g(x) = x+2; f(x) = x+1
how do write a function that gives me f(g(x))
functions takes a list of functions as an input.

thank you for your help