Data type field name from module I defined is "not in scope"

I have a Haskell file called Types.hs that contains this definition, among others: module Types ( KnapsackItem ) where data KnapsackItem = KnapsackItem { weight :: Int, cost :: Int } deriving (Show, Eq) Then there’s my Main.hs (also shortened here for simplicity): import Types evalTotal :: [KnapsackItem] -> [KnapsackItem] -> (Int, Int, String) evalTotal… Read More Data type field name from module I defined is "not in scope"

In Haskell, is there a way to define a type constructor that includes a bunch of type constraints?

there. Relative Haskell newbie here. I have a big bunch of data types and functions on two type variables that require that the types are Eq, Ord, and Show. I found myself writing type Foo n t = (Eq n, Eq t, Ord n, Ord t, Show n, Show t) => Bar n t –… Read More In Haskell, is there a way to define a type constructor that includes a bunch of type constraints?

How to correctly return nested types in haskell?

I want to return empty lists if one of the parameters is Nothing, but I can’t data UtilsDiff = UtilsDiff {syntaxBlockOptions :: [String], optionsBlockOptions :: [String]} deriving Show data UtilsOrDiff = UtilsOrDiff Utils | Diff UtilsDiff deriving Show useBlockExpr :: Parser UtilsOrDiff useBlockExpr = do u1 <- syntaxExpr opts <- optionsBlockExpr _ <- absorbToStopWord "Description:"… Read More How to correctly return nested types in haskell?