Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  instance (Alexander Chen)
   2. Re:  instance (Ut Primum)
   3.  instance 2 (Alexander Chen)
   4. Re:  instance 2 (Ut Primum)


----------------------------------------------------------------------

Message: 1
Date: Wed, 22 Apr 2020 20:10:23 +0200 (CEST)
From: Alexander Chen <alexan...@chenjia.nl>
To: beginners@haskell.org
Subject: [Haskell-beginners] instance
Message-ID: <2038347538.89633.1587579022...@ichabod.co-bxl>
Content-Type: text/plain; charset="utf-8"

Hi,

data TisanInteger = Tisan Integer

instance Eq (Tisan Integer) where (Tisan v) == (Tisan v') = v == v'

prelude>
Instance_testen.hs:7:14: error:
    Not in scope: type constructor or class ‘Tisan’
    A data constructor of that name is in scope; did you mean DataKinds?
  |
7 | instance Eq (Tisan Integer) where (Tisan v) == (Tisan v') = v == v'   |     
         ^^^^^
[1 of 1] Compiling Main             ( Instance_testen.hs, interpreted )
Failed, no modules loaded.

what am i doing wrong?

best,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200422/210a8b0c/attachment-0001.html>

------------------------------

Message: 2
Date: Wed, 22 Apr 2020 20:20:57 +0200
From: Ut Primum <utpri...@gmail.com>
To: Alexander Chen <alexan...@chenjia.nl>,  The Haskell-Beginners
        Mailing List - Discussion of primarily beginner-level topics related
        to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] instance
Message-ID:
        <canjdmklxyfn1guj3gjdkovmyu6c0ush8aahfpdhhzmuoc-d...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi,

data TisanInteger = Tisan Integer
instance Eq (*Tisan Integer*) where (Tisan v) == (Tisan v') = v == v'

I think the part in red is the error: you should write *TisanInteger*
instead (with no space between Tisan and Integer):
This is because there you should put the name of the data, not its
definition.

Best,

Ut


Il giorno mer 22 apr 2020 alle ore 20:11 Alexander Chen <
alexan...@chenjia.nl> ha scritto:

> Hi,
>
>
> *data TisanInteger = Tisan Integer*
>
> *instance Eq (Tisan Integer) where (Tisan v) == (Tisan v') = v == v'*
>
> *prelude>*
> *Instance_testen.hs:7:14: error:*
> *    Not in scope: type constructor or class ‘Tisan’*
> *    A data constructor of that name is in scope; did you mean DataKinds?*
> *  |*
> *7 | instance Eq (Tisan Integer) where (Tisan v) == (Tisan v') = v == v'
>  |              ^^^^^*
> *[1 of 1] Compiling Main             ( Instance_testen.hs, interpreted )*
> *Failed, no modules loaded.*
>
>
>
> what am i doing wrong?
>
> best,
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200422/1374c89e/attachment-0001.html>

------------------------------

Message: 3
Date: Wed, 22 Apr 2020 21:13:58 +0200 (CEST)
From: Alexander Chen <alexan...@chenjia.nl>
To: beginners@haskell.org
Subject: [Haskell-beginners] instance 2
Message-ID: <340361797.93178.1587582838...@ichabod.co-bxl>
Content-Type: text/plain; charset="utf-8"

hi,

data StringOrInt = TisanInt Int | TisAString String

instance Eq (StringOrInt) where 
(==) (TisanInt v) (TisanInt v') = v == v'
(==) (TisAString s) (TisAString s') = s == s'

prelude>

Instance_testen.hs:4:37: error:
    Ambiguous occurrence ‘==’
    It could refer to either ‘Prelude.==’,
                             imported from ‘Prelude’ at Instance_testen.hs:1:1
                             (and originally defined in ‘GHC.Classes’)
                          or ‘Main.==’, defined at Instance_testen.hs:4:1
  |
4 | (==) (TisanInt v) (TisanInt v') = v == v'   |                               
      ^^

Instance_testen.hs:5:41: error:
    Ambiguous occurrence ‘==’
    It could refer to either ‘Prelude.==’,
                             imported from ‘Prelude’ at Instance_testen.hs:1:1
                             (and originally defined in ‘GHC.Classes’)
                          or ‘Main.==’, defined at Instance_testen.hs:4:1
  |
5 | (==) (TisAString s) (TisAString s') = s == s' 
  |                                         ^^
[1 of 1] Compiling Main             ( Instance_testen.hs, interpreted )
Failed, no modules loaded.

what gives?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200422/402a5602/attachment-0001.html>

------------------------------

Message: 4
Date: Wed, 22 Apr 2020 21:49:46 +0200
From: Ut Primum <utpri...@gmail.com>
To: Alexander Chen <alexan...@chenjia.nl>,  The Haskell-Beginners
        Mailing List - Discussion of primarily beginner-level topics related
        to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] instance 2
Message-ID:
        <canjdmklnylwb_rc0y0+qggvitudr-6hycopyppgp02jkf-c...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi,

I think the problem is indentation. Write the code this way:

data StringOrInt = TisanInt Integer | TisAString String

instance Eq (StringOrInt) where
  (==) (TisanInt v) (TisanInt v') = v == v'
  (==) (TisAString s) (TisAString s') = s==s'

where the red lines are indented (it means you have to leave two white
spaces at the beginning of those lines).

Ut

Il giorno mer 22 apr 2020 alle ore 21:14 Alexander Chen <
alexan...@chenjia.nl> ha scritto:

> hi,
>
> *data StringOrInt = TisanInt Int | TisAString String*
>
> *instance Eq (StringOrInt) where *
> *(==) (TisanInt v) (TisanInt v') = v == v'*
> *(==) (TisAString s) (TisAString s') = s == s'*
>
>
> *prelude>*
>
> *Instance_testen.hs:4:37: error:*
> *    Ambiguous occurrence ‘==’*
> *    It could refer to either ‘Prelude.==’,*
> *                             imported from ‘Prelude’ at
> Instance_testen.hs:1:1*
> *                             (and originally defined in ‘GHC.Classes’)*
> *                          or ‘Main.==’, defined at Instance_testen.hs:4:1*
> *  |*
> *4 | (==) (TisanInt v) (TisanInt v') = v == v'   |
>              ^^*
>
> *Instance_testen.hs:5:41: error:*
> *    Ambiguous occurrence ‘==’*
> *    It could refer to either ‘Prelude.==’,*
> *                             imported from ‘Prelude’ at
> Instance_testen.hs:1:1*
> *                             (and originally defined in ‘GHC.Classes’)*
> *                          or ‘Main.==’, defined at Instance_testen.hs:4:1*
> *  |*
> *5 | (==) (TisAString s) (TisAString s') = s == s' *
> *  |                                         ^^*
> *[1 of 1] Compiling Main             ( Instance_testen.hs, interpreted )*
> *Failed, no modules loaded.*
>
>
>
> *what gives?*
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200422/4c7a99b6/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 142, Issue 4
*****************************************

Reply via email to