Skip to content

Instantly share code, notes, and snippets.

View mihassan's full-sized avatar

Md Imrul Hassan mihassan

View GitHub Profile
@mihassan
mihassan / gist:167117f71a7d500c98e9f4fb410c30ca
Created May 30, 2024 21:50
Solution of the hacker rank expressions problem in Haskell
{-# LANGUAGE RecordWildCards #-}
-- | Problem https://www.hackerrank.com/challenges/expressions
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Set (Set)
import qualified Data.Set as Set
@mihassan
mihassan / HackerRankExpressions.hs
Created May 30, 2024 14:02
Solution of the hacker rank expressions problem in Haskell
{-# LANGUAGE RecordWildCards #-}
-- | Problem https://www.hackerrank.com/challenges/expressions
import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.Trans.Class
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.State
@mihassan
mihassan / expression_parser.hs
Last active April 30, 2024 11:32
This Haskell script demonstrates a simple expression parser with monadic combinators.
#!/usr/bin/env cabal
{- cabal:
build-depends: base
-}
{-# LANGUAGE DeriveFunctor #-}
import Control.Applicative
import Control.Monad
import Data.Char
@mihassan
mihassan / .ghci
Created October 9, 2023 02:53
Sample Haskell .ghci template
-- Turn off output for resource usage and types. This is to reduce verbosity when reloading this file.
:unset +s +t
-- Turn on multi-line input and remove the distracting verbosity.
:set +m -v0
-- Turn off all compiler warnings and turn on OverloadedStrings for interactive input.
:seti -w -XOverloadedStrings
-- Set the preferred editor for use with the :e command. I would recommend using an editor in a separate terminal, and using :r to reload, but :e can still be useful for quick edits from within GHCi.
:set editor vim
:def! hoogle \x -> return $ ":!hoogle --color \"" ++ x ++ "\""
@mihassan
mihassan / codeforces_template.hs
Last active July 27, 2024 13:16
Haskell code template for competitive programming
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-|
Module : Main
Description : A Haskell code template designed for competitive programming, targeting platforms like CodeForces.
Presenting a Haskell code template designed for competitive programming, targeting platforms like CodeForces.
The template offers a modular structure to handle diverse tasks including input/output management, parsing, test case segmentation, and formatting.