Skip to content

Panic!

Hi, I'm using haskell for an assignment and I createt this (which told me to do a bug report): [1 of 1] Compiling Main ( plant.hs, plant.o ) ghc: panic! (the 'impossible' happened)

(GHC version 8.0.2 for x86_64-unknown-linux):

initTc: unsolved constraints

WC {wc_insol =

\[W\] true_a1Gg t_a1Gf\[tau:1\] (CHoleCan: true)
\[W\] false_a1Gj t_a1Gi\[tau:1\] (CHoleCan: false)
\[W\] true_a1Qq t_a1Qp\[tau:1\] (CHoleCan: true)}
data Farbe = Rot | Rosa | Weis | Blau | Lila | Grun | Gelb
   deriving (Show, Eq)

data Pflanze =
      Blatt
   |  Blute Farbe
   |  Stiel Pflanze Pflanze
   deriving (Show, Eq)

fold_pflanze :: (a -> a -> a) -> (Farbe -> a) -> a -> Pflanze -> a
fold_pflanze f g x (Blatt) = x
fold_pflanze f g x (Blute fa) = (f x (g fa))
fold_pflanze f g x (Stiel p1 p2) = fold_pflanze f g (fold_pflanze f g x p1) p2


--4.
farbezuliste :: Farbe -> [Farbe]
farbezuliste f = [f]

appendlisten :: [Farbe] -> [Farbe] -> [Farbe]
appendlisten f1 f2 = f1 ++ f2

blutenfarben :: Pflanze -> [Farbe]
blutenfarben p = fold_pflanze appendlisten farbezuliste [] p 

--5.
fold_pflanze2 :: (Farbe -> Int) -> Int -> Pflanze -> Int
fold_pflanze2 f x (Blatt) = x + 1;
fold_pflanze2 f x (Blute fa) =  x + (f fa)
fold_pflanze2 f x (Stiel p1 p2) = (-2) + (fold_pflanze2 f (fold_pflanze2 f x p1) p2)

evaluatefarbe :: Farbe -> Int
evaluatefarbe Rot = 2
evaluatefarbe Rosa = 3
evaluatefarbe Weis = 5
evaluatefarbe Blau = 1
evaluatefarbe Lila = 10
evaluatefarbe Grun = -1
evaluatefarbe Gelb = 0

schonheit :: Pflanze -> Int
schonheit p = fold_pflanze2 evaluatefarbe 0 p

--6.
istrosa :: Farbe -> Bool
istrosa Rosa = true
istrosa otherwise = false

und :: Bool -> Bool -> Bool
und x y = x && y

rosabluhend :: Pflanze -> Bool
rosabluhend p = fold_pflanze und istrosa true p

I tryed to add the code as attechment bug it crashed (It also told me to do a bug report but I have an assignment to do).

EDIT: It seems to be the part that belongs to 6

Edited by Deus
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information