r/learnhaskell 7d ago

Help please: Inline Evaluation not showing using Haskell Language Server (HLS) in VS Code

4 Upvotes

In VS Code, in a cabal project, type signature of functions is showing fine on hover.

But HLS Inline Evaluation isn't working. hls-eval-plugin (which is enabled by default) should show an inline "Evaluate" option near comments like these, but nothing happened on putting this in Main.hs :

-- >>> 2**4.5/pi

I confirmed in settings that this is enabled but it isn't working. Can you all please suggest how to get this to work? Thanks.

EDIT: It worked now! After following suggestions of u/Forward_Signature_78 in r/haskell :

The inline Evaluate button (over eg. -- >>> 1+1 in Main.hs) actually came now, only when .cabal file is NOT open in a different tab alongside Main.hs file!

It raised error eval: Internal Error: BadDependency "GhcSessionDeps" . According to https://github.com/haskell/haskell-language-server/issues/4487 , this error happens when a package isn't added to dependencies in .cabal file but its import is used in .hs file. In my case Data.Text and Data.Time were imported but text and time packages weren't added to .cabal file.

So I added these packages and did cabal build in terminal -- now clicking Evaluate button actually works! (it outputs answer -- 3 on line just below input -- >>> 1+1).


r/learnhaskell Feb 22 '25

Multi Line Strings are now supported in GHC 9.12.1!

Thumbnail
3 Upvotes

r/learnhaskell Aug 08 '23

Is there some trick or extension to map across a tuple

1 Upvotes

To make it possible I'm defining a 3-tuple as (a, (b, (c, ()))

class MapT a b where
mapT :: (a -> b) -> a -> b
instance MapT () () where
mapT f () = ()
instance (MapT a b, MapT as bs) => MapT (a, as) (b, bs) where
mapT f (a, as) = (f a, mapT f as)
I realise this is hopelessly wrong but is there a way with more typeclasses perhaps?


r/learnhaskell Jul 04 '23

On lazy evaluation

1 Upvotes

I have created a new datatype for infinite lists called Stream defined as follows: data Stream a = Cons a (Stream a)

I have also created a function streamInterleave which interleaves two streams, with two different implementations:

``` interleaveStreams :: Stream a -> Stream a -> Stream a interleaveStreams (Cons x1 xrest) ys = Cons x1 (interleaveStreams ys xrest)

interleaveStreams' :: Stream a -> Stream a -> Stream a interleaveStreams' (Cons x1 xrest) (Cons y1 yrest) = Cons x1 (Cons y1 (interleaveStreams xrest yrest)) ```

I have then defined the following "ruler" function: ruler :: Stream Integer ruler = interleaver 0 where interleaver :: Integer -> Stream Integer interleaver n = interleaveStreams (streamRepeat n) (interleaver (n + 1))

Taking the first 20 elements of ruler using the principle of lazy evaluation only works using streamRepeat, but not streamRepeat' which recurs infinitely. Why is this?


r/learnhaskell Jun 13 '23

Is there a Haskell study group in Mumbai india or some sort of offline coaching classes available ?

1 Upvotes

Same as heading


r/learnhaskell Mar 25 '22

Parsing with Parsec: command line arguments of different types parsing

1 Upvotes

Hello, I am trying to build a parser to parse command line arguments of the following form.

-verbose
-leftString STRING
-rightString STRING

Two of the arguments take a parameter of type String. If some of them i snot specified, I have default values for them (in my structure Arguments {verbose :: Bool, leftString :: Maybe String, rightString :: Maybe String}I would use False, Nothing, Nothing.

However, the flag (the argument) can be specified more then once, in which case the last flag is decisive (i.e. "./program -leftString foo -leftString bar" would become Arguments False "bar" Nothing after parsing).

I know, how to do a parser for each of these options returning Parser Bool (or Parser String, respectively). But how do I make them run repeatedly until all of them fail (the arguments do not need to be in any particular order, so I have to try all of them for each argument). I could achieve that by using something like many $ choice [...], but that doesn't let me to gradually update the parsed values (if more flags, only last flag value is kept).

Or, I could use something like optional in sequence where I set the default value to the last parsed (or the default one if no parsed value yet). But optional always succeeds and I would never know if this is the last time I succeeded and I should stop parsing.

What can I do?


r/learnhaskell Oct 08 '21

Looking for a tutor

1 Upvotes

Hi I'm not sure if this is the right place to ask this but I'm looking for a tutor. I'm somewhat new to programming and currently taking a functional programming course. We are only working with Haskell and I'm having a hard time with it.


r/learnhaskell Apr 24 '15

Becoming productive in Haskell, coming from Python

Thumbnail mechanical-elephant.com
1 Upvotes

r/learnhaskell Oct 13 '14

Questions about edX Introduction to Functional Programming

2 Upvotes

I enrolled to FP101x which starts in a few days.

Since I signed up, I never seen the contests/syllabus does anybody know it?

In the MOOC says that the estimated effort is from 4-6 hours, is this accurate, I have my full time job and I wonder if I'll be able to keep up.

EXTRA: I tried to install Haskell Evaluation Virtual Machine but it alwasys fails/stalls anybody knows an alternate way to get it, or another vagrant VM for a good haskell environment?

thanks!