Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undef Error while using (>>=) #165

Open
Kleidukos opened this issue Jun 12, 2020 · 0 comments
Open

undef Error while using (>>=) #165

Kleidukos opened this issue Jun 12, 2020 · 0 comments
Assignees
Milestone

Comments

@Kleidukos
Copy link
Contributor

Hi! I am currently trying out Hamler and produced the following code:

module Main where                                                      
                                                                       
import Prelude                                                         
import Data.Maybe                                                      
import Data.String as String                                           
                                                                       
main :: IO ()                                                          
main = print "Let there be Hamler, running on Erlang VM!"              
                                                                       
checkPasswordLength :: String -> Maybe String                          
checkPasswordLength password =                                         
  case (String.length password > 20) of                                
       true  -> Nothing                                                
       false -> Just password                                          
                                                                       
cleanWhitespace :: String -> Maybe String                              
cleanWhitespace string =                                               
  case (isSpace x) of                                                  
      true  -> cleanWhitespace xs                                      
      false -> Just $ x <> xs                                          
  where                                                                
    (x, xs) = (String.take 1 string, String.drop 1 string)             
                                                                       
isSpace :: String -> Bool                                              
isSpace " "  = true                                                    
isSpace "\t" = true                                                    
isSpace "\n" = true                                                    
isSpace _    = false                                                   

(Purely for educational purposes).

I tried to run the following code in the REPL, but then got this error:

checkPasswordLength "test"  >>= cleanWhitespace 
Error: error, Reason: undef
Stacktrace:[{'Main',checkPasswordLength,["test"],[]},
            {'$PSCI',it,0,[]},
            {replsrv__escript__1591__956394__873330__5,reploop,1,
                [{file,"/usr/local/lib/hamler/bin/replsrv"},{line,31}]},
            {escript,run,2,[{file,"escript.erl"},{line,758}]},
            {escript,start,1,[{file,"escript.erl"},{line,277}]},
            {init,start_em,1,[]},
            {init,do_boot,3,[]}]
@emqplus emqplus added this to the 0.1.1 milestone Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants