Not totally I tried two versions:
findSAndE ts = do
ps <- powerset ts
return (map (\p->[[x | x<-ts, not (x elem
p)], p]) ps)
Error:
Prelude> :load powerset_haskell.hs
[1 of 1] Compiling Main ( powerset_haskell.hs, interpreted )
powerset_haskell.hs:7:55: error:
• Occurs check: cannot construct the infinite type: t ~ [t]
Expected type: [[t]]
Actual type: [t]
• In the second argument of ‘map’, namely ‘ps’
In the first argument of ‘return’, namely
‘(map (\ p -> [[x | x <- ts, not (x elem
p)], p]) ps)’
In a stmt of a ‘do’ block:
return (map (\ p -> [[x | x <- ts, not (x elem
p)], p]) ps)
• Relevant bindings include
ps :: [t] (bound at powerset_haskell.hs:6:2)
ts :: [t] (bound at powerset_haskell.hs:5:11)
findSAndE :: [t] -> [[[[t]]]] (bound at powerset_haskell.hs:5:1)
Failed, modules loaded: none.
Prelude>
Second variant:
findSAndE ts = do
ps <- powerset ts
return (map (\p->[[x | x<-ts, not (x elem
p)], [p]]) ps)
Error:
Prelude> :load powerset_haskell.hs
[1 of 1] Compiling Main ( powerset_haskell.hs, interpreted )
powerset_haskell.hs:7:55: error:
• Occurs check: cannot construct the infinite type: t ~ [t]
Expected type: [[t]]
Actual type: [t]
• In the second argument of ‘map’, namely ‘ps’
In the first argument of ‘return’, namely
‘(map (\ p -> [[x | x <- ts, not (x elem
p)], p]) ps)’
In a stmt of a ‘do’ block:
return (map (\ p -> [[x | x <- ts, not (x elem
p)], p]) ps)
• Relevant bindings include
ps :: [t] (bound at powerset_haskell.hs:6:2)
ts :: [t] (bound at powerset_haskell.hs:5:11)
findSAndE :: [t] -> [[[[t]]]] (bound at powerset_haskell.hs:5:1)
Failed, modules loaded: none.
Prelude>