I have the following code right now:
Require Import Category.
Require Import Sized.
Require Import Combinators.
Require Import Numbers.
Require Import NEList.
Require Import Coq.NArith.NArith.
Require Import Coq.QArith.QArith.
Require Import Ascii.
Local Open Scope char.
Require Import Coq.Lists.List.
Import ListNotations.
Section Helpers.
Context
{M : Type -> Type}
`{RF : RawFunctor M}
`{RA : RawApplicative M}
`{RM : RawMonad M}
`{RT : RawAlternative M}
{Chars : nat -> Type} `{Sized Chars ascii}
{n : nat}.
Definition decimal_digit_N : Parser Chars ascii M N n :=
alts ((0 <$ exact "0")%N
:: (1 <$ exact "1")%N
:: (2 <$ exact "2")%N
:: (3 <$ exact "3")%N
:: (4 <$ exact "4")%N
:: (5 <$ exact "5")%N
:: (6 <$ exact "6")%N
:: (7 <$ exact "7")%N
:: (8 <$ exact "8")%N
:: (9 <$ exact "9")%N
:: nil).
Definition decimal_N : Parser Chars ascii M N n :=
let convert ds := foldl (fun ih d => 10 * ih + d)%N ds 0%N
in Combinators.map convert (nelist decimal_digit_N).
Definition float_Q : Parser Chars ascii M Q n :=
decimal_N >>= fun x : N =>
match x return Parser Chars ascii M Q n with
| N0 => (Qmake <$> decimal_int) <*> pure 1%positive
| Npos p => (Qmake <$> decimal_int) <*> pure p
end.
End Helpers.
When I tried to type check float_Q, I get:
Error:
Unable to satisfy the following constraints:
In environment:
M : Type -> Type
RF, H : RawFunctor M
RA : RawApplicative M
H0 : RawFunctor M
H1 : RawApplicative M
RM : RawMonad M
H2 : RawFunctor M
H3 : RawApplicative M
RT : RawAlternative M
Chars : nat -> Type
H4 : Sized Chars ascii
n : nat
x : N
?F : "Type -> Type"
?H : "RawFunctor ?F"
?H0 : "RawApplicative ?F"
As you can see, there are somehow three RawFunctor M instances in scope, which I don't quite understand. I've tried various combinations of explicit arguments, but I was wondering if you could help me understand what I'm doing wrong here?
I have the following code right now:
When I tried to type check
float_Q, I get:As you can see, there are somehow three
RawFunctor Minstances in scope, which I don't quite understand. I've tried various combinations of explicit arguments, but I was wondering if you could help me understand what I'm doing wrong here?