Question

How can I export the constructors of my data family instances? I've tried various ways without success (see commented out code):

module Test (
    --Foo () (..)
    --type Foo () (..)
    --UnitBar
) where

class Foo a where
    data Bar a :: *

instance Foo () where
    data Bar () = UnitBar

The only way I've been able to successfuly export the constructor is when doing a

module Test where

Notice the absense of parentheses. The drawback of this approach is that too much information leaves!

Was it helpful?

Solution

Use

module Test (
    Bar(..)
) where

to export all constructors from the associated data family Bar. Or

module Test (
    Bar(UnitBar)
) where

to only export the single constructor.

You can read the relevant section in GHC's documentation for more details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top