evincarofautumn / kitten

A statically typed concatenative systems programming language.
http://kittenlang.org/
Other
1.08k stars 39 forks source link

"No instance for (Semigroup (Fragment a))" in Fragment.hs:33 #206

Open i336 opened 6 years ago

i336 commented 6 years ago

Hi! I'm trying to compile Kitten so I can play with it.

I've never used Haskell before so I have no idea what's going on or how to proceed. I wouldn't be surprised if my GHC setup is broken.

$ git pull
Already up to date.

$ make
cabal sandbox init
Writing a default package environment file to
/data/kitten/cabal.sandbox.config
Using an existing sandbox located at /data/kitten/.cabal-sandbox
cabal install --enable-tests --only-dependencies
Resolving dependencies...
All the requested packages are already installed:
Use --reinstall if you want to reinstall anyway.
cabal configure --enable-tests
Resolving dependencies...
Configuring Kitten-0.1.0.0...
cabal build
Preprocessing library for Kitten-0.1.0.0..
Building library for Kitten-0.1.0.0..
[61 of 65] Compiling Kitten.Fragment  ( lib/Kitten/Fragment.hs, dist/build/Kitten/Fragment.o )

lib/Kitten/Fragment.hs:33:10: error:
    ⢠No instance for (Semigroup (Fragment a))
        arising from the superclasses of an instance declaration
    ⢠In the instance declaration for â
   |
33 | instance Monoid (Fragment a) where
   |          ^^^^^^^^^^^^^^^^^^^
make: *** [Makefile:86: dist/build/kitten/kitten] Error 1

I'm on Arch, for better or worse. Happy to shout at the package manager to try and figure out what to install.

btw: I'm sshing to my Arch box from a Slackware machine which has broken Unicode, which is the reason for the "â¢"s. GHC doesn't seem to respect LC_ALL=C!

sullyj3 commented 6 years ago

Yep, you'll need an earlier GHC, from before the Semigroup Monoid Proposal. (https://prime.haskell.org/wiki/Libraries/Proposals/SemigroupMonoid) Longer term, probably (Fragment a) should get a Semigroup instance (the implementation is trivial).

evincarofautumn commented 6 years ago

This is an issue I should fix anyway, so thanks for the report. :) If you’re not familiar with Haskell build tooling, the most straightforward way to build is probably using Stack, which will install an appropriate GHC and the correct package versions for you in a sandbox—instructions are in the README. Honestly, I should probably just remove the Makefile since I haven’t been maintaining it.

i336 commented 6 years ago

...I feel very stupid for not scrolling down and noticing the readme information. Woops.

But now it works! Now I just have to figure out what on earth to do with this thing. :P

Thanks very much, installing Stack was a simple pacman -S stack.

sullyj3 commented 6 years ago

Can ghc not derive those instances?

evincarofautumn commented 6 years ago

@sullyj3 I don’t think so, but there are libraries for it like generic-deriving. I think that instance might actually go away in the next round of changes anyway—not sure it’ll be needed.

However, as long as there’s not too much of it, I often end up manually writing code like that instead of finding a way to cleverly avoid it, even though it’s purely mechanical. It only needs to be done once, and being explicit makes the code (in theory) easier to port over to Kitten if/when I want to bootstrap.

sullyj3 commented 6 years ago

Oh yeah, I guess writing a deriving system for kitten would be super nontrivial.

evincarofautumn commented 6 years ago

@sullyj3 Yeah, not necessarily hard, just Yet Another Thing to do. Incidentally, I’m leaning toward doing deriving with macros (#141) when I get around to it, so at least those things can be written in Kitten instead of Haskell.

evincarofautumn commented 6 years ago

@i336 Glad you got it going! :) Feel free to come hang out on the Kitten Gitter channel if you have any questions or feedback. I’m happy to help you try things out—and explain and apologise for all the stuff that’s broken while I continue to take forever to fix it, hah