• possibly incorrect indentation or mismatched brackets

    From Ben Bacarisse@21:1/5 to meInvent bbird on Mon Jul 18 15:20:11 2016
    meInvent bbird <jobmattcon@gmail.com> writes:

    in ghci, run code below , it can run without error

    It's complicated. There are two forms of let. One is an expression and
    has in 'in' part:

    let x = 42 in x*x

    The other appears in do blocks and list comprehensions and just
    introduced a new binding. This is the form you are using when you type
    let at ghci.

    but after put in file test.hs

    then :l test.hs

    got error

    Prelude> :l trees.hs
    [1 of 1] Compiling Main ( trees.hs, interpreted )
    parse error (possibly incorrect indentation or mismatched brackets) Failed, modules loaded: none.


    import Data.List
    import Control.Monad
    import Math.Combinat
    import System.IO
    import Data.Map (Map)
    import qualified Data.Map as Map

    let allparams = replicateM 2 [0.0, 1.0]
    let a1 = [0.0, 1.0, 1.0, 1.0]
    let a2 = [0.0, 0.0, 0.0, 1.0]
    let a3 = [1.0, 1.0, 0.0, 1.0]

    These should be top-level definitions (i.e. just remove the let
    keyword).

    <snip>
    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to Ben Bacarisse on Mon Jul 18 20:29:02 2016
    thanks , after remove let , it succeed to run

    On Monday, July 18, 2016 at 10:20:12 PM UTC+8, Ben Bacarisse wrote:
    meInvent bbird <jobmattcon@gmail.com> writes:

    in ghci, run code below , it can run without error

    It's complicated. There are two forms of let. One is an expression and
    has in 'in' part:

    let x = 42 in x*x

    The other appears in do blocks and list comprehensions and just
    introduced a new binding. This is the form you are using when you type
    let at ghci.

    but after put in file test.hs

    then :l test.hs

    got error

    Prelude> :l trees.hs
    [1 of 1] Compiling Main ( trees.hs, interpreted )
    parse error (possibly incorrect indentation or mismatched brackets) Failed, modules loaded: none.


    import Data.List
    import Control.Monad
    import Math.Combinat
    import System.IO
    import Data.Map (Map)
    import qualified Data.Map as Map

    let allparams = replicateM 2 [0.0, 1.0]
    let a1 = [0.0, 1.0, 1.0, 1.0]
    let a2 = [0.0, 0.0, 0.0, 1.0]
    let a3 = [1.0, 1.0, 0.0, 1.0]

    These should be top-level definitions (i.e. just remove the let
    keyword).

    <snip>
    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From meInvent bbird@21:1/5 to All on Mon Jul 18 02:30:33 2016
    in ghci, run code below , it can run without error

    but after put in file test.hs

    then :l test.hs

    got error

    Prelude> :l trees.hs
    [1 of 1] Compiling Main ( trees.hs, interpreted )
    parse error (possibly incorrect indentation or mismatched brackets)
    Failed, modules loaded: none.


    import Data.List
    import Control.Monad
    import Math.Combinat
    import System.IO
    import Data.Map (Map)
    import qualified Data.Map as Map

    let allparams = replicateM 2 [0.0, 1.0]
    let a1 = [0.0, 1.0, 1.0, 1.0]
    let a2 = [0.0, 0.0, 0.0, 1.0]
    let 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] ]

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