haskell - About ++ to concate things -
given following function signature:
concatthings :: (show a) => -> string -> string concatthings str2 = str2 ++ (show any)
if run concatthings "there" "hi"
, result be: "hi\"there\""
, want "hithere"
.
how can still "hithere" function signature?
you wrap string in new type , provide simple show instance it:
newtype partialstring = partialstring string instance show partialstring show partialstring str = str
and pass in wrapped string concatthings
function:
let pstr1 = partialstring str1 in concatthings pstr1 str2
Comments
Post a Comment