OK, I've defined my own datatype that represents a variable polynoms in Haskell.
Data Polinomio a where Pol :: (number) = & gt; A - & gt; Integer - & gt; Polinoamio A - & gt; Palinomio One Causes :: (Name A) => A - & gt; Polinomio a I used GADTs to force a variable related to the NAM class here. Now I want to define my own example for the function class
example. Future Polinomio where fmap f (cons x) = opposition $ fx fmap f (Pol xgp) = Pol (fx) G (fmap) FP) And it does not compile from giving me this reason:
Polinomio_GADT.hs: 31: 23: Number (B) with the constructor using the reference (nominate) bound by a pattern with 'opposition': number one => A - & gt; In an equation on Polinomio_GADT.hs for Polinomio A, `FMAP ': 31: 13-18 Potential Improvement: Add (name B) in the context of the data constructor' reference 'or type signature for FMAP :: (a - & Gt; b) - & gt; Polinoamio A - & gt; In polinomio b expression: in opposition expression: in an equation for the opposition $ fx `fmap ': fmap f (cons x) = opposition $ fx Polinomio_GADT.hs: 32: 26: reference created by a pattern with constructor pole ( Use of `Polls' from the numbers: Everyone. Number one = & gt; A - & gt; Integer - & gt; Polinoamio A - & gt; Polinomio One, in an equation for `fmap 'at Polinomio_GADT.hs: 32: 13-21 Potential Improvement: Add a reference (name B) to the data constructor' pole 'or type signature for FMAP :: (a - & gt) ; B) - & gt; Polinoamio A - & gt; In polinomio b expression: Pol (fx) g (fmap fp) in an equation for `fmap ': fmap f (Pol xgp) = Pol (fx) g (fmap fp)' Functor Polinomio 'code> < P> So I try to add this barrier to the fmap definition using the language extension: instanceSigs: Example Functor Polinomio where fmap :: (number one, number b) -> gt; ; (A -> B) - & gt; Polinoamio A - & gt; Polinomio b fmap f (cons x) = Cons $ fx fmap f (Pol xgp) = Pol (fx) g (fmap fp) And it does not get it from the compiler: / P>
Polinomio_GADT.hs: 31: 13: 'is used as a number (number number)' in the type sign for 'fmap': fmap :: (number one, number b) - & gt; (A -> B) - & gt; Polinoamio A - & gt; How can I correct any idea?
you type data
data Polinomio a where Pol :: ( Num a) = & gt; A - & gt; Integer - & gt; Polinoamio A - & gt; Palinomio One Causes :: (Name A) => A - & gt; Polinomio a Now looking at its definition of Phantaka
Example Painter Polinomio where fmap f (cons x) = Cons $ fx fmap f (Pol Xgp) = Pole (Fx) G (FMAP FP) Due to the lack of x for number due to GAD GADT Odds may be imposed. But the problem is in the unrestricted function f as f :: a -> B, X :: number one = & gt; b to be a infers f x type. So it is f x to Num b = & gt; Not limited to. B which is required for against .
Therefore, guided by Daniel, you can not add obstacles to your Factor class. Either you can define your own restricted Functor class or you can use RFunctor.
No comments:
Post a Comment