Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import specific PortNumber constructor

Tags:

haskell

Simple question.

This compiles:

module Example where

import Network

port :: PortID
port = PortNumber 3001

And this does not:

module Example where

import Network (PortID, PortNumber)

port :: PortID
port = PortNumber 3001

GHC says:

Example.hs:6:8: Not in scope: data constructor `PortNumber'

Why?

like image 598
Thiago Negri Avatar asked Jul 06 '12 23:07

Thiago Negri


1 Answers

It has to be

import Network (PortID(PortNumber))

as PortNumber seems to be a constructor of PortID. The other import simply imports all of Network and hence PortNumber is found.

like image 138
epsilonhalbe Avatar answered Oct 27 '22 21:10

epsilonhalbe