title: How to connect to a redis server via Unix domain socket using hedis in Haskell?
body: <p>I'm looking for how to connect to a redis server via Unix domain socket using <a href="http://hackage.haskell.org/package/hedis" rel="noreferrer">hedis</a>, as advertised in the hackage page:</p>
  
  <blockquote>
    <p><strong>Connect via TCP or Unix Domain Socket:</strong><br>
    TCP sockets are the default way
    to connect to a Redis server. For connections to a server on the same
    machine, Unix domain sockets offer higher performance than the
    standard TCP connection.</p>
  </blockquote>
  
  <p>From the constructors of <a href="http://hackage.haskell.org/packages/archive/hedis/0.6.2/doc/html/Database-Redis.html#t:ConnectInfo" rel="noreferrer"><code>ConnectInfo</code></a>, as well as the <a href="http://hackage.haskell.org/packages/archive/hedis/0.6.2/doc/html/Database-Redis.html#v:defaultConnectInfo" rel="noreferrer"><code>defaultConnectInfo</code></a>, it seems that we should fill in the <code>connectPort</code>, since it has type <code>PortID</code> which has a constructor named <code>UnixSocket</code>. But it only shows <code>UnixSocket</code> is a <code>String</code>, without details of format, etc.</p>
  
  <p>So how to fill in the <code>connectPort</code> to connect via Unix domain socket? Thanks.</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong> I tried it out and found it's not that hard. Below is my hello world.</p>
  
  <pre><code>{-# LANGUAGE OverloadedStrings #-}
  import Control.Monad.Trans
  import Database.Redis
  
  myConnectInfo :: ConnectInfo
  myConnectInfo = defaultConnectInfo { connectPort = UnixSocket "/tmp/redis.sock" }
  
  main :: IO ()
  main = do
      conn &lt;- connect myConnectInfo
      runRedis conn $ do
          set "hello" "hello"
          set "world" "world"
          hello &lt;- get "hello"
          world &lt;- get "world"
          liftIO $ print (hello,world)
  </code></pre>