I'm in the process of laying out all of the data types for an API wrapper I'm writing. I want to create each type separately, and then combine them under a group so that I can refer to them ambiguously.
E.g.
data Bookmark = Bookmark {
url :: T.Text,
title :: T.Text
} deriving (Show)
data Note = Note {
author :: T.Text,
text :: T.Text
} deriving (Show)
data APIObject = Bookmark | Note
This way, I could define something like the following:
retrieveFromAPI :: APIObject a => String -> a
Where String is a URL.
However, when I try to compile this, I get two errors:
[1 of 1] Compiling Main ( API.hs, interpreted )
API.hs:28:16:
Multiple declarations of `Bookmark'
Declared at: API.hs:22:17
API.hs:28:16
API.hs:28:27:
Multiple declarations of `Note'
Declared at: API.hs:27:13
API.hs:28:27
Failed, modules loaded: none.
What should I be doing differently?
Thanks!