[Haskell-beginners] Re: confusion about parameterized types.
Kyle Murphy
orclev at gmail.com
Mon Aug 30 13:25:32 EDT 2010
Students and ID are constructors, not types. You need to change the
type signature from:
popStudents :: [String] -> Table Students ID
to:
popStudents :: [String] -> Table StudentsOrActivities Value
You might want to re-think the way you're doing this though, as I
don't think this is really want you want. Maybe you need to make
Students and Activities seperate types and create some sort of common
class that they can both be instances of? What exactly do they have in
common with each other? If you're just trying to create an abstraction
over a SQL table, you should probably look at the way HSQL or one of
the other SQL libraries handles the issue (usually with a class that
requires a fromSQL function or similar).
-R. Kyle Murphy
--
Curiosity was framed, Ignorance killed the cat.
On Mon, Aug 30, 2010 at 12:55, Michael Litchard <michael at schmong.org> wrote:
> Okay, ski (of Freenode fame) helped me with the first problem. Now I
> need to figure out how to use specific types.
>
> given
>
>
>> module Main where
>> import System.Environment
>> import PrepData
>
>> data ProcessData =
>> ProcessData { flatfile :: String
>> , processfunc :: [String] -> Table StudentsOrActivities Value
>> }
>
>> main = undefined
>
> and
>
>> module PrepData where
>> data Value = Cost Int | ID Int
>> type Tname = String
>> data StudentsOrActivities = Students String | Activities String
>> data Table soa v = PopTable
>> { tableName :: Tname
>> , tableColumns :: [(soa, v)]
>> } deriving (Show, Read)
>
>> popStudents :: [String] -> Table Students ID
>> popStudents flatFile = undefined
>
> is it clear what I am trying to do in popStudents?
>
> here's the error I get
> PrepData.lhs:10:35:
> Not in scope: type constructor or class `Students'
>
> PrepData.lhs:10:44: Not in scope: type constructor or class `ID'
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
More information about the Beginners
mailing list