Skip to content

Instantly share code, notes, and snippets.

@LeviSchuck
Created September 21, 2015 03:06
Show Gist options
  • Save LeviSchuck/1070109b98946a4c515f to your computer and use it in GitHub Desktop.
Save LeviSchuck/1070109b98946a4c515f to your computer and use it in GitHub Desktop.
{-# LANGUAGE RecordWildCards #-}
module Ruben where
import Debug.Trace
data SomeState = SomeState
{ a :: Int
, b :: Int
, c :: Int
} deriving(Show)
someFunction s@SomeState{..} = if a < c
then let a' = a + 2
b' = b * 2
in trace (show s) (someFunction s {a = a', b = b'})
else putStrLn (show s)
{-
*Ruben> someFunction (SomeState 1 1 20)
SomeState {a = 1, b = 1, c = 20}
SomeState {a = 3, b = 2, c = 20}
SomeState {a = 5, b = 4, c = 20}
SomeState {a = 7, b = 8, c = 20}
SomeState {a = 9, b = 16, c = 20}
SomeState {a = 11, b = 32, c = 20}
SomeState {a = 13, b = 64, c = 20}
SomeState {a = 15, b = 128, c = 20}
SomeState {a = 17, b = 256, c = 20}
SomeState {a = 19, b = 512, c = 20}
SomeState {a = 21, b = 1024, c = 20}
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment