Okay, I'm dumb and can't figure this out.  I'm migrating hMPI from GHC
4.08 to GHC 5.04 (fun fun) and am having trouble writing an instance of
Storable.  The relevant information is:

> import Foreign.Storable
> type MPI_Rank_Type = Int
> newtype MPI_Rank = MPI_Rank MPI_Rank_Type deriving (Eq)
> 
> instance Storable MPI_Rank where
>     sizeOf    (MPI_Rank r) = sizeOf r
>     alignment (MPI_Rank r) = alignment r
>     peek addr = do r <- peek addr
>                    return (MPI_Rank r)
>     poke addr (MPI_Rank r) = poke addr r

which doesn't work; ghc complains:

/nfs/isd/hdaume/download/hmpi-0.9.3/src/Foo.hs:12:
    Couldn't match `MPI_Rank_Type' against `MPI_Rank'
        Expected type: MPI_Rank_Type
        Inferred type: MPI_Rank
    In the first argument of `MPI_Rank', namely `r'
    In the first argument of `return', namely `(MPI_Rank r)'
Failed, modules loaded: none.


I have no idea what's wrong.  if i make it "...do (r :: Int) <- ..." it
complains:

/nfs/isd/hdaume/download/hmpi-0.9.3/src/Foo.hs:12:
    Couldn't match `Int' against `MPI_Rank'
        Expected type: Int
        Inferred type: MPI_Rank
    When checking the pattern: r :: Int
    In a 'do' expression pattern binding: (r :: Int) <- peek addr
Failed, modules loaded: none.

it's like it doesn't realize that "peek" is part of the class and can be
overloaded.

someone please clear this up and tell me what obvious thing i'm missing...

Thanks!

 - Hal

--
Hal Daume III

 "Computer science is no more about computers    | [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to