non-exhaustive-patterns Questions

2

Solved

I've started learning Scala. I was surprised that next code compiles: object Hello extends App { def isOne(num: Int) = num match { case 1 => "hello" } } You can't do something simi...

2

Solved

Scala can warn when pattern match on a sealed type is not exhaustive, however can we check that a function returns all cases when the return type is sealed? For example, consider the following ADT ...

2

Solved

How do I persuade the Rust compiler that the internal match expression is fine here, as the outer match has already restricted the possible types? enum Op { LoadX, LoadY, Add, } fn test(o: Op)...
Kroeger asked 8/5, 2019 at 21:17

2

Solved

I am training for a test tomorrow to complete my introduction to functional programming but there is one thing I don't understand. Whenever I have a program like: test [] = [] test (x:xs) = test ...
Ked asked 26/9, 2014 at 7:16

3

Solved

So I'm trying to triplize an element, i.e. making 2 other copies of the element. So I've written this: triplize :: [a] -> [a] triplize [x] = concatMap (replicate 3) [x] But I've been getting...
Grotto asked 11/9, 2015 at 21:52

1

Solved

I have no idea why my function doesn't work. I have gone through all the posts about non-exhaustive functions but my functions fulfills all possible options as far as I can see. ascending :: [Int]...
Recency asked 8/2, 2015 at 0:5

1

Solved

I have the following code {-# LANGUAGE DataKinds, GADTs, TypeOperators #-} data Vect v a where Nil :: Vect '[] a Vec :: a -> Vect v a -> Vect (() ': v) a instance Eq a => Eq (Vect v ...
Handhold asked 15/10, 2013 at 5:31

3

Solved

When I compile the following code with GHC (using the -Wall flag): module Main where data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show) insert :: (Ord a) => a -> Tree a -&g...
Disregard asked 22/5, 2012 at 9:44

2

Consider the following broken function: def sum (list : Seq[Int]) : Int = list match { case Nil => 0 case head :: tail => head + sum(tail) } Here, the function was supposed to work with ...
Hau asked 18/1, 2012 at 14:20

2

Solved

I've got a problem with this code, it should count the longest substring of the same letter in a string, but there is an error: *** Exception: test.hs:(15,0)-(21,17): Non-exhaustive pattern...
Malinda asked 8/12, 2011 at 18:11

2

Solved

This is a follow-up of Why am I getting "Non-exhaustive patterns in function..." when I invoke my Haskell substring function? I understand that using -Wall, GHC can warn against non-exha...

1

Solved

I'm working my way through the book The Haskell Road to Logic, Maths and Programming. (I'm only mid-way through chapter 1, but I'm enjoying it so far and intend to continue.) I've read through the ...
Tessietessier asked 26/9, 2010 at 19:8
1

© 2022 - 2024 — McMap. All rights reserved.