Squallcx
Squallcx

Reputation: 125

Print contains data type how to disable

using gogol package, follow example got

> exampleGetValue
-- ValueRange' {_vrValues = Just [String "2018/1/1",String "2018/1/2"], _vrRange = Just "'\24037\20316\34920\&1'!A1:1", _vrMajorDimension = Just VRMDRows} 
> exampleGetValue >>= return . view vrValues
-- [String "2018/1/1",String "2018/1/2"]
> mapM_ (print) (exampleGetValue >>= return . view vrValues)
String "2018/1/1"
String "2018/1/2"

Why there will be a string of words

How to do I can only show

2018/1/1
2018/1/2

Upvotes: 0

Views: 49

Answers (1)

typetetris
typetetris

Reputation: 4867

Take a look at

[String "2018/1/1",String "2018/1/2"]

the result of

> exampleGetValue >>= return . view vrValues

Here the strings you are interested in, like "2018/1/1" are contained in another datatype String, which has, I assume, an automatically derived show instance, which will print the name of the Data constructor String.

You need to unpack the strings somehow to get rid of the printing of the word String.

As this is stackoverflow, and we are considered to provide answers, I will give you one possibility now, but before you read it, try to do it yourself:

unpackString (String w) = w
mapM_ (print . unpackString) (exampleGetValue >>= return . view vrValues)

You have to determine the type signature for unpackString yourself, as you didn't provided any types.

Upvotes: 2

Related Questions