[Haskell-beginners] Monadic functions definitions for free monadic DSL

Sumit Raja sumitraja at gmail.com
Thu Oct 13 23:44:25 UTC 2016


> I would really like to help you, but without your imports, packages, etc,
> it is really hard to interpret your program.  Like where does decodeUtf8
> come from, or receive, or TCPSocket?  If they are functions you wrote, I
> don't need their code, the types would be sufficient.
>
Imports are:

import Protolude
import Control.Monad.Free
import System.Socket
import System.Socket.Family.Inet
import System.Socket.Type.Stream
import System.Socket.Protocol.TCP
import Control.Exception ( bracket, catch )
import Data.ByteString as BS (uncons)

    decodeUtf8 :: ByteString -> Text
    encodeUtf8 :: Text -> ByteString

I'm using the socket library for the actual networking
(https://hackage.haskell.org/package/socket-0.6.0.1)

    type TCPSocket = Socket Inet Stream TCP
    receive :: Socket f t p -> Int -> MessageFlags -> IO ByteString Source
    send :: Socket f t p -> ByteString -> MessageFlags -> IO Int
    accept :: (Family f, Storable (SocketAddress f)) => Socket f t p
-> IO (Socket f t p, SocketAddress f)

If it helps the full source is at
https://bitbucket.org/sumitraja/network-free/src/a4fcbc74c9e178e81d8b10b60d912b32c542b661/src/Lib.hs.

Looking forward to your assistance.

Thanks

Sumit


More information about the Beginners mailing list