purescript question 

I wonder if there's an alternative to `Data.Show` in purescript that does /not/ escape strings but /does/ turn other types into strings

like

"meow" -> "meow"
1 -> "1"

instead of

"meow" -> \"meow\"
1 -> "1"

ive been trying to figure it out for so long but no progress so far

re: purescript question 

@AgathaSorceress ...I was sure there was such a thing but apparently not

you could probably write such a thing yourself using instance chains

class MyShow a where
myShow :: a -> String

instance stringShow :: MyShow String where
myShow = identity
else instance otherShow :: Show a => MyShow a
myShow = show

re: purescript question 

@lambdagrrl so apparently that works when i directly call myShow

but if i use myShow in a function, it gives me the escaped string anyway

not sure why that's happening... maybe it doesn't check if the type is String

Follow

re: purescript question 

@AgathaSorceress oh, yeah, if it doesn't know statically that the type is a string then it will call the more generic version

Β· Β· 1 Β· 0 Β· 1

re: purescript question 

@lambdagrrl riiiight,,, im not sure what to do about this

re: purescript question 

@AgathaSorceress what's the type of the function you're calling it from?

re: purescript question 

@lambdagrrl
forall a. Show a => Int -> String -> Array a -> Array String

re: purescript question 

@AgathaSorceress ah yeah, try changing the class constraint from Show to MyShow?

re: purescript question 

@lambdagrrl right
i,, forgot about that

it works now, thank you!

Sign in to participate in the conversation
Computer Fairies

Computer Fairies is a Mastodon instance that aims to be as queer, friendly and furry as possible. We welcome all kinds of computer fairies!