Created
November 12, 2022 18:39
-
-
Save ThoNohT/8af39ad731835f48cc3c6bd246a19285 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE AllowAmbiguousTypes #-} | |
import qualified Data.List as L | |
class Uncons l a where | |
uncons :: l -> Maybe (a, l) | |
instance Uncons [a] a where uncons = L.uncons | |
newtype Parser l a = Parser {runParser :: l -> Maybe (a, l)} deriving (Functor) | |
end :: forall l a. Uncons l a => Parser l () | |
end = Parser $ \input -> case uncons input of | |
Just _ -> Nothing | |
Nothing -> Just ((), input) | |
main = putStrLn "Hello, World!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment