Re: [Haskell-cafe] Inferred type is not general enough

Stefan Holdermans wrote: Huh. I'm really get stuck. Can someone write me working implementation of my crap?

Ivan, IT> Stefan Holdermans wrote: IT> IT> Huh. I'm really get stuck. Can someone write me working IT> implementation of my crap? Huh? Did *I* wrote that ... ? ;) \begin{code} {-# -OPTIONS -fglasgow-exts #-} class Location a where point :: a -> String class (Location b) => Packet a b where source :: a -> b destination :: a -> b size :: forall c . (Num c) => a -> c data TestLocation = TestSource | TestDestination deriving (Show) instance Location TestLocation where point = show data TestPacket = TestPacket instance Packet TestPacket TestLocation where source = const TestSource destination = const TestDestination size = const 99 main :: IO () main = print $ (source TestPacket :: TestLocation) \end{code} As I mentioned, depending on your needs, there are other options: enriching the Location class, parameterizing the packet types, ... HTH, Stefan
participants (2)
-
Ivan Tihonov
-
Stefan Holdermans