• how to remove Maybe or Just with fromJust

    From meInvent bbird@21:1/5 to All on Mon Jul 18 20:28:00 2016
    it return Maybe [Double]

    and fromJust can remove Maybe

    but error in this case

    *Main Data.Map Map Data.Maybe> :t fromJust
    fromJust :: Maybe a -> a

    *Main Data.Map Map Data.Maybe> :type sequence [Map.lookup (input2!!i,input1!!i) $ op1 | i <- [0..3]]
    sequence [Map.lookup (input2!!i,input1!!i) $ op1 | i <- [0..3]]
    :: Maybe [Double]

    *Main Data.Map Map Data.Maybe> fromJust sequence [Map.lookup (input2!!i,input1!!i) $ op1 | i <- [0..3]]

    <interactive>:32:10:
    Couldn't match expected type `Maybe ([Maybe Double] -> t0)'
    with actual type `[m0 a0] -> m0 [a0]'
    In the first argument of `fromJust', namely `sequence'
    In the expression:
    fromJust
    sequence
    [Map.lookup (input2 !! i, input1 !! i) $ op1 | i <- [0 .. 3]]
    In an equation for `it':
    it
    = fromJust
    sequence
    [Map.lookup (input2 !! i, input1 !! i) $ op1 | i <- [0 .. 3]] *Main Data.Map Map Data.Maybe>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to meInvent bbird on Mon Jul 18 20:32:33 2016
    after a () succeed to run

    On Tuesday, July 19, 2016 at 11:28:03 AM UTC+8, meInvent bbird wrote:
    it return Maybe [Double]

    and fromJust can remove Maybe

    but error in this case

    *Main Data.Map Map Data.Maybe> :t fromJust
    fromJust :: Maybe a -> a

    *Main Data.Map Map Data.Maybe> :type sequence [Map.lookup (input2!!i,input1!!i) $ op1 | i <- [0..3]]
    sequence [Map.lookup (input2!!i,input1!!i) $ op1 | i <- [0..3]]
    :: Maybe [Double]

    *Main Data.Map Map Data.Maybe> fromJust sequence [Map.lookup (input2!!i,input1!!i) $ op1 | i <- [0..3]]

    <interactive>:32:10:
    Couldn't match expected type `Maybe ([Maybe Double] -> t0)'
    with actual type `[m0 a0] -> m0 [a0]'
    In the first argument of `fromJust', namely `sequence'
    In the expression:
    fromJust
    sequence
    [Map.lookup (input2 !! i, input1 !! i) $ op1 | i <- [0 .. 3]]
    In an equation for `it':
    it
    = fromJust
    sequence
    [Map.lookup (input2 !! i, input1 !! i) $ op1 | i <- [0 .. 3]] *Main Data.Map Map Data.Maybe>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)