Q:

Read newline character from command line arguments with optparse-applicative

Below is an example of a program which takes one optional argument a which has as default value the newline character. The program only prints the value of the sole argument. Thus, calling the program with no argument or with -a '\n' should give the same value, but it doesn't:
$ ./myProg

$ ./myProg -a '\n'
\n

The problem is that when it's read from the command line arguments, the newline character is escaped. Is it possible to make the two calls behave the same?
import Options.Applicative

data Options = Options String

optsParser :: Parser Options
optsParser = Options
    <$> strOption
         ( short 'a'
        <> metavar "A"
        <> value "\n" )

opts :: IO Options
opts = execParser $ info (helper <*> optsParser) ( fullDesc )

main = do
    Options a <- opts
    putStrLn $ a

A:

The problem is not that the newline character is escaped; the problem is that you don't have a newline character in the first place.
As far as the shell is concerned, '\n' is literally a two-character string (backslash, n), and that's what gets passed to your program.
How to pass a literal newline character on the command line depends on your shell, but try the following:
$ ./myProg -a '
> '

(The > in there is a secondary shell prompt. What you type is ' Return '.)
Or in bash:
$ ./myProg -a $'\n'

