-2
A
答えて
1
fst
はタイプ(a, b) -> a
(まあ、私たちは(Int, Int) -> Int
として、より具体的な方法でそれを使用している)が、我々はタイプError (Int, Int)
を持ってmixIt 2 2
にそれを適用しているとの関数です。これが私たちのエラーの原因です。我々はそれ
case mixIt 2 2 of
Nice tuple -> fst tuple
我々は、我々が持っているNice
コンストラクタを持っている場合に明示的にパターンマッチすることができます上のパターンマッチングによってバックmixIt
から取得Error
値を検査する必要があり、それを修正するために
私たちが引数として必要とするタプル。しかし、mixIt
もWoops
、もう1つのコンストラクタError
を返す可能性があるため、問題があります。私たちはあなたが行くように設定されているケース式の最後のブランチに記入します一度
case mixIt 2 2 of
Nice tuple -> fst tuple
Whoops -> ... some Haskell code to produce another tuple ...
(非常に悪いことで)そうでない場合は、私たちのプログラムは、実行時に失敗します別にそのケースを処理する必要があります。
関連する問題
- 1. カスタムコンパレータ<int型、ペア<int, int>>
- 2. インスタンスは、私が</p> <pre><code>data GameAction = GameAction (Int, Int) deriving (Eq) </code></pre> <p>データ型の読み取りインスタンスを実装する必要がHaskellの
- 3. ベクトル<int> v(istream_iterator <int>(cin)、istream_iterator <int>());
- 4. argv []をintとしてどのように取得できますか?私はこれを行う</p> <pre><code>int main (int argc, char *argv[]) { printf("%d\t",(int)argv[1]); printf("%s\t",(int)argv[1]); } </code></pre> <p>とシェルで:
- 5. は、暗黙的変換が</p> <pre><code>struct A { int val = 42; operator int() const { return val; } </code></pre> <p>ので、私はこのようにそれを使用することができますintにのは、私が指定したクラスAがあるとしましょうタイプ
- 6. のJava SWT:</p> <pre><code>GC.drawLine(int x1, int y1, int x2, int y2); </code></pre> <p>どのように私はラインの色を変更します:私は使用して線を描画していた場合GC.drawline
- 7. 地図<'a, int>
- 8. 建設中の初期化?私は<code>a(c), b(a)</code>として<code>a</code>で<code>b</code>の初期化についてはよく分からない、今</p> <pre><code>struct A{ int a; int b; A(int c): a(c), b(a){ } }; int main() { A b(10); } </code></pre> <p>:
- 9. ベクトル<pair <int、pair <int,int> >> Pythonのデータ構造
- 10. は、私は、単純な乗算アプリケーションと</p> <pre><code>public virtual int Multi(int a, int b) { return a * b; } </code></pre> <p>をしようとしていますユニットテストケース
- 11. 定義、初期化、および使用方法 - ベクトル<ベクトル<ペア< int,int >、int>> v C++では?
- 12. unique_ptr <int[]>またはベクター<int>?
- 13. constポインタをintに宣言しますか?</p> <pre><code>int* p1; // pointer to int const int* p2; // pointer to constant int int* const p3; // constant pointer to int const int* const p4; // constant pointer to constant int </code></pre> <p>とDに:私たちは、次のしているC++では
- 14. は、私がここに<code>int</code>が<code>priority_queue</code>の外で定義されたベクトル<code>arr</code>のインデックスを格納<code>priority_queue<int, vector<int>, TCOMP></code>などのカスタム<code>priority_queue</code>を定義したいPRIORITY_QUEUE
- 15. ラムダ型をint => IEnumerable <string>> int =>タスク<IEnumerable <string> >>に変換しますか?
- 16. は '>' 私は</p> <blockquote> <p>が '>' 'STR' と 'int型</p> </blockquote> <p>しばらくのインスタンス間でサポートされていないエラーが発生しました 'STR' と「int型
- 17. のNullPointerException:} 'int型android.graphics.Bitmap.getWidth()' 私は以下のような<code>error</code>を取得しています</p> <p>を...
- 18. 2つの合計型を含むデータ型?</p> <pre><code>data Foo = A Int | B String data Bar = C Int | D String </code></pre> <p>私は<code>Either (Foo or Bar) String</code>を返す関数を定義したいと思います:
- 19. ソート一覧<タプル<int, int>>インプレース
- 20. なぜコンストラクタは一度だけ呼び出されますか?私は出力を取得しています</p> <pre><code>class A { public: A(int i) { cout<<"Called"<<endl; } }; int main() { vector<A> v(5,A(1)); return 0; } </code></pre> <p>:
- 21. 私はint型のペアを含むセットを持っている場合は、</p> <pre><code>set<pair<int,int> > cells; </code></pre> <p>は、どのように私は「検索」を使用して設定でペアを抜けるかどうかを見つけることができ++
- 22. intを0に初期化するかどうかを指定します。私は、彼らがJavaでは</p> <pre><code>protected int mPaddingRight = 0; protected int mPaddingLeft = 0; protected int mPaddingTop; protected int mPaddingBottom; </code></pre> <p>として4つの変数を定義する参照アンドロイドのソースコードで
- 23. C++:マップ<string, int>をイテレータを使用してベクトル<map <string, int>>にプッシュバックしますか?
- 24. なぜフォーオールですか? Intのサブタイプとは見なされませんが、forall型の式を使用できます。 Int型のどこでも期待されていますか?</p> <pre><code>a :: forall a. a a = undefined b :: Int b = a </code></pre><p>即ち:
- 25. <Int> == <String>
- 26. 読み取り専用ディクショナリ<int、List <int>>
- 27. ハスケル:私は<code>Int</code>は頂点のインデックス番号であると<code>[Vertex]</code>がこの頂点に隣接する頂点であるカスタム再帰的なデータ型</p> <pre><code>data Vertex = Vertex Int [Vertex] </code></pre> <p>を持って再帰的なデータ型
- 28. "multiset <int、greater <int>> ms1"と "multiset <int> ms2(より大きい<int>()の違いは何ですか?"
- 29. タプルの要素による並べ替え<int、Tuple <int、int、int、int、string、int >>
- 30. メモリ効率の良いマップ<pair <int,int>、set <int>>代替
ありがとう、私は実際に解決策を何を検索するか分からなかったので、Web上でこれについて何かを見つけることができませんでした。もう一度ありがとう、大きな助けでした! – something
@何か問題はない、ハスケルを学ぶ幸運:) – jozefg