Reputation: 171
To run a simulation I created my own data Type, so I can store the parameters.
example:: Double -> SimuInfo -> Double
example a information = 2* a * b
where
information{b = bFieldSaved }
...--Some other functions
data SimuInfo = Information {
massSaved:: Double
, chiSaved:: Double
, bFieldSaved :: Double
} deriving Show
initialization:: Double -> Double -> Double -> SimuInfo
initialization m chiInit b = Information{
massSaved = m,
chiSaved = chiInit,
bFieldSaved = b
}
The problem is that, while trying to compile, I receive this error message. (the compiler says, that it is in the line where I have ...--Some other functions
)
parse error (possibly incorrect indentation or mismatched brackets)
Thanks in advance
Upvotes: 0
Views: 67
Reputation: 531605
You can pattern-match with record syntax, but you need to use the data constructor.
example a (Information {bFieldSave = b}) = 2 * a * b
Also, your initialization
function isn't really necessary, as
it is really equivalent to the data constructor you already have
underneath all the record syntax.
initialization:: Double -> Double -> Double -> SimuInfo
-- initialization m chiInit b = Information m chiInit b
initialization = Information
Upvotes: 0
Reputation: 1739
Your where
clause doesn't look right - it should have a syntax like this:
where
name = value
Perhaps you meant to write something like the following?
where
b = bFieldSaved information
Upvotes: 4