Haskellians,<br><br>i'm sure i don't understand type classes, yet. Still, i was surprised at ghci's response to the code below. Clues gratefully accepted.<br><br>Best wishes,<br><br>--greg<br><br>-- transcript<br>
-- Prelude> :l grn<br>-- [1 of 1] Compiling GeneticRegulatoryNetwork ( grn.hs, interpreted )<br><br>-- grn.hs:33:35:<br>-- Couldn't match expected type `b1' (a rigid variable)<br>-- against inferred type `b' (a rigid variable)
<br>-- `b1' is bound by the type signature for `sequence' at grn.hs:25:36<br>-- `b' is bound by the instance declaration at grn.hs:31:0<br>-- Expected type: [b1]<br>-- Inferred type: [b]<br>
-- In the expression: molecules<br>-- In the definition of `sequence':<br>-- sequence (Site l1 molecules) = molecules<br>-- Failed, modules loaded: none.<br>-- Prelude> <br><br>{-# OPTIONS -fglasgow-exts -fallow-undecidable-instances #-}
<br>-- -*- mode: Haskell;-*- <br>-- Filename: grn.hs <br>-- Authors: lgm <br>-- Creation: Thu Dec 6 15:38:26 2007 <br>-- Copyright: Not supplied <br>-- Description:
<br>-- ----------------------------------------------------------------<br><br>module GeneticRegulatoryNetwork<br> where<br><br>data Segment p = <br> Nil<br> | Section [p] (Segment p)<br> deriving (Eq, Show)<br>
<br>class BindingMolecule b l | b -> l where<br> name :: b -> l<br> complement :: b -> b<br> complements :: b -> Bool<br><br>class Locale s l1 l2 | s -> l1 l2 where<br> label :: s -> l1
<br> sequence :: (BindingMolecule b l2) => s -> [b]<br> provides :: (BindingMolecule b l2) => s -> [b] -> Bool<br> matches :: (BindingMolecule b l2) => s -> [b] -> Bool<br><br>data (BindingMolecule b l2) => Site b l1 l2 = Site l1 [b] deriving (Eq, Show)
<br><br>instance (BindingMolecule b l2) => Locale (Site b l1 l2) l1 l2 where<br> label (Site l1 _) = l1<br> sequence (Site l1 molecules) = molecules<br> provides (Site l1 molecules) molecules' = False -- tbd
<br> matches (Site l1 molecules) molecules' = False -- tbd<br><br><br clear="all"><br>-- <br>L.G. Meredith<br>Managing Partner<br>Biosimilarity LLC<br>505 N 72nd St<br>Seattle, WA 98103<br><br>+1 206.650.3740<br><br>
<a href="http://biosimilarity.blogspot.com">http://biosimilarity.blogspot.com</a>