隠れている

  • HaskellForMathsなるパッケージをとってきて使おうと思った
    • cabalでインストールできた。たしかにローカルPCにあるし、leksahのModuleペインにも見えている
$ cabal install HaskellForMaths
    • インストールはファイルの在処まで行って、Setup.hsでもやってみた
$ runhaskell Setup.hs configure
$ runhaskell Setup.hs build
$ su 
$ runhaskell Setup.hs install
      • これもうまく行った
  • だけれども、leksahのファイル書きで、import Math.Combinatorics.Graph (これはHaskellForMathsの中のモジュール)と書いてやっても、オートフィルでHakellForMathsのモジュールファイルが表示されないし
  • 書いた上でビルドしたり、ランしたりすると、エラーが出る。次のようなエラー
Could not find 'Math.Combinatorics.Graph'
It is a member of a hidden package 'HaskellForMaths-0.4.5'.
Perhaps you need to add 'HaskellForMaths' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
  • ここでハスケルのhidden packageとは何ぞ?となる
    • こちらにも書かれているように、基本的には、パッケージはhiddenであって、ひょいひょいとimportして使えるわけではないらしい
  • ghcの起動時にオプションをつけたりして対応することはできるようだが、王道ではなさそう
  • 結局、.cabalファイルに依存関係を書き込むのが正解
  • leksahで新しいパッケージを作ったときのデフォルトの.cabalファイルを以下に示し、依存関係を書き込んだそれも、対応箇所を抜粋して以下に示す
    • デフォルト
-- Instructions on how to write this file are in the Cabal
-- documentation, which can be found here:
--   http://haskell.org/cabal/release/cabal-latest/doc/users-guide/

name: test
version: 1.0.0.2
license: BSD3
license-file: LICENSE
copyright: (c) Simon Marlow
author: Simon Marlow
maintainer: Simon Marlow <marlowsd@gmail.com>
bug-reports: mailto:marlowsd@gmail.com
stability: stable
homepage: http://www.haskell.org/hello/
synopsis: Hello World, an example package
category: Console, Text
cabal-version: >= 1.6
build-type: Simple

Description:
  This is an implementation of the classic "Hello World" program in
  Haskell, as an example of how to create a minimal Haskell
  application using Cabal and Hackage.  Please submit any suggestions and
  improvements.

source-repository head
  type:     darcs
  location: http://darcs.haskell.org/hello/

flag threaded
  default: False

executable test
  hs-source-dirs: src
  main-is: hello.hs
  build-depends: base >= 4.2 && < 5

  if flag(threaded)
     ghc-options: -threaded
    • executable test の中のbuild-depends: に書き込む。パッケージの追加は','区切り
executable test
  hs-source-dirs: src
  main-is: hello.hs
  build-depends: base >= 4.2 && < 5, HaskellForMaths
  • これにより、importしてもおこられなくなって、きちんと回った(モジュールを使った処理はしていないプログラムだけれど…)
    • まず、configureして、パッケージ依存関係を教えて(?)、ビルドして、ランする
module Main (main) where

import Math.Combinatorics.Graph

main = putStrLn "Hello, World!"
  • HaskellForMathsパッケージの関数を使った処理をさせてみる
module Main (main) where

import Math.Combinatorics.Graph

main = print $ q 3
  • こう出てくる
Preprocessing executable 'test' for test-1.0.0.2...
G [0,1,2,3,4,5,6,7] [[0,1],[0,2],[0,4],[1,3],[1,5],[2,3],[2,6],[3,7],[4,5],[4,6],[5,7],[6,7]]
  • ちなみにghciにモジュールをつけて起動すると…以下のようにずらーーーーと処理しながら環境を整えてくれて、指定したモジュールMath.Combinatorics.Graphが使える状態でスタートできることがわかる
MacBookProLate2013:HaskellForMaths-0.4.5 ryamada$ ghci -v Math.Combinatorics.Graph
GHCi, version 7.8.3: http://www.haskell.org/ghc/  :? for help
Glasgow Haskell Compiler, Version 7.8.3, stage 2 booted by GHC version 7.6.3
Using binary package database: /Library/Frameworks/GHC.framework/Versions/7.8.3-x86_64/usr/lib/ghc-7.8.3/package.conf.d/package.cache
Using binary package database: /Users/ryamada/.ghc/x86_64-darwin-7.8.3/package.conf.d/package.cache
wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-954cb57749cf319beafdc89b3415422c
wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-d42e6a7874a019e6a0d1c7305ebc83c4
wired-in package base mapped to base-4.7.0.1-df210ede1eb79477fef5662549c32927
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.9.0.0-1b116efce4b8d0d027f75248473a95bb
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags: 
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
*** gcc:
/usr/bin/gcc -m64 -fno-stack-protector -DTABLES_NEXT_TO_CODE -L/Library/Frameworks/GHC.framework/Versions/7.8.3-x86_64/usr/lib/ghc-7.8.3/base-4.7.0.1 --print-file-name libiconv.dylib
Loading package base ... linking ... done.
*** Chasing dependencies:
Chasing modules from: 
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Ready for upsweep []
Upsweep completely successful.
*** Deleting temp files:
Deleting: 
*** Chasing dependencies:
Chasing modules from: *Math.Combinatorics.Graph
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Ready for upsweep
  [NONREC
      ModSummary {
         ms_hs_date = 2015-01-30 08:24:10 UTC
         ms_mod = main:Math.Core.Utils,
         ms_textual_imps = [import (implicit) Prelude,
                            import qualified Data.Set as S, import Data.List as L]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = 2015-01-30 08:24:10 UTC
         ms_mod = main:Math.Core.Field,
         ms_textual_imps = [import (implicit) Prelude,
                            import Math.Core.Utils ( FinSet, elts ), import Data.List as L,
                            import Data.Bits, import Data.Ratio]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = 2015-01-30 08:24:10 UTC
         ms_mod = main:Math.Common.ListSet,
         ms_textual_imps = [import (implicit) Prelude,
                            import Data.List ( group, sort )]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = 2015-01-30 08:24:10 UTC
         ms_mod = main:Math.Algebra.LinearAlgebra,
         ms_textual_imps = [import (implicit) Prelude,
                            import Math.Core.Field, import qualified Data.List as L]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = 2015-01-30 08:24:10 UTC
         ms_mod = main:Math.Algebra.Group.PermutationGroup,
         ms_textual_imps = [import (implicit) Prelude,
                            import Math.Algebra.LinearAlgebra hiding ( inverse ),
                            import Math.Core.Utils hiding ( elts ),
                            import Math.Common.ListSet ( toListSet, union, (\\) ),
                            import qualified Data.Set as S, import qualified Data.Map as M,
                            import qualified Data.List as L]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = 2015-01-30 08:24:10 UTC
         ms_mod = main:Math.Algebra.Group.SchreierSims,
         ms_textual_imps = [import (implicit) Prelude,
                            import Math.Core.Utils hiding ( elts ),
                            import Math.Common.ListSet ( toListSet ),
                            import Math.Algebra.Group.PermutationGroup
                                hiding ( elts,
                                         order,
                                         gens,
                                         isMember,
                                         isSubgp,
                                         isNormal,
                                         reduceGens,
                                         normalClosure,
                                         commutatorGp,
                                         derivedSubgp ),
                            import qualified Data.Map as M, import qualified Data.Set as S,
                            import Data.Maybe ( isNothing, isJust ),
                            import qualified Data.List as L]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = 2015-01-30 11:58:54 UTC
         ms_mod = main:Math.Combinatorics.Graph,
         ms_textual_imps = [import (implicit) Prelude,
                            import Math.Algebra.Group.SchreierSims as SS,
                            import Math.Algebra.Group.PermutationGroup
                                hiding ( fromDigits, fromBinary ),
                            import Math.Core.Utils, import Math.Common.ListSet as LS,
                            import Control.Arrow ( (&&&) ), import qualified Data.Set as S,
                            import qualified Data.Map as M, import Data.Maybe ( isJust ),
                            import qualified Data.List as L]
         ms_srcimps = []
      }]
*** Deleting temp files:
Deleting: 
compile: input file ./Math/Core/Utils.hs
Created temporary directory: /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0
*** Checking old interface for main:Math.Core.Utils:
[1 of 7] Compiling Math.Core.Utils  ( Math/Core/Utils.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size of Desugar (after optimization)
  = {terms: 703, types: 950, coercions: 0}
*** Simplifier:
Result size of Simplifier iteration=1
  = {terms: 691, types: 953, coercions: 2}
Result size of Simplifier iteration=2
  = {terms: 691, types: 953, coercions: 2}
Result size of Simplifier = {terms: 691, types: 953, coercions: 2}
*** Tidy Core:
Result size of Tidy Core = {terms: 699, types: 969, coercions: 6}
*** CorePrep:
Result size of CorePrep = {terms: 918, types: 1,250, coercions: 6}
*** ByteCodeGen:
*** Deleting temp files:
Deleting: /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_2.c /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_1.o
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_2.c
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_1.o
compile: input file ./Math/Core/Field.hs
*** Checking old interface for main:Math.Core.Field:
[2 of 7] Compiling Math.Core.Field  ( Math/Core/Field.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size of Desugar (after optimization)
  = {terms: 3,983, types: 5,317, coercions: 440}
*** Simplifier:
Result size of Simplifier iteration=1
  = {terms: 3,807, types: 5,397, coercions: 1,012}
Result size of Simplifier
  = {terms: 3,807, types: 5,397, coercions: 1,012}
*** Tidy Core:
Result size of Tidy Core
  = {terms: 3,807, types: 5,397, coercions: 1,012}
*** CorePrep:
Result size of CorePrep
  = {terms: 4,676, types: 5,883, coercions: 1,012}
*** ByteCodeGen:
*** Deleting temp files:
Deleting: /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_4.c /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_3.o
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_4.c
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_3.o
compile: input file ./Math/Common/ListSet.hs
*** Checking old interface for main:Math.Common.ListSet:
[3 of 7] Compiling Math.Common.ListSet ( Math/Common/ListSet.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size of Desugar (after optimization)
  = {terms: 301, types: 290, coercions: 0}
*** Simplifier:
Result size of Simplifier iteration=1
  = {terms: 277, types: 281, coercions: 0}
Result size of Simplifier = {terms: 271, types: 273, coercions: 0}
*** Tidy Core:
Result size of Tidy Core = {terms: 271, types: 273, coercions: 0}
*** CorePrep:
Result size of CorePrep = {terms: 327, types: 330, coercions: 0}
*** ByteCodeGen:
*** Deleting temp files:
Deleting: /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_6.c /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_5.o
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_6.c
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_5.o
compile: input file ./Math/Algebra/LinearAlgebra.hs
*** Checking old interface for main:Math.Algebra.LinearAlgebra:
[4 of 7] Compiling Math.Algebra.LinearAlgebra ( Math/Algebra/LinearAlgebra.hs, interpreted )
*** Parser:
*** Renamer/typechecker:

Math/Algebra/LinearAlgebra.hs:45:3: Warning:
    Local definition of ‘<*>’ clashes with a future Prelude name - this will become an error in GHC 7.10, under the Applicative-Monad Proposal.
*** Desugar:
Result size of Desugar (after optimization)
  = {terms: 1,427, types: 1,999, coercions: 0}
*** Simplifier:
Result size of Simplifier iteration=1
  = {terms: 1,444, types: 1,991, coercions: 0}
Result size of Simplifier iteration=2
  = {terms: 1,435, types: 1,976, coercions: 0}
Result size of Simplifier
  = {terms: 1,435, types: 1,976, coercions: 0}
*** Tidy Core:
Result size of Tidy Core
  = {terms: 1,435, types: 1,976, coercions: 0}
*** CorePrep:
Result size of CorePrep
  = {terms: 2,018, types: 2,550, coercions: 0}
*** ByteCodeGen:
*** Deleting temp files:
Deleting: /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_8.c /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_7.o
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_8.c
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_7.o
compile: input file ./Math/Algebra/Group/PermutationGroup.hs
*** Checking old interface for main:Math.Algebra.Group.PermutationGroup:
[5 of 7] Compiling Math.Algebra.Group.PermutationGroup ( Math/Algebra/Group/PermutationGroup.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size of Desugar (after optimization)
  = {terms: 3,741, types: 6,125, coercions: 105}
*** Simplifier:
Result size of Simplifier iteration=1
  = {terms: 3,715, types: 5,638, coercions: 295}
Result size of Simplifier iteration=2
  = {terms: 3,699, types: 5,574, coercions: 260}
Result size of Simplifier iteration=3
  = {terms: 3,699, types: 5,574, coercions: 254}
Result size of Simplifier
  = {terms: 3,699, types: 5,574, coercions: 254}
*** Tidy Core:
Result size of Tidy Core
  = {terms: 3,699, types: 5,574, coercions: 254}
*** CorePrep:
Result size of CorePrep
  = {terms: 5,053, types: 7,491, coercions: 254}
*** ByteCodeGen:
*** Deleting temp files:
Deleting: /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_10.c /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_9.o
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_10.c
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_9.o
compile: input file ./Math/Algebra/Group/SchreierSims.hs
*** Checking old interface for main:Math.Algebra.Group.SchreierSims:
[6 of 7] Compiling Math.Algebra.Group.SchreierSims ( Math/Algebra/Group/SchreierSims.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size of Desugar (after optimization)
  = {terms: 1,122, types: 2,738, coercions: 3}
*** Simplifier:
Result size of Simplifier iteration=1
  = {terms: 1,114, types: 2,668, coercions: 12}
Result size of Simplifier
  = {terms: 1,114, types: 2,668, coercions: 12}
*** Tidy Core:
Result size of Tidy Core
  = {terms: 1,114, types: 2,668, coercions: 12}
*** CorePrep:
Result size of CorePrep
  = {terms: 1,406, types: 3,275, coercions: 12}
*** ByteCodeGen:
*** Deleting temp files:
Deleting: /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_12.c /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_11.o
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_12.c
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_11.o
compile: input file ./Math/Combinatorics/Graph.hs
*** Checking old interface for main:Math.Combinatorics.Graph:
[7 of 7] Compiling Math.Combinatorics.Graph ( Math/Combinatorics/Graph.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size of Desugar (after optimization)
  = {terms: 3,433, types: 4,443, coercions: 0}
*** Simplifier:
Result size of Simplifier iteration=1
  = {terms: 3,373, types: 4,337, coercions: 0}
Result size of Simplifier iteration=2
  = {terms: 3,351, types: 4,310, coercions: 0}
Result size of Simplifier
  = {terms: 3,351, types: 4,310, coercions: 0}
*** Tidy Core:
Result size of Tidy Core
  = {terms: 3,351, types: 4,310, coercions: 0}
*** CorePrep:
Result size of CorePrep
  = {terms: 5,147, types: 6,099, coercions: 0}
*** ByteCodeGen:
Upsweep completely successful.
*** Deleting temp files:
Deleting: /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_14.c /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_13.o
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_14.c
Warning: deleting non-existent /var/folders/js/6kthw60j3hv00n0mf55zkctw0000gn/T/ghc8667_0/ghc8667_13.o
Ok, modules loaded: Math.Algebra.LinearAlgebra, Math.Algebra.Group.PermutationGroup, Math.Algebra.Group.SchreierSims, Math.Combinatorics.Graph, Math.Common.ListSet, Math.Core.Utils, Math.Core.Field.
*Math.Combinatorics.Graph> q 3
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
G [0,1,2,3,4,5,6,7] [[0,1],[0,2],[0,4],[1,3],[1,5],[2,3],[2,6],[3,7],[4,5],[4,6],[5,7],[6,7]]
*Math.Combinatorics.Graph>