Sergey Sosnin
Sergey Sosnin

Reputation: 1413

Compilation error at an instance declaration, Haskell

I faced with strange compilation error.

import Foreign
import Foreign.C.Types
import Foreign.C.String

newtype Test = Test {testList :: [CShort]}   deriving (Show)    

instance Storable Test where
    sizeOf _ =  16
    peek _ = error "peek is not implemented"
    alignment _ = alignment (undefined :: CShort)

got

TestICH.hsc:9:16: parse error on input `='

9:16 is peek _ = er{here}ror "peek is not implemented", in the middle of the word error? How is it possible?

Update Closed, trouble was with tabs

Upvotes: 1

Views: 87

Answers (1)

Dirk Holsopple
Dirk Holsopple

Reputation: 8831

Check the indentation of the declarations of sizeOf, peek and alignment. They should all be indented to the same level. Most likely, one or more of the declarations is using tabs for indentation and the others are using spaces, which will cause this error. When writing Haskell, it is best to configure your editor to always use spaces instead of tabs to avoid this problem.

Upvotes: 1

Related Questions