r/haskell

Slow build on commodity VPS when developing on mac. What do you suggest?

So, i've built a project and i am new to Haskell environment coming from Ruby, Go, Python.

When i try to deploy Haskell project, it's gets stuck in pulling packages and compiling them. I suspect the problem is my development machine is way stronger than the commodity VPS i deploy on (limited cpu/memory), enough to run the binary but not enough to build on it.

in Go, i cross compile and upload a binary.

What are my possible options here?

reddit.com
u/CoachFreeAll — 11 hours ago
▲ 107 r/haskell

The industry's tolerance for "mostly right" code is driving me crazy

I swear every time i talk to dev friends who work strictly in python or ts, they rave about how much boilerplate they can generate now. but then they spend hours debugging weird edge case hallucinations because the model just statistically guessed teh next syntax token without any underlying logical grounding. it feels like the whole industry is just happily accepting a massive regression in software safety

working in haskell lately feels like a completely different universe. we actually care about mathematical soundness and types. the idea of just letting an autoregressive model brute-force a solution and hoping the test suite catches the fatal flaws is just wild to me

I did have a bit of a sudden realization today though that maybe the hype cycle is finally hitting a wall. I was reading up on how the newer ai reasoning benchmarks are starting to shift heavily towards formal verification and theorem proving environments. like, people are finally admitting that just throwing more compute at a standard transformer doesn't magically spawn deterministic logic

idk. it just makes me appreciate our ecosystem so much more. Pure functions and a ridiculously strict type checker are basically the only things keeping me sane when the rest of the tech world seems perfectly fine drowning in probabilistic slop

u/StrikingClos — 1 day ago
▲ 31 r/haskell

Servant-Effectful & general overview of effect systems

Tonight at 5pm EST we will be diving into effect systems starting with effectful via the Servant-effectful library and also if time permits, looking into building a quick demo of Bluefin.

The core focus of our sessions are how to interact with the haskell ecosystem as it is a truly unique language with respect to documentation, both by having little traditional documentation style but also by being a self documenting language and all that means for getting shit done with haskell as a real world language. We also really seek to cater to our audience so if you have questions about Servant or haskell in general, please consider the stream a help session.

Personally I am curious about Effect systems as a more intuitive way to drive home the core value of haskell to intermediate programmers, especially since they remove logical errors that can happen with monad transformers as the structure becomes more complex (eg how ExceptT e (StateT s m) a isnt the same as StateT s (ExceptT e m) a despite feeling like it should be the same behavior.

Link: https://m.twitch.tv/typifyprogramming/home

u/_lazyLambda — 1 day ago
▲ 14 r/haskell

Any paid course/certification for functional programming?

Company is sponsoring certification/training/course. Anything related to FP that I can do?

reddit.com
u/Worldly_Dish_48 — 2 days ago

[Hiring] [$15/hr] Haskell / Purescript Documentation Writer

I’m in need of a documentation writer well versed in Haskell and purescript. We’re running into issues regarding training because as you know there’s not that much material freely available for a standardized onboarded training.

The documentation written will include open source projects and our internal projects. The documentation made for open source projects will be made freely available on our public facing documentation website to help the Haskell and purescript community.

The main technologies we use are

Purescript,
Halogen,
Purescript-css

Haskell,
Servant,
Opaleye

Were also generating the cross concerning layers. So the domain layer is being autogenerated, and the purescript client to the backend is being autogenerated from servant.

reddit.com
u/joey_the_god_of_code — 2 days ago
▲ 11 r/haskell

Haddock pre-processor to insert type-checked examples

What already exists that compile-checks haddock examples?

While working on hyperbole, I realized I don't have enough discipline/attention to keep haddock examples correct as the package changes over time. (Discipline is the compiler's job!)

I wrote a custom pre-processor that replaces little `#EMBED` macros in the haddock with a top-level definition from a compiled module. It works like this:

{- | Run a 'Page' and return a 'Response'

@
#EMBED Example.Docs.BasicPage main

#EMBED Example.Docs.BasicPage page
@
-}

Goes to the module Example.Docs.BasicPage and finds `main` and `page`, ending up with this:

{- | Run a 'Page' and return a 'Response'

@
main :: IO ()
main = do
  run 3000 $ liveApp quickStartDocument (runPage hello)

page :: Page es '[]
page = do
  pure $ messageView "Hello World"
@
-}

-----------

It turns out to be a major pain to get a local pre-processor working without publishing it to hackage. I'm considering doing just that, but first I wanted to ask: what already exists to solve this problem?

I'm aware of doctest, but that only seems to check small `>>>` examples. I don't think it can accomplish what I'm asking for above.

u/embwbam — 2 days ago
▲ 17 r/haskell

[TIL] There isn’t a single posting of requirement for Haskell developer on any freelancing website

Continuing my previous post on r/haskell,
about how difficult it is finding work as a haskell developer, I know finding projects on GitHub, connecting with peers working on haskell is the right approach but anyway I started doing research, I had accounts on Upwork, freelancer.com, peopleperhour and fiverr. SoI thought, what are the chances? First I went to Upwork, I could find projects on data mining, analytics, ai chatbot development, ai integration, agentic workflows but not a single one requiring haskell. Every posting has skill requirements wich I would call mainstream requirements from python, javascript and xyz family of oops languages. freelancer did not even yield a single result when I tried keywords like haskell developer, smart contracts developments using haskell, mining, analytics using haskell etc.
Same happened with peopleperhour, All empty.
Heres something interesting I found on fiverr. Ten listings of guys offering teaching and code reviewing services with Haskell.

Hmm, so whats the future holds?
I am not sure, but I am thinking about the Haskell community.

reddit.com
u/Historical-Fan1619 — 3 days ago
▲ 16 r/haskell+1 crossposts

Starting an NES emulator in Haskell

Some final words on our EmuDevz JavaScript emulator, which is finally finished, and then on to the next challenge...writing an NES emulator in Haskell!

If you want to skip the introductory remarks about the JavaScript code and get straight to the Haskell, skip to around 3:45.

Thumbnail painting: "Napoleon Crossing the Alps", by Jaques Louis-David (1801).

youtube.com
u/peterb12 — 3 days ago
▲ 36 r/haskell+1 crossposts

hsrs -- PyO3-style bindings generator for Haskell

Hey everyone! I recently needed an ergonomic Haskell bindings generator for Rust code and realized one doesn't really exist, so I decided to build my own! hsrs is an ergonomic bindings generator which will take your Rust code, with hsrs annotations, and generate a Haskell bindings for you.

hsrs allows you to take this code

#[hsrs::module(safety = unsafe)]
mod quecto_vm {

/// CPU register identifiers.
#[derive(Debug, PartialEq, Eq)]
#[hsrs::enumeration]
pub enum Register {
  /// First general-purpose register.
  Reg0,
  /// Second general-purpose register.
  Reg1,
}

/// An error produced by the VM.
#[derive(Debug, PartialEq, Eq)]
#[hsrs::enumeration]
pub enum VmError {
  /// Division by zero.
  DivisionByZero,
}


/// A tiny VM with support for addition.
#[hsrs::data_type]
pub struct QuectoVm { registers: [i64; 2] }

impl QuectoVm {
  /// Create a new instance of the VM.
  #[hsrs::function]
  pub fn new() -> Self { ... }

  /// Adds register `b` into register `a` (a += b).
  #[hsrs::function]
  pub fn add(&mut self, a: Register, b: Register) { ... }

  /// Divides register `a` by register `b`, returning an error on division by zero.
  ///
  /// Demonstrates `Result<T, E>` → `Either E T` mapping across the FFI boundary.
  #[hsrs::function]
  pub fn safe_div(&mut self, a: Register, b: Register) -> Result<i64, VmError> { ... }
}

}

and generate

-- | CPU register identifiers.
newtype Register = Register Word8
  deriving newtype (Eq, Show, Storable)
  deriving (BorshSize, ToBorsh, FromBorsh) via Word8

pattern Reg0 = Register 0
pattern Reg1 = Register 1

-- | An error produced by the VM.
newtype VmError = VmError Word8
  deriving newtype (Eq, Show, Storable)
  deriving (BorshSize, ToBorsh, FromBorsh) via Word8

data QuectoVmRaw

-- | A tiny VM with support for addition.
newtype QuectoVm = QuectoVm (ForeignPtr QuectoVmRaw)

-- | Create a new instance of the VM.
new :: IO QuectoVm
new = do
  ptr <- c_quectoVmNew
  fp <- newForeignPtr c_quectoVmFree ptr
  pure (QuectoVm fp)

-- | Adds register `b` into register `a` (a += b).
add :: QuectoVm -> Register -> Register -> IO ()
add (QuectoVm fp) a b = withForeignPtr fp $ \ptr -> c_quectoVmAdd ptr (let (Register a') = a in a') (let (Register b') = b in b')

-- | Divides register `a` by register `b`, returning an error on division by zero.
--
-- Demonstrates `Result<T, E>` → `Either E T` mapping across the FFI boundary.
safeDiv :: QuectoVm -> Register -> Register -> IO (Either VmError Int64)
safeDiv (QuectoVm fp) a b = withForeignPtr fp $ \ptr ->
  fromBorshBuffer =<< c_quectoVmSafeDiv ptr (let (Register a') = a in a') (let (Register b') = b in b')

hsrs will generate both the Haskell side and the necessary C FFI bridges in Rust. The way I achieved rich type-semantics across both implementations is through borsh which serializes types in the Rust-side of things, and then deserializes it on the Haskell end.

For a full example, I'd recommend you look at the QuectoVM example in the hsrs repo.

Prior Art

hs-bindgen

A relatively popular project is hs-bindgen, https://github.com/yvan-sraka/hs-bindgen. My understanding for this crate is that only primitive C types are supported, which did not suit my ergonomics requirements. hsrs supports serializable value types, mapping between String and Text, Vec&lt;T&gt; <-> [T], Result&lt;T, E&gt; <-> Either E T, etc.

Purgatory

I stumbled upon Calling Purgatory from Heaven -- https://well-typed.com/blog/2023/03/purgatory/ -- after writing hsrs, which describes a similar approach to what hsrs employs. The system described in that article outlines two packages -- foreign-rust, https://github.com/BeFunctional/haskell-foreign-rust, and haskell-ffi, https://github.com/BeFunctional/haskell-rust-ffi. From now, I will refer to these two packages as Purgatory. Similar ideas and differences are:

  • Both hsrs and Purgatory use borsh as the underlying serialization scheme for sharing value types across the FFI boundary.
  • hsrs, unlike Purgatory, automatically does Haskell codegen for you from your Rust types. hsrs automatically emits extern functions and automatically generates binding files. We support automatic .hs codegen and have some nifty features:
    • Automatic value-type serialization/deserialization.
    • Automatic Haddock codegen from your Rust codegen.
    • Automatic Derive propagation -- things that you marked as Eq in Rust automatically get Eq in Haskell, etc.

Feedback is very welcome -- I want hsrs to solve for your needs as well as it does for mine. I commit to supporting this project for the next year, or so, to the best of my abilities.


Note: This has been cross-posted on discourse.haskell.org

u/siva_sokolica — 3 days ago
▲ 17 r/haskell

Haskell Interlude #82: Fraser Tweedale

In the new Haskell Interlude, we talked to Fraser Tweedale. Fraser works at Red Hat, and is on the Haskell Security Response Team. We talked about security in the context of Haskell, both technical and organizational issues, and also the political issues involved. Fraser’s work is both really important and not well-known in the Haskell ecosystem, so it was high time for him to come on the show.

haskell.foundation
u/sperbsen — 3 days ago
▲ 11 r/haskell

wrote a small servant app that searches youtube video transcripts and i'm weirdly pleased with how the types turned out

i work at a legal tech company and we have about 190 youtube videos. recorded CLE presentations, product walkthroughs for attorneys, internal engineering talks, some webinar recordings from conferences. the attorneys kept asking "do we have a video that explains X" and nobody had a fast way to answer because the videos are titled things like "Webinar Recording - Nov 2024."

i built a search tool for it in haskell over a weekend. mostly because i wanted a real project to work on outside of the toy stuff i've been doing while learning.

the api is defined with servant. two endpoints. one serves the static html page, the other takes a query parameter and returns search results as json. the result type is a record with the video title, date, speaker, transcript snippet, and youtube url. servant gives me the type-safe routing and the aeson instances get derived generically for the response type. the whole api definition and server are maybe 60 lines.

the database layer uses postgresql-simple. i wrote a search function that takes a connection and a query string and returns [SearchResult]. the query uses postgres full text search with tsvector on the transcript column and ts_headline for the snippet. the raw sql is in a quasiquoted string which isn't beautiful but it works and the function signature keeps everything honest. the db module is about 40 lines.

for pulling the transcripts i wrote a separate ingestion binary. it reads urls from a file, calls transcript api for each one:

npx skills add ZeroPointRepo/youtube-skills --skill youtube-full

the ingestion tool uses http-conduit for the api calls and aeson to parse the json response. each transcript gets inserted into postgres with the metadata. about 50 lines for the ingestion tool.

the part i enjoyed was defining the SearchResult type and having everything downstream just work. the aeson ToJSON instance is derived, servant uses it to serialize the response, and the postgresql-simple FromRow instance maps the query results. once the types compiled i didn't have a single runtime error related to data shape. the only bugs were in the sql query itself which is the one place haskell can't help you.

deployed it with a nix flake that builds the executable. copied it to our internal server, set up a systemd service, done. about 190 videos indexed. the legal team uses it to find CLE recordings by topic. one attorney searched for "fiduciary duty" and found 6 videos she didn't know existed. the engineering team uses it before architecture discussions to check if someone already presented on the approach.

the codebase is three modules and a Main. maybe 200 lines of haskell total. not counting the cabal file which is honestly longer than some of the modules.

reddit.com
u/scheemunai_ — 4 days ago

Defining filter using (a) recursion (b) folding (c) folding with S, B and I combinators (d) folding with applicative functor and identity function

linkedin.com
u/philip_schwarz — 3 days ago
▲ 36 r/haskell+1 crossposts

Do you write Haskell?

I feel like it's very difficult to find any jobs where people write Haskell,

If you are one of the lucky ones who get paid to write Haskell, which domain do you use Haskell for? Is it data science, ml, academia or anything else? Did your company move from using any mainstream language to starting using Haskell? Is your company a brand new startup (e.g., database / distributed systems, Ai) where you didn’t consider Haskell initially but now feel more comfortable! What was your the initial choice?

I want to hear stories about how people ended up writing Haskell for a living (and not just as a weekend hobby).

reddit.com
u/Historical-Fan1619 — 5 days ago
▲ 46 r/haskell

I benchmarked Cartesian product implementations in Haskell, then compared them with C

I wrote a small article around implementing Cartesian products, starting from Haskell’s sequence.

The article goes through a naive Haskell implementation, a more idiomatic list-comprehension version, native sequence, then versions using Data.Vector.Unboxed, mutable vectors, runST, unsafeFreeze to try a different memory representation.

The second half compares those designs with C implementations, mostly to look at what changes when the memory layout and allocation model are made explicit.

The most interesting result for me was that changing representation in Haskell reduced allocations a lot without automatically improving runtime. In some cases, fusion helped a bit (no temporary indices).

I’d be happy to get feedback on the Haskell side, especially the vector/ST implementations and whether there are more idiomatic or faster ways to express this.

Here is the article link:

https://julienlargetpiet.tech/articles/the-cartesian-product-disaster-tour-haskell-c-and-25gb-of-allocations.html

If you want to share any optimizations, you can do a PR at this repo:

https://github.com/julienlargetpiet/PerfLabs

It will be mentioned in the next article update.

PS: We now managed to find (currently) best version which is this one (in C) running at 160ms for 100k iterations to 5^5 lists here:

https://github.com/julienlargetpiet/PerfLabs/blob/main/CartesianProduct/contrib2/contrib2.c

I'm updating after trying some new Haskell impl, thanks everyone for the help and the intuition on where to dig !

reddit.com
u/Medical-Common1034 — 6 days ago
▲ 50 r/haskell

[ANN] linear-locks: locking primitives free of deadlocks

linear-locks provides locking primitives that are statically guaranteed not to lead to deadlocks.

It achieves this by breaking one of the Coffman conditions for deadlocks: the "circular wait" condition. linear-locks ensures locks are always acquired in a consistent order.

tl;dr: Each lock is assigned a "level", tracked at the type level. When you enter a "lock scope", you're given a key that can acquire locks of level 0 or above. When you acquire a lock of level n, the key is consumed and you're given a new key of level n+1, capable of acquiring locks of level n+1 or above. This ensures locks are always acquired in order of increasing level, preventing circular waits.

The package ports the ideas of the Surelock Rust crate to Linear Haskel. As such, it relies heavily on LinearTypes and is meant to be used with linear-base. Keys are linearly typed to ensure they cannot be reused and do not escape the "lock scope". "Guards" (which represent ownership over acquired locks) are also linearly typed to ensure they are (1) always released and (2) cannot be used after being released.

reddit.com
u/dfacastro — 7 days ago
▲ 44 r/haskell

[ANN] hpgsql, a pure Haskell PostgreSQL driver (no libpq)

It’s a pleasure to announce hpgsql, a PostgreSQL driver written in pure Haskell (no libpq), with an API largely inspired by the great postgresql-simple library, but featuring:

  • Usage of PostgreSQL’s binary protocol
  • Query arguments passed via the protocol instead of being escaped into the query string
  • Pipelining
  • Prepared statements
  • Ability to stream query results directly from the socket (not just with cursors)
  • Interruption safety, except for very specific (and documented) edge cases
  • Thread safety, unless specific (and documented) instructions say otherwise
  • A SQL quasiquoter like the one in postgresql-query and hasql-interpolate

Here’s an example of a pipeline mixing streams, prepared and non prepared statements:

f :: Int -&gt; IO (Stream (Of Aeson.Value) IO ())
f val = do
  (updateTbl :: IO (), aggRes :: IO (Only Int), largeResults) &lt;-
    runPipeline conn $
      (,,)
        &lt;$&gt; pipelineExec_ [sql|UPDATE tbl SET val=#{val}|]
        &lt;*&gt; pipeline1 [sql|SELECT SUM(val) FROM tbl|]
        &lt;*&gt; pipelineSWith
          (rowDecoder @(Vector Int, Vector Text))
          -- We use a prepared statement for the query below
          [sqlPrep|SELECT x, y FROM tbl|]
  updateTbl
  Only total &lt;- aggRes
  Streaming.map Aeson.toJSON &lt;$&gt; largeResults

Also, I am maintaining hpgsql-simple-compat, a fork of postgresql-simple that preserves its API as much as I could make it, but with internals rewritten to use hpgsql. The idea is to provide a simpler migration path from postgresql-simple; one that allows a smaller initial changeset and then the possibility of migrating queries to hpgsql one at a time. I have even migrated a CLI tool of mine, codd, as an example.

hpgsql-simple-compat is not in Hackage as I wasn’t sure duplicating the search space with modules, types, and functions already in postgresql-simple would annoy users. It’s in the “hpgsql-simple-compat” folder in the repository.

Some initial benchmarks show hpgsql can materialize rows from a query in ~38% the time postgresql-simple takes, and ~70% the time hasql takes (on my computer, Linux x64, GHC 9.10.3, compiled with -O1). Peak memory usage is trickier to analyze, and I therefore welcome people that know more to read the benchmarks page and help me better understand them. Also, please scrutinize these benchmarks as much as you can.

I want to encourage and welcome contributions, bug reports, questions, suggestions. Nothing’s off the table: what would you want or what do you need from such a library?

I really want to hear from the community, both those eager to switch and potential future users.

reddit.com
u/mzabani — 8 days ago
▲ 44 r/haskell

[JOB] Artificial Labs Q2 hiring

My last post was only 3 months ago, but here we go again, hiring ~6 Haskellers.

Roles

Product Engineering:

If you're not sure which role to apply for, just pick one, and we’ll move you to the appropriate role.

About us

Artificial is a leading UK-based Insurtech company. Our technology enables some of the world’s largest insurers to write and trade complex risks faster, more efficiently, and at lower cost. We have built a cool DSL to rapidly and robustly model insurance contracts, and a platform around it that enables the capture, assessment, and trading of risks in a highly automated fashion.

We've recently raised $45M in Series B funding.

Our engineering team is fully remote, with some people close to our London office in the City working from there on occasion. The choice is yours.

Info

We are able to hire people with the right to work in specific countries, see below:

  • via company branches: UK, Poland
  • via Deel: Estonia, Spain, Portugal, Greece, Hungary
  • other EU countries on a case-by-case basis

Compensation is benchmarked against London fintech scale-up rates.

We’re principally looking for generalists, rather than specialists. You don’t shy away from anything. Artificial is a fast-paced, scale-up environment with half a dozen separate Haskell teams.

Previously

https://www.reddit.com/r/haskell/comments/1quyzxr/job_various_roles_at_artificial/ https://www.reddit.com/r/haskell/comments/1ledlqg/job_4x_haskell_engineer_at_artificial/ https://www.reddit.com/r/haskell/comments/1kcdwc4/job_site_reliability_engineer_at_artificial/ https://www.reddit.com/r/haskell/comments/1ij8oub/job_solutions_engineering_at_artificial/ https://www.reddit.com/r/haskell/comments/17u7ixo/job_engineer_at_artificial/ https://www.reddit.com/r/haskell/comments/108drpm/job_engineer_at_artificial/ https://www.reddit.com/r/haskell/comments/rxfqtc/job_haskell_engineer_at_artificial/ https://www.reddit.com/r/haskell/comments/cn6toi/job_opening_senior_haskell_engineer_at_artificial/

u/pwmosquito — 8 days ago

My Newbie Error "Could not deduce ‘RealFrac a’ arising from a use of ‘floor’ from the context: Num a"

Hi, I'm learning Haskell, and I admit I'm just playing with it right now.

While I'm not a terribly experienced programmer, I do have a Bachelor's in Computer Science. My professional experience has been restricted to mostly web development in Typescript sadly.

I have not touched functional programming, but this seems unrelated to functional intricacies and more me having a primitive understanding of number types.

I'm playing with pattern matching and guards so maybe excuse the silly code, I'm just starting.
I try loading (":l haskell_test.hs") my file in GHCi and get the following compile error

"Could not deduce ‘RealFrac a’ arising from a use of ‘floor’ from the context: Num a" . I take in type Num, and floor doesn't like that general of a type, I take it?

-- testing pattern matching and guards
isXFactorOfY :: Num a =&gt; a -&gt; a -&gt; Bool
isXFactorOfY 0 0 = True
isXFactorOfY 0 y = False
isXFactorOfY x 0 = False
isXFactorOfY 1 1 = True
isXFactorOfY 1 y = False
isXFactorOfY x 1 = False
isXFactorOfY x y  | x &gt; y = False
                  | abs(x / y) &gt; floor( abs(x)/abs(y) ) = False
                  | otherwise = True

I've tried replacing Num a with Real a, RealFrac a, and some other things I've seen. But I'm just poking blindly and don't actually understand the exact issue. I'd like some help understanding it explicitly rather than stumbling upon the compile-able code.

I see the reference for floor is here: https://hackage.haskell.org/package/ClassyPrelude-0.1/docs/Prelude-Math.html#v:floor

I guess I'm confused what it want's floor to take in, I figured any number that's an Int or Float would work. But I'm not sure how to define that the way it wants.

Again sorry for the silly code. I am quite rusty and am having a rough time getting back into .... problem solving, and reading APIs and references it seems.
Thank you in advance for any help or direction you give.

The full compile error output is as follows:

ghci&gt; :l haskell_test.hs 
[1 of 2] Compiling Main             ( haskell_test.hs, interpreted )
haskell_test.hs:3:14: error: [GHC-39999]
    • Could not deduce ‘Eq a’ arising from the literal ‘0’
      from the context: Num a
        bound by the type signature for:
                   isXFactorOfY :: forall a. Num a =&gt; a -&gt; a -&gt; Bool
        at haskell_test.hs:2:1-39
      Possible fix:
        add (Eq a) to the context of
          the type signature for:
            isXFactorOfY :: forall a. Num a =&gt; a -&gt; a -&gt; Bool
    • In the pattern: 0
      In an equation for ‘isXFactorOfY’: isXFactorOfY 0 0 = True
  |
3 | isXFactorOfY 0 0 = True
  |              ^

haskell_test.hs:9:29: error: [GHC-39999]
    • Could not deduce ‘Ord a’ arising from a use of ‘&gt;’
      from the context: Num a
        bound by the type signature for:
                   isXFactorOfY :: forall a. Num a =&gt; a -&gt; a -&gt; Bool
        at haskell_test.hs:2:1-39
      Possible fix:
        add (Ord a) to the context of
          the type signature for:
            isXFactorOfY :: forall a. Num a =&gt; a -&gt; a -&gt; Bool
    • In the expression: x &gt; y
      In a stmt of a pattern guard for
                     an equation for ‘isXFactorOfY’:
        x &gt; y
      In an equation for ‘isXFactorOfY’:
          isXFactorOfY x y
            | x &gt; y = False
            | abs (x / y) &gt; floor (abs (x) / abs (y)) = False
            | otherwise = True
  |
9 | isXFactorOfY x y        | x &gt; y = False
  |                             ^

haskell_test.hs:10:33: error: [GHC-39999]
    • Could not deduce ‘Fractional a’ arising from a use of ‘/’
      from the context: Num a
        bound by the type signature for:
                   isXFactorOfY :: forall a. Num a =&gt; a -&gt; a -&gt; Bool
        at haskell_test.hs:2:1-39
      Possible fix:
        add (Fractional a) to the context of
          the type signature for:
            isXFactorOfY :: forall a. Num a =&gt; a -&gt; a -&gt; Bool
    • In the first argument of ‘abs’, namely ‘(x / y)’
      In the first argument of ‘(&gt;)’, namely ‘abs (x / y)’
      In the expression: abs (x / y) &gt; floor (abs (x) / abs (y))
   |
10 |                         | abs(x / y) &gt; floor( abs(x)/abs(y) ) = False
   |                                 ^

haskell_test.hs:10:40: error: [GHC-39999]
    • Could not deduce ‘RealFrac a’ arising from a use of ‘floor’
      from the context: Num a
        bound by the type signature for:
                   isXFactorOfY :: forall a. Num a =&gt; a -&gt; a -&gt; Bool
        at haskell_test.hs:2:1-39
      Possible fix:
        add (RealFrac a) to the context of
          the type signature for:
            isXFactorOfY :: forall a. Num a =&gt; a -&gt; a -&gt; Bool
    • In the second argument of ‘(&gt;)’, namely
        ‘floor (abs (x) / abs (y))’
      In the expression: abs (x / y) &gt; floor (abs (x) / abs (y))
      In a stmt of a pattern guard for
                     an equation for ‘isXFactorOfY’:
        abs (x / y) &gt; floor (abs (x) / abs (y))
   |
10 |                         | abs(x / y) &gt; floor( abs(x)/abs(y) ) = False
   |                                        ^^^^^

Failed, unloaded all modules.
reddit.com
u/SleepyGuyy — 9 days ago