I have this core Haskell file : Relation.hs
It defines some data types
{-# LANGUAGE GADTs,MultiParamTypeClasses,ScopedTypeVariables,TypeSynonymInstances,FlexibleInstances #-}
module Relation where
data SchemaField schemaField where
SchemaField :: (Eq fieldType) => {
name :: String,
fieldType :: fieldType,
nullable :: Bool
} -> SchemaField (String,fieldType,Bool)
data ValueField valueField where
ValueField :: (Eq valueField,Ord valueField) => valueField -> ValueField valueField
type Schema schemaField = [SchemaField schemaField]
type MaybeValueField valueField = Maybe (ValueField valueField)
type Row valueField = [MaybeValueField valueField]
type Rows valueField = [Row valueField]
data Relation schemaField valueField = Relation {
schema :: Schema schemaField,
rows :: Rows valueField
}
Then, I have the test file : RelationTest.hs
It needs to use below Relation constructor :
{-# LANGUAGE MultiParamTypeClasses #-}
module RelationTest where
import Relation (FromValueToSchema,bindType,schema,rows,Relation)
data FieldType =
StringType | IntType -- Char | Bool | Integer | Float | Double
deriving (Show,Eq)
consistentSchema = [SchemaField "name" StringType False,SchemaField "ID" IntType True]
createdRelation = Relation {schema = consistentSchema, rows = []}
But when I compile RelationTest.hs, I have this error I do not understand :
Not in scope: data constructor ‘Relation’
From understanding, Relation constructor is well defined in Relation.hs.
I can remove the details in "import Relation ..." in RelationTest.hs and it works fine.
But I would like to keep detailed import.
When this import is removed, in GHCi interpreter, I can see Relation constructor type :
*Main> import Relation
*Main Relation> :t Relation
Relation
:: Schema schemaField
-> Rows valueField -> Relation schemaField valueField
So, what did I miss in my detailed import ?
I check those 2 StackOverflow threads, but I did not find any solution :