Some terminology: What you install with cabal is a "package". What you import in code is a "module".
I am trying to build a TCP server and am using the network module
There is no "network" module in any modern Haskell package that I'm aware of. This would be your first problem.
import Network (listenOn, withSocketsDo, accept, PortID(..), Socket)
If you're new and learned of this module and functions from a resource then find something new - two years ago the network package changed and no longer exports "Network" as a module.
cabal doesnt seem to find the network module
Again cabal installs packages so you're probably meaning the network package. Cabal does know about this package:
bash-3.2$ cabal update 2>/dev/null 1>&2 && cabal info network
* network (library)
Synopsis: Low-level networking interface
...
and ghc-pkg list shows nothing
ghc-pkg is really low-level and frankly insufficient these days. It doesn't handle package environments used in new GHCs. You can, for example, setup a .ghc.environment and use libraries listed there without ghc-pkg ever telling you those packages are installed.
For example below I install network and have cabal write a ghc environment file, then ask ghc-pkg to list the network package (unlisted), then use the network package in GHCi (GHCi knows to read the environment file).
tommd@ovdak /tmp% cabal install --package-env . --lib network
Resolving dependencies...
Up to date
cabal install --package-env . --lib network 2.60s user 0.49s system 95% cpu 3.254 total
tommd@ovdak /tmp% ghc-pkg list network
/Users/tommd/.ghcup/ghc/8.10.1/lib/ghc-8.10.1/package.conf.d
(no packages)
tommd@ovdak /tmp% ghci
GHCi, version 8.10.1: https://www.haskell.org/ghc/ :? for help
Loaded package environment from /private/tmp/.ghc.environment.x86_64-darwin-8.10.1
package flags have changed, resetting and loading new packages...
Loaded GHCi configuration from /Users/tommd/.ghci
Prelude> import Network.Socket
Prelude Network.Socket>