how to compile this type
From
meInvent bbird@21:1/5 to
All on Thu Aug 4 20:13:38 2016
after edit oplist and eeval1
got error when compile
Prelude> :l a.hs
[1 of 1] Compiling Main ( a.hs, interpreted )
a.hs:98:24:
Couldn't match expected type `(Integer, b0)'
with actual type `[(Integer, [Double])]'
In the first argument of `fst', namely `x'
In the expression: fst x
In the expression: (fst x, snd x)
a.hs:98:30:
Couldn't match expected type `(a0, [Double])'
with actual type `[(Integer, [Double])]'
In the first argument of `snd', namely `x'
In the expression: snd x
In the expression: (fst x, snd x)
a.hs:99:24:
Couldn't match expected type `(Integer, [Double])'
with actual type `[Double]'
In the return type of a call of `oplist'
In the expression: oplist op1 (eeval1 l) (eeval1 r)
In an equation for `eeval1':
eeval1 (Mode l MA r) = oplist op1 (eeval1 l) (eeval1 r)
a.hs:100:24:
Couldn't match expected type `(Integer, [Double])'
with actual type `[Double]'
In the return type of a call of `oplist'
In the expression: oplist op2 (eeval1 l) (eeval1 r)
In an equation for `eeval1':
eeval1 (Mode l MB r) = oplist op2 (eeval1 l) (eeval1 r)
a.hs:101:24:
Couldn't match expected type `(Integer, [Double])'
with actual type `[Double]'
In the return type of a call of `oplist'
In the expression: oplist op3 (eeval1 l) (eeval1 r)
In an equation for `eeval1':
eeval1 (Mode l MC r) = oplist op3 (eeval1 l) (eeval1 r)
Failed, modules loaded: none.
allparams = replicateM 2 [0.0, 1.0]
a1 = [0.0, 1.0, 1.0, 1.0]
a2 = [0.0, 0.0, 0.0, 1.0]
a3 = [1.0, 1.0, 0.0, 1.0]
op1 :: Map (Double, Double) Double
op1 = Map.fromList [((allparams!!i!!0, allparams!!i!!1), a1!!i) | i <- [0..3] ]
op2 :: Map (Double, Double) Double
op2 = Map.fromList [((allparams!!i!!0, allparams!!i!!1), a2!!i) | i <- [0..3] ]
op3 :: Map (Double, Double) Double
op3 = Map.fromList [((allparams!!i!!0, allparams!!i!!1), a3!!i) | i <- [0..3] ]
-- have bug before, correct to param1, then param2
oplist :: Map (Double, Double) Double -> (Integer, [Double]) -> (Integer, [Double]) -> [Double]
oplist oper (0,param1) (0,param2) = fromJust (sequence [Map.lookup (param1!!i,param2!!i) $ oper | i <- [0..(length(param1)-1)]])
oplist oper (0,param1) (1,param2) = fromJust (sequence [Map.lookup (param1!!i,param2!!j) $ oper | i <- [0..(length(param1)-1)], j <- [0..(length(param1)-1)]])
oplist oper (1,param1) (0,param2) = fromJust (sequence [Map.lookup (param1!!j,param2!!i) $ oper | i <- [0..(length(param1)-1)], j <- [0..(length(param1)-1)]])
oplist oper (1,param1) (1,param2) = (fromJust (sequence [Map.lookup (param1!!i,param2!!j) $ oper | i <- [0..(length(param1)-1)], j <- [0..(length(param1)-1)]])) ++ (fromJust (sequence [Map.lookup (param1!!j,param2!!i) $ oper | i <- [0..(length(param1)-1)]
, j <- [0..(length(param1)-1)]]))
eeval1 :: Mree [(Integer, [Double])] -> (Integer, [Double])
eeval1 (Meaf x) = (fst x,snd x)
eeval1 (Mode l MA r) = oplist op1 (eeval1 l) (eeval1 r)
eeval1 (Mode l MB r) = oplist op2 (eeval1 l) (eeval1 r)
eeval1 (Mode l MC r) = oplist op3 (eeval1 l) (eeval1 r)
let input1 = input2 3
let oplist = filter isSorted input1
let getoperationlist = [map snd (oplist!!i) | i <- [0..((length oplist)-1)]]
let fullytruerownum = 4
let fullytrue = 4.0
let logic3row = replicateM 2 [0.0, 1.0]
let logic3col = [[logic3row!!i!!1 | i <- [0..(4-1)]],[logic3row!!i!!0 | i <- [0..(4-1)]]]
let aa2 = [logic3row!!i!!1 | i <- [0..(4-1)]]
let aa1 = [logic3row!!i!!0 | i <- [0..(4-1)]]
let append xs ys = foldr (\x y -> x:y) ys xs
let allparams1 = [[(1,aa1), (0,aa1), (1,aa2), (1,aa2)]]
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)