2017-10-08 6 views
0

나는 다음과 같은 모듈 찾고 있어요 : https://hackage.haskell.org/package/boxes-0.1.4/docs/src/Text-PrettyPrint-Boxes.html의 내용이cabal/stack 내에 CPP 정의를 어떻게 추가합니까?

: 나는/활성화 할 수는 TESTING 값을 정의하는 방법

module Text.PrettyPrint.Boxes 
    (-- * Constructing boxes 
#ifdef TESTING 
     Box(Box, content) 
#else 
     Box 
#endif 

- 개발 목적을? 이상적으로 GHCi 세션 내에서이 기능을 구현/활성화하고 싶습니다.

+0

'stack test'를 호출하면 플래그가 자동으로 설정됩니다. 현재이 CPP 플래그를 활성화 할 수있는 플래그가 없습니다. – epsilonhalbe

답변

1

나는 나 자신을 바로 잡아야한다. 내가 준 의견은 전적으로 그리고 완전히 틀렸다.

> git clone git://github.com/treeowl/boxes.git 
> cd boxes 
> stack init 
> stack ghci --ghc-options=-DTESTING 
split-0.2.3.2: using precompiled package 
boxes-0.1.4: configure (lib) 
Configuring boxes-0.1.4... 
boxes-0.1.4: initial-build-steps (lib) 
Completed 2 action(s). 
Configuring GHCi with the following packages: boxes 
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help 
Loaded GHCi configuration from ... 
[1 of 1] Compiling Text.PrettyPrint.Boxes (.../boxes/Text/PrettyPrint/Boxes.hs, interpreted) 
Ok, modules loaded: Text.PrettyPrint.Boxes. 
Loaded GHCi configuration from /tmp/ghci28386/ghci-script 
*Text.PrettyPrint.Boxes Text.PrettyPrint.Boxes> :t content 
content :: Box -> Content 

잘 작동합니다.

+0

이것은'stack ghci'가'boxes' 프로젝트에서 호출 될 때 오히려 그것이 cabal을 통해 의존성으로 포함될 때만 작동하는 것처럼 보입니다. –

+1

상자에 끌어 오기 요청을 보내고 기수 깃발을 제공하고 그 사이에 github 저장소를 사용할 수 있습니다. 스택에는 repo를 원본으로 사용하는 옵션이 내장되어 있습니다. 기밀을 위해 나는 잠시 그것을 사용하지 않았다. 그래서 이것이 여기의 옵션인지 모른다. – epsilonhalbe

+0

테스트 목적이 아닌 다른 것을 위해'content' 함수가 필요하다면 - 나는 관리자에게 상기 함수를 숨길 의도를 물어볼 것입니다! 편리하게 사용할 수있는 것들이 많이 있지만, 사용하면 위험이 커집니다. – epsilonhalbe