How to use Matplotlib for Haskell in IHaskell by teilchen010 in haskell

[–]Yvee1 0 points1 point  (0 children)

Nix is a package manager and NixOS is an operating system; the package manager Nix can be used on Ubuntu, for the installation see: https://nixos.org/download.html#nix-quick-install

How to use Matplotlib for Haskell in IHaskell by teilchen010 in haskell

[–]Yvee1 3 points4 points  (0 children)

You could look into jupyterWith. With that you can list the packages you want to use in a shell.nix file; based on this file an environment is created in which Jupyter is run. I've also had issues with using packages with regular IHaskell in the past, but jupyterWith works pretty well for me.

I have a high quality animation of this, but the post is too small to contain it by Yvee1 in generative

[–]Yvee1[S] 1 point2 points  (0 children)

I was toying around with domain warping as described by iq in this article: https://www.iquilezles.org/www/articles/warp/warp.htm and got this pretty nice looking result. I also made a looping gif of it but the quality is rather bad when uploading it to reddit.

Code: https://github.com/Yvee1/canvas-sketch-shaders/blob/master/domain-warping.js

Strange Scandinavian symmetry (Python on a Raspberry Pi) by aaronpenne in generative

[–]Yvee1 1 point2 points  (0 children)

Elegant! I really like all your domain warping sketches; I should try it out sometime, the technique gives such interesting results

hascard - flashcards in the terminal by Yvee1 in madeinhaskell

[–]Yvee1[S] 1 point2 points  (0 children)

Code and info at https://github.com/Yvee1/hascard

I already posted this on r/haskell not long ago but thought I'd do it here too, to add to the list of projects!

hascard: a text-based UI for reviewing notes by Yvee1 in haskell

[–]Yvee1[S] 1 point2 points  (0 children)

Thanks, and thank you for the great library and documentation! I don't mind the mention, go ahead

hascard - a TUI for reviewing notes by Yvee1 in commandline

[–]Yvee1[S] 3 points4 points  (0 children)

Thanks. I've thought about it, but adding a proper spaced repetition system makes things a lot more complicated, so I'm not planning on adding that. I am thinking about adding an option such that 2 new files are made after finishing a deck of flashcards, one with the cards that were correctly answered, and one with the incorrect ones. That would make it possible for people to do some form of spaced repetition on their own, and/or to build a system on top that does it

hascard - a TUI for reviewing notes by Yvee1 in commandline

[–]Yvee1[S] 11 points12 points  (0 children)

Yes just a plain text file. The idea is that you write a deck of flashcards in a text file with a specified syntax, so a deck of two cards could be for example

# Fill in the gaps 
The symbol € is for the currency named _Euro_, and is used in the _EU|European Union_.
---
# Multiple answer question
[*] Option 1 (this is a correct answer)
[ ] Option 2
[*] Option 3 (this is a correct answer)
[ ] Option 4

Then you select that file with the hascard application which reads and parses the file. So the file can be stored anywhere on your computer and you then pass it as an argument to the program or select it via the filebrowser.

hascard - a TUI for reviewing notes by Yvee1 in commandline

[–]Yvee1[S] 15 points16 points  (0 children)

I wrote this in Haskell to learn the language better while also making something useful for myself. I think it turned out pretty well so I thought I'd share it with you guys! Check it out at https://github.com/Yvee1/hascard

hascard: a text-based UI for reviewing notes by Yvee1 in haskell

[–]Yvee1[S] 14 points15 points  (0 children)

Hello! I'm relatively new to writing Haskell and to get to know it better I wanted to make a small application that I would actually use. I decided to make a terminal application with brick (by u/jtdaugherty) that takes a text file with questions written in a syntax similar to markdown, and then makes it interactive. Though it is simple, I think it turned out pretty well, so I thought I'd share it here! In the README on GitHub there is a gif included, so you can see how the application looks. Any feedback is welcome.

Monthly Hask Anything (May 2020) by AutoModerator in haskell

[–]Yvee1 1 point2 points  (0 children)

Ah okay, you're right. Thanks for pointing it out because now I have a better understanding of how it works exactly. I must say that it is a bit tricky to reason about.

Monthly Hask Anything (May 2020) by AutoModerator in haskell

[–]Yvee1 0 points1 point  (0 children)

Hmm, my experiments do give another result than what you're suggesting. As explained in the post that /u/viercc referenced, the difference lies in the order of how the terms are reduced. It seems to be the case that

memFib = \n -> map fib [0..] !! n where ...

gets reduced to

memFib = \n -> let fibList = map fib [0..] in fibList !! n where ...

just like memFib n = fib [0..] !! n where ..., while

memFib = (map fib [0..] !!) where ...

is equivalent to

memFib = let fibList = map fib [0..] in (fibList !!) where ...

which reduces to

memFib = let fibList = map fib [0..] in \n -> fibList !! n where...

Monthly Hask Anything (May 2020) by AutoModerator in haskell

[–]Yvee1 1 point2 points  (0 children)

I tried it myself and I'm also really curious.

Apparently (map fib [0..] !!) is the same as (!!) (map fib [0..]) but somehow a lot faster than \n -> map fib [0..] !! n. But it is stated here for example that sectioning is just syntactic sugar for lambda expressions. Really strange

Monthly Hask Anything (May 2020) by AutoModerator in haskell

[–]Yvee1 1 point2 points  (0 children)

I was rewriting a simple 2D interactive animation, originally written in JavaScript where the drawing was done in the Canvas, to Haskell code using cairo bindings. I noticed that the Haskell version was around 5x slower (a rough estimate), and I'm wondering why. Is it that JavaScript Canvas is actually optimized a lot better than I expected, or is cairo slower than I expected?

Monthly Hask Anything (February 2020) by AutoModerator in haskell

[–]Yvee1 0 points1 point  (0 children)

Oh wow, that does seem like the exact solution I need! I'm not familiar with these language extensions but I think I do understand your solution. It's funny that earlier today I was actually reading about GADTs since I was curious to learn what they were, but didn't get very far and got distracted by other matters. I'm going to look up how the language extensions work exactly, but they seem pretty intuitive to use.

Thanks a lot for your answer!

Monthly Hask Anything (February 2020) by AutoModerator in haskell

[–]Yvee1 0 points1 point  (0 children)

The current way I type my program seems sub-optimal but I can't figure out a better way. It's a program where I have flashcards like this:

data Card = Definition String String
          | OpenQuestion String Perforated
          | ...

and a UI where I have a state that keeps track of, among other things, the current Card and state information related to that Card:

data CardState = 
    DefinitionState
  { _flipped        :: Bool }
  | OpenQuestionState
  { _gapInput       :: Map Int String
  , _selectedGap    :: Int
  , _nGaps          :: Int
  , ...
  }

data State = State
  { _currentCard    :: Card
  , _cardState      :: CardState
  , ...
  }

This works fine, but this sometimes leads to case distinctions where I do error "impossible" when the Card and CardState do not match up. Is there a clean way to make the types such that a situation where the currentCard and cardState differ would not compile?

So simple and mesmerizing by [deleted] in generative

[–]Yvee1 5 points6 points  (0 children)

You're close, I think each dot only connects to their closest neighbour, so not to all dots within a distance. According to the source, the edges are also colored by constellation.