polymorphism - Coerce to multiple-parameter type in Haskell -


I have a type class IntegerAsType one where the value :: a -> Integer data T5 example IntegerAsType T5 where value_ = 5 newtype (number one, integer type n) = & gt; PolyRing A = PolyRing [A]

My main question is: How do I define a variable in a particular PolyRing

should do? Something like this:

  x = [1, 2, 3] :: integer T5   

(I think) The question is: right What is :: ?

After syntax I am getting the error

  with the actual type the required type can not be matched with the 'PolyRing Integer T5' In the expression '[t0]': [1, 2, 3] :: PolyRing integer for T5 'x in an equation': x = [1, 2, 3] :: PolyRing integer T5   

Besides, I'm looking for a better way to implement it. In particular, I really want to estimate a with the list elements, while should specify integerAsType n (this should not depend on the length of the list , Even if it is possible).

I have tried so far:

  x = [1,2,3] :: polyring (integer, t5) x = [1,2,3 ] :: PolyRing Integer T5    

First note

Data type references, such as:

  newtype (number one, integer type n) = & gt; PolyRing A = Polarizing [A]   

Generally a bad idea and has retired from language.

Do not ignore it

To make an example, you need to type the Data Constructor PolyRing :

  PolyRing [1,2,3]   

But this is not enough, so far the type of guess would be (IntegerAsType n) = & gt; PolyRing integer n your last type of signature will terminate it two x = polarizing [1,2,3] :: Integration for T5.

Back to the first note

However, maybe you wanted to:

  newtype PolyRing a = PolyRing [a ]   

And every function that creates or consumes a polywier can apply the necessary obstacles:

  func :: (name one, integer type N) = & gt; Polarizing a n - & gt; ...    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -