Wie kann ich einige Werte in einem eigenen erstellten Datentyp speichern? Nach dem Speichern sollten verschiedene Module Zugriff auf diese Werte haben.Weitergabe von Informationen durch verschiedene Module Haskell
Es wäre schön, wenn Sie mir einig Code-Beispiel zeigen können, weil ich in Haskell ganz neu bin
Der Code habe ich bisher: Das zweite Modul (das nicht das Haupt Zeug hat)
data SimuInfo = Information {
massSaved:: Double
} deriving Show
initialization:: Double-> SimuInfo
initialization m = Information{
massSaved = m
}
--a example function, which uses the data
example:: Double -> SimuInfo -> Double
example a information = 2* a * b
where
b = massSaved information
Dies ist der Code in dem ersten Modul, das den Datentyp verwendet:
import Simufunc -- the import of the 2nd module
example2 :: Double -> Double
example2 a = example a Information
Dies wird die folgende Fehlermeldung erhalte ich:
Couldn't match expected type ‘SimuInfo’
with actual type ‘Double -> SimuInfo’
Probable cause: ‘Information’ is applied to too few arguments
In the second argument of ‘example’, namely ‘Information’
In the expression: example a Information
Vielen Dank im Voraus
Bitte beschränken Stapel O Verflow-Fragen, um sich auf eine einzelne Frage zu konzentrieren. Ihre Frage zur Tastatureingabe sollte wahrscheinlich auf eine eigene Frage gestellt werden, oder [lesen Sie hier Ein-/Ausgabe] (http://learnyouahaskell.com/input-and-output) –