Skip to content

Partial port of Haskell Euterpea library to Gleam

License

Apache-2.0, Zlib licenses found

Licenses found

Apache-2.0
LICENSE
Zlib
Euterpea2_License
Notifications You must be signed in to change notification settings

karlsson/gleuterpea

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gleuterpea

What this is

In an attempt to learn Gleam I have tried to translate a subset of the Haskell Euterpea library that accompanies the book "The Haskell School of Music" by Paul Hudak and Donya Quick

Development

gleam run   # Run the main function in the gleuterpea module and create MIDI files.

Observations

I have left some parts of the Haskell original code as a comparison in the comments.

In general the transposing "distance" between Haskell and Gleam is not too far.

Gleam does not support polymorphism as Haskell do with class and instance, which was used when converting the Music type to Music1 type in m_event.gleam. This was (partly) fixed by going back and refine the Music type itself to be more generic, which is a bit interesting as it gives a hint that, if you define/refine your types carefully, you may not need all the "bells and whistles" provided in other languages.

The BitArray and the bit syntax provided by Erlang is really a bonus when encoding to Midi format. Here one can see how the Haskell implementation has to struggle converting between bytes and bits in the export_file.gleam module.

The "pipes" in Gleam can to some extent replace the function composition (".") and infix operations in Haskell, one may have to change the parameter order in the function calls though.

Todos

Refine the Music or Pitch type more to support extra parameters.
Make the Rational type to use the frac library instead of just aliasing Float.
Learn how to use "use" in Gleam.

References

  • [1] Euterpea2 - Haskell library for Euterpea. License
  • [2] HSoM - Examples to accompany the Haskell School of Music textbook. License
  • [3] Codec.Midi - Haskell library for Midi encoding.

About

Partial port of Haskell Euterpea library to Gleam

Resources

License

Apache-2.0, Zlib licenses found

Licenses found

Apache-2.0
LICENSE
Zlib
Euterpea2_License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages