2016-10-15 7 views
0

:하스켈 다이어그램 오류 : "다이어그램을 선택하지 않았습니다." 나는 다음과 같은 주요 기능을 사용하여 다이어그램 세트를 만들려고하고

main = mainWith [("here0", myDiagram), ("here1", myDiagram)] 

을 다음과 같은 오류가 점점 오전 :

No diagram selected. 
Available diagrams: 
    here0 here1 

이 오류가 무엇을 의미하는지 어떤 생각을?


자세한 내용 :

내 "myDiagram는"유형이 있습니다

myDiagram :: Diagram B 

및 주요 기능 대신 때 프로그램이 제대로 작동합니다

main = mainWith myDiagram 

편집 :

의견에 감사드립니다. 링크 된 명령 줄 튜토리얼을보고 가능한 한 가깝게 (-s 옵션을 지정하는 것을 포함하여) 계속 시도했지만 여전히 동일한 문제로 실행 중입니다. 여기에 내가했던 정확히 무엇 :

는 파일 "Animation.hs"를 만든 :와,

ghc --make Animation.hs 

렌더링하는 데 사용할 수있는 다이어그램을 표시 :

./Animation --list 

{-# LANGUAGE NoMonomorphismRestriction #-} 

import Diagrams.Prelude 
import Diagrams.Backend.SVG.CmdLine 

main = mainWith [("myBlue", myBlue), ("myGreen", myGreen)] 

myBlue :: Diagram B 
myBlue = circle 1 # lw none # fc blue 

myGreen :: Diagram B 
myGreen = circle 1 # lw none # fc green 

를 통해 그것을 컴파일

예상대로 반환 됨 :

Available diagrams: 
    myBlue myGreen 

는 그러나 마침내 통해 .svg 년대 중 하나 생성을 시도 :

./Animation -o out.svg -w 400 -s myBlue 

은 반환 내가 부족하지만 보일 수없는 간단한 무언가가 있어야합니다 같은

No diagram selected. 
Available diagrams: 
    myBlue myGreen 

내 기분이 그것을 찾으려면 - "my blue"와 함께 나열된 사용 가능한 다이어그램을 지정합니다.

답변

2

이런 식으로 mainWith을 사용하는 경우 -S 명령 줄 옵션을 통해 렌더링 할 다이어그램을 선택해야합니다. 공식 comand-line tutorial을 인용 :

If we have multiple diagrams with names we can use mainWith to give an interface that allows the selection of a particular diagram by name.

> -- Multiple 
> 
> d1, d2, d3 :: Diagram SVG V2 Double 
> ... 
> 
> main = mainWith [("First", d1),("Second", d2),("Third", d3)] 

The --list option just lists the available diagrams to render and the -S selection option takes a name and renders the associated diagram with the standard options.

$ ./Multiple --list 
Available diagrams: 
    First Second Third 
$ ./Multiple -o d1.svg -w 100 -S First 

주를 사용하는 옵션 (2016년 10월 25일 현재) 튜토리얼처럼 -S, 그리고 -s입니다. 옵션이 this issue으로 변경되었지만 튜토리얼에 변경 사항이 아직 반영되지 않았습니다 (패치 수정이 수락되었으므로 곧 수정해야합니다).프로그램의 도움말 메시지는 정확합니다.

$ stack --resolver=lts-7.2 exec -- runhaskell Dag.hs -? 
Dag.hs 

Usage: Dag.hs [-?|--help] [-w|--width WIDTH] [-h|--height HEIGHT] 
       [-o|--output OUTPUT] [-l|--loop] [-s|--src ARG] 
       [-i|--interval INTERVAL] [-p|--pretty] [-S|--selection NAME] 
       [-L|--list] 
    Command-line diagram generation. 

Available options: 
    -?,--help    Show this help text 
    -w,--width WIDTH   Desired WIDTH of the output image 
    -h,--height HEIGHT  Desired HEIGHT of the output image 
    -o,--output OUTPUT  OUTPUT file 
    -l,--loop    Run in a self-recompiling loop 
    -s,--src ARG    Source file to watch 
    -i,--interval INTERVAL When running in a loop, check for changes every 
          INTERVAL seconds. 
    -p,--pretty    Pretty print the SVG output 
    -S,--selection NAME  NAME of the diagram to render 
    -L,--list    List all available diagrams 
+0

명명 된 조회 목록의 기능을 설계했을 때 생각했던 것이 궁금합니다. 그것은 꽤 쓸모없는 것, 또는 명령 행에서 전달되는 임의의 매개 변수를 허용하는 함수 인스턴스와 비교할 때 적어도 비효율적입니다. – leftaroundabout

+0

@leftaroundabout 정말 이상합니다. 내가 생각할 수있는 유일한 것은 다이어그램의 슬라이드 쇼를 배열하는 특이한 방식이라는 것입니다. – duplode