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
import Data.Char (ord) | |
main = print $ rot13 "unccl oveguqnl, funqra!" | |
where | |
rot13 = foldr replace [] | |
alpha = ['a'..'z'] | |
index x = (ord x - ord 'a' + 13) `mod` 26 | |
replace x xs | |
| x `elem` alpha = alpha !! index x:xs | |
| otherwise = x:xs |
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
module Main where | |
import Prelude hiding ( | |
iterate, repeat, map, filter, zipWith, zip, | |
take, takeWhile, drop, dropWhile) | |
import qualified Prelude as P | |
import Text.Printf (printf) | |
import Data.List (intercalate) | |
infixr 5 :> |
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
data Point2D = Point2D { x :: Double, y :: Double } | |
p = Point2D { x = 1 } | |
-- Point2D (D# 1.0) (recConError "x.hs:3:5-21|y"#) | |
main = do | |
print (x p) | |
print (y p) -- BOOM |
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 DeriveGeneric #-} | |
module Main where | |
import Control.DeepSeq | |
import Control.DeepSeq.Generics (genericRnf) | |
import GHC.Generics | |
data List a = Nil | Cons a (List a) deriving (Generic) |
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
diff --git a/rts/Compact.cmm b/rts/Compact.cmm | |
index 72ad4dd437..a4b2d9b2ef 100644 | |
--- a/rts/Compact.cmm | |
+++ b/rts/Compact.cmm | |
@@ -121,17 +121,49 @@ eval: | |
} | |
// We shouldn't see any functions, if this data structure was NFData. | |
+ | |
+ case |
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 GADTs #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
import Data.Typeable | |
import Control.Monad | |
import Control.Exception | |
import Prelude hiding (id) |
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 MagicHash #-} | |
{-# LANGUAGE UnboxedTuples #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
import Control.Monad | |
import Control.Exception | |
import GHC.Exts | |
import GHC.IO | |
import GHC.Prim |
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
/* @flow */ | |
export type ChurchT<A> = <R>(cons: (a: A, r: R) => R, nil: () => R) => R | |
function fromArray<A>(array: Array<A>): ChurchT<A> { | |
return function<R>(cons: (a: A, r: R) => R, nil: () => R): R { | |
let result = nil() | |
for (let i = array.length - 1; i >= 0; --i) { | |
result = cons(array[i], result) | |
} |
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
#!/usr/bin/env stack | |
-- stack --resolver lts-10.3 script --package ghc-typelits-natnormalise | |
{- | |
$ tail -2 Vector.hs | |
print $ toVector @[1, 2, 3, 4, 5] | |
print $ toVector @["whomp", "merp", "yarp"] | |
$ ./Vector.hs |
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
#!/usr/bin/env stack | |
-- stack --resolver lts-10.8 script | |
-- Serializing and deserializing GADTs by using an intermediate | |
-- untyped representation. | |
-- | |
-- Typed | List [And (Not (Equals (Int 1) (Int 2))) (Equals (Bool True) (Bool False)),Bool False] | |
-- Annotated | List [And (Not (Equals (Int 1) (Int 2))) (Equals (Bool True) (Bool False)),Bool False] ::: ListTy BoolTy | |
-- Erased | UList [UAnd (UNot (UEquals (UInt 1) (UInt 2))) (UEquals (UBool True) (UBool False)),UBool False] | |
-- Encoded | "{\"List\":[{\"And\":[{\"Not\":{\"Equals\":[{\"Int\":1},{\"Int\":2}]}},{\"Equals\":[{\"Bool\":true},{\"Bool\":false}]}]},{\"Bool\":false}]}" |
OlderNewer