masaedw / PuddingX

BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Envを消してEnvTにする #7

Closed masaedw closed 11 years ago

masaedw commented 11 years ago

Rank2Typesにすればできるのかなぁと思ったけどそうでもないみたい

masaedw commented 11 years ago

d01f5d696 のコミットで

[1 of 2] Compiling Pudding.Parse    ( Pudding/Parse.hs, interpreted )
[2 of 2] Compiling Pudding          ( Pudding.hs, interpreted )

Pudding.hs:140:25:
    Could not deduce (m ~ m1)
    from the context (Monad m)
      bound by the type signature for
                 insertWord :: Monad m => ByteString -> Meaning m -> EnvT m ()
      at Pudding.hs:(138,1)-(140,63)
    or from (Monad m1)
      bound by a type expected by the context:
                 Monad m1 => Map ByteString (Meaning m1)
      at Pudding.hs:140:9-63
      `m' is a rigid type variable bound by
          the type signature for
            insertWord :: Monad m => ByteString -> Meaning m -> EnvT m ()
          at Pudding.hs:138:1
      `m1' is a rigid type variable bound by
           a type expected by the context:
             Monad m1 => Map ByteString (Meaning m1)
           at Pudding.hs:140:9
    Expected type: Map ByteString (Meaning m1)
      Actual type: Map ByteString (Meaning m)
    In the `wordMap' field of a record
    In the second argument of `($)', namely
      `env {wordMap = insert name meaning $ wordMap env}'
Failed, modules loaded: Pudding.Parse.

こうなる

swtw7466 commented 11 years ago

put の行では insertWord が宣言している Meaning の m (= 定義を辿れば EnvT のm) と Environment に入っている Meaning の m (エラーメッセージでは m1) は同じ型であるべきなのに、 同じであるということがワカランでよ…というメッセージに見えるんだけども、 これ、同じであると仮定してコンパイル進めるってーのはできないんですかね。 できないんですよね、エラーになってるわけだから。 ちょっとこのへん、具体的に何がどうっていう話なのかよく分からないですね。 "m1 is rigid type variable bound by" って言ってるから、 Environment の定義のところで一旦 "rigid" な型を当てはめたんでしょうけども。

でまあ、詳しいことはワカランにせよ、 同じであることさえ分かればコンパイルは通るみたいなので通るようにしてみたんですけど、 これこの Issue に直接 Pull Request 張れないんですかねえ。

masaedw commented 11 years ago

pull request をマージしてmasterにもマージしました。