2012-01-26 16 views
7

कम करें मैंने हाल ही में हास्केल ग्रहण-प्लगइन "एक्लिप्ससेपी" स्थापित किया है। सबकुछ बहुत अच्छी तरह से काम करता है जबकि एक सुविधा है जो मुझे बहुत गुस्सा करती है हेहे। मैं आउटपुट के चेतावनी स्तर को कम नहीं कर सकता। ग्रहण/यह प्लगइन "-वॉल" ध्वज को स्वतः जोड़ना प्रतीत होता है, जो टाइप-चीजों के खिलाफ बहुत संवेदनशील है। एक उदाहरण पर इस दिखाने दें:ग्रहण (प्रकार) चेतावनी स्तर

*Main> head [1,2,3] 

<interactive>:1:11: 
    Warning: Defaulting the following constraint(s) to type `Integer' 
       (Num a0) arising from the literal `3' 
    In the expression: 3 
    In the first argument of `head', namely `[1, 2, 3]' 
    In the expression: head [1, 2, 3] 

<interactive>:1:11: 
    Warning: Defaulting the following constraint(s) to type `Integer' 
       (Num a0) arising from the literal `3' at <interactive>:1:11 
       (Show a0) arising from a use of `print' at <interactive>:1:1-12 
    In the expression: 3 
    In the first argument of `head', namely `[1, 2, 3]' 
    In the expression: head [1, 2, 3] 
1 
*Main> 

हां, यही वास्तव में कष्टप्रद है। यह "अंतर्निहित" कार्यों के साथ-साथ कस्टम पर भी होता है। एक और एक:

factorial :: (Integral a) => a -> a 
factorial 1 = 1 
factorial n = n * factorial (n-1) 

*Main> factorial 3 

<interactive>:1:1: 
    Warning: Defaulting the following constraint(s) to type `Integer' 
       (Integral a0) arising from a use of `factorial' 
          at <interactive>:1:1-9 
       (Num a0) arising from the literal `3' at <interactive>:1:11 
    In the expression: factorial 3 
    In an equation for `it': it = factorial 3 

<interactive>:1:1: 
    Warning: Defaulting the following constraint(s) to type `Integer' 
       (Integral a0) arising from a use of `factorial' 
          at <interactive>:1:1-9 
       (Num a0) arising from the literal `3' at <interactive>:1:11 
       (Show a0) arising from a use of `print' at <interactive>:1:1-11 
    In the expression: factorial 3 
    In an equation for `it': it = factorial 3 
6 
*Main> 
+0

आप वास्तव में इस कोड को कैसे लिखेंगे ताकि चेतावनी पहली जगह में दिखाई न दे? –

उत्तर

6

मैं ग्रहण के बारे में पता नहीं है, लेकिन आप अपने .ghci फ़ाइल में चेतावनी बंद कर सकते हैं।

:set -Wall   -- unnecessary if Eclipse already turns it on 
:set -fno-warn-type-defaults 
:set -fno-warn-unused-do-bind 

अपने ~/.ghci में डाल दिया और जो कुछ भी आपको चेतावनी दी के बारे में नहीं करना चाहते डिफ़ॉल्ट रूप से और महत्वपूर्ण लोगों को चेतावनी कम। यदि आप डिफ़ॉल्ट रूप से कुछ मॉड्यूल लोड करना चाहते हैं, तो आप import Control.Applicative (या जो भी) जोड़ सकते हैं।

+1

धन्यवाद, यह काम किया। ध्यान दें कि विंडोज़ पर, पथ सी होगा: \ उपयोगकर्ता \ \ AppData \ Roaming \ ghc \ ghci.conf - फ़ाइल बनाएं और उपरोक्त की प्रतिलिपि बनाएँ यदि फ़ाइल मौजूद नहीं है, फिर भी। – poitroae

2

उन आदेशों को suggested by Daniel Fischer को सीधे EclipseFP में रखने का एक तरीका है।

खोलें "भागो विन्यास ...", चयन तुम्हारा, करने के लिए "स्वचालन" टैब, प्रकार पाठ संपादन में एक कमांड में स्विच करें। दुर्भाग्यवश, यह एक पंक्ति संपादन प्रविष्टि है और जीएचसीआई एक पंक्ति में कई कमांड का समर्थन नहीं करता है।

हालांकि, आप कहीं भी मल्टी-लाइन टेक्स्ट टाइप कर सकते हैं और इसे इस टेक्स्ट एडिट में पेस्ट कर सकते हैं ताकि यह :set -fno-warn-type-defaults[000A]:set -fno-warn-unused-do-bind जैसा दिखाई दे।

वहाँ भी एक विशेष बहु लाइन पाठ "तर्क" नाम संपादित है लेकिन यह समस्या के बाद से इन तर्कों कि -Wall से पहले डाला जाता है का समाधान नहीं होता, इसलिए वे कोई मतलब नहीं है।

+1

एक सेट कमांड पर दो विकल्प डालना ठीक है जैसे: set -fno-warn-type-defaults -fno-warn-unused-do-bind –

5
.cabal फ़ाइल लिखने में

: ghc-options: -Wall -fno-warn-type-defaults -fno-warn-unused-do-bind

1

एक और दृष्टिकोण के बजाय इस व्यवहार बंद करने की बहस को जोड़ने का है, यह पहली जगह में वह चालू करने के रोकने के लिए है।

ग्रहण हैकेल प्रोजेक्ट के अंदर, eclispeProjectName .cabal नामक एक फ़ाइल है। यह वह जगह है जहां -Wall ghci तर्क परिभाषित किया गया है। उस लाइन पर टिप्पणी करें।

उदाहरण के लिए: एक ग्रहण हैकेल प्रोजेक्ट में हैकेलटेस्ट नामक प्रोजेक्ट में, परियोजना के शीर्ष स्तर पर haskelltest.cabal नामक एक फ़ाइल है। अपनी सामग्री को नीचे सेट करें - पिछली पंक्ति जहां मैंने ghc-options सेटिंग को टिप्पणी की है:

name:   haskelltest 
version:  0.1 
cabal-version: >=1.2 
build-type:  Simple 
author:   marty 

executable haskelltest 
    hs-source-dirs: src 
    main-is:   Main.hs 
    build-depends: base >= 4 
-- ghc-options:  -Wall 
+0

बीटीडब्ल्यू स्पष्ट रूप से बंद कर देता है -वॉल सेटिंग को खराब अभ्यास माना जाता है। [लिंक] देखें (http: // stackoverflow।कॉम/प्रश्न/4174629/प्रभाव-पर-शैली-के-जीसी-दीवार) तो भेड़ का बच्चा का दृष्टिकोण शायद बेहतर है। –

संबंधित मुद्दे