awakesecurity / gRPC-haskell

Haskell gRPC support
https://hackage.haskell.org/package/grpc-haskell
Apache License 2.0
236 stars 74 forks source link

Usage (No Constructor imported) #162

Closed MohsenNz closed 4 months ago

MohsenNz commented 4 months ago

Hello there. I configured my project for using grpc-haskell (in cabal, not nix). But after I tried to use example arithmetic (I copied the files and directory to my own project) I encountered these errors: Screenshot from 2024-03-15 02-44-14 It say it needed type constructor Arithmetic. After I import that, I encountered: Screenshot from 2024-03-15 02-44-56 It says Arithmetic constructor is not exported. Then I checked the generated file Arithmetic.hs: Screenshot from 2024-03-15 02-45-18 Here there is no data exported. I'm wondering how to use it ?

MohsenNz commented 4 months ago

OK, it was my mistake. I wasn't in my development shell (nix develop, some dependencies like grpc-c were defined here). After entering that the problem solved. Anyway, I still had a question how Arithmetic constructor and other stuff are importable will they are not exported in Arithmetic.hs ? (I'm newbie in Haskell and will thankful for putting up with me)

ixmatus commented 4 months ago

@MohsenNz if there are no explicit exports from a module, then everything is exported, which is the case with module Arithmetic where. The haskell.org website has what looks like a good tutorial on modules: https://www.haskell.org/tutorial/modules.html and I recommend reading that.

If you are new to Haskell, I recommend starting your learning journey with something simpler that has better tutorial materials for beginners like Servant for web applications.